libpldmresponder: bios: Add SetDataTime
Implement the time setting function based on decode requests,
set values and return responses.
It contains the error response.
Unit tests only include tests for numerical conversion.
Tested:
~# pldmtool bios SetDateTime -d 20200101080000
Encode request successfully
Request Message:
08 01 80 03 0d 00 00 08 01 01 20 20
On first recv(),response == request : RC = 0
Total length: 6
Shutdown Socket successful : RC = 0
Response Message:
08 01 00 03 0d 00
Set date time successfully.
~# busctl get-property xyz.openbmc_project.Time.Manager\
/xyz/openbmc_project/time/host\
xyz.openbmc_project.Time.EpochTime Elapsed
t 1577865726549597
The value of epochtime matches the time entered.
Signed-off-by: Xiaochao Ma <maxiaochao@inspur.com>
Change-Id: I8d123b993d515bcadba1468974907eb56d7e98b9
diff --git a/test/libpldmresponder_bios_test.cpp b/test/libpldmresponder_bios_test.cpp
index 1271dda..762a960 100644
--- a/test/libpldmresponder_bios_test.cpp
+++ b/test/libpldmresponder_bios_test.cpp
@@ -51,6 +51,23 @@
ASSERT_EQ(0x2019, year);
}
+TEST(timeToEpoch, testTime0)
+{
+ std::time_t ret = 1555132693;
+
+ uint8_t sec = 13;
+ uint8_t min = 18;
+ uint8_t hours = 5;
+ uint8_t day = 13;
+ uint8_t month = 4;
+ uint16_t year = 2019;
+
+ std::time_t timeSec = 0;
+ timeSec = timeToEpoch(sec, min, hours, day, month, year);
+
+ EXPECT_EQ(ret, timeSec);
+}
+
TEST(GetBIOSStrings, allScenarios)
{
using namespace bios_parser;