1 #include "libpldmresponder/bios.hpp"
2 #include "libpldmresponder/bios_table.hpp"
3
4 #include <libpldm/base.h>
5 #include <libpldm/bios.h>
6 #include <string.h>
7
8 #include <array>
9 #include <cstring>
10 #include <ctime>
11 #include <filesystem>
12
13 #include <gtest/gtest.h>
14
15 using namespace pldm;
16 using namespace pldm::responder;
17 using namespace pldm::responder::bios;
18 using namespace pldm::responder::utils;
19
TEST(epochToBCDTime,testTime)20 TEST(epochToBCDTime, testTime)
21 {
22 struct tm time
23 {};
24 time.tm_year = 119;
25 time.tm_mon = 3;
26 time.tm_mday = 13;
27 time.tm_hour = 5;
28 time.tm_min = 18;
29 time.tm_sec = 13;
30 time.tm_isdst = -1;
31
32 time_t epochTime = mktime(&time);
33 uint8_t seconds = 0;
34 uint8_t minutes = 0;
35 uint8_t hours = 0;
36 uint8_t day = 0;
37 uint8_t month = 0;
38 uint16_t year = 0;
39
40 epochToBCDTime(epochTime, seconds, minutes, hours, day, month, year);
41
42 ASSERT_EQ(0x13, seconds);
43 ASSERT_EQ(0x18, minutes);
44 ASSERT_EQ(0x5, hours);
45 ASSERT_EQ(0x13, day);
46 ASSERT_EQ(0x4, month);
47 ASSERT_EQ(0x2019, year);
48 }
49
TEST(timeToEpoch,testTime0)50 TEST(timeToEpoch, testTime0)
51 {
52 std::time_t ret = 1555132693;
53
54 uint8_t sec = 13;
55 uint8_t min = 18;
56 uint8_t hours = 5;
57 uint8_t day = 13;
58 uint8_t month = 4;
59 uint16_t year = 2019;
60
61 std::time_t timeSec = 0;
62 timeSec = timeToEpoch(sec, min, hours, day, month, year);
63
64 EXPECT_EQ(ret, timeSec);
65 }
66