blob: e5f26329ab17a647b4e2a5af6e68295a1594c45e [file] [log] [blame]
Matt Spinlerdf13bdb2019-07-10 16:54:13 -05001#include "extensions/openpower-pels/log_id.hpp"
2#include "extensions/openpower-pels/paths.hpp"
3
4#include <arpa/inet.h>
5
6#include <filesystem>
7
8#include <gtest/gtest.h>
9
10using namespace openpower::pels;
11namespace fs = std::filesystem;
12
13TEST(LogIdTest, TimeBasedIDTest)
14{
15 uint32_t lastID = 0;
16 for (int i = 0; i < 10; i++)
17 {
18 auto id = detail::getTimeBasedLogID();
19
20 EXPECT_EQ(id & 0xFF000000, 0x50000000);
21 EXPECT_NE(id, lastID);
22 lastID = id;
23 }
24}
25
26TEST(LogIdTest, IDTest)
27{
28 EXPECT_EQ(generatePELID(), 0x50000001);
29 EXPECT_EQ(generatePELID(), 0x50000002);
30 EXPECT_EQ(generatePELID(), 0x50000003);
31 EXPECT_EQ(generatePELID(), 0x50000004);
32 EXPECT_EQ(generatePELID(), 0x50000005);
33 EXPECT_EQ(generatePELID(), 0x50000006);
34
35 auto backingFile = getPELIDFile();
36 fs::remove(backingFile);
37 EXPECT_EQ(generatePELID(), 0x50000001);
38 EXPECT_EQ(generatePELID(), 0x50000002);
39 EXPECT_EQ(generatePELID(), 0x50000003);
40
41 fs::remove_all(fs::path{backingFile}.parent_path());
42}