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