Deepak Kodihalli | 707a3e1 | 2017-06-14 03:56:12 -0500 | [diff] [blame] | 1 | #include "elog_entry.hpp" |
| 2 | #include "elog_serialize.hpp" |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 3 | #include "serialization_tests.hpp" |
Deepak Kodihalli | 707a3e1 | 2017-06-14 03:56:12 -0500 | [diff] [blame] | 4 | |
| 5 | namespace phosphor |
| 6 | { |
| 7 | namespace logging |
| 8 | { |
| 9 | namespace test |
| 10 | { |
| 11 | |
| 12 | TEST_F(TestSerialization, testProperties) |
| 13 | { |
| 14 | auto id = 99; |
| 15 | phosphor::logging::AssociationList assocations{}; |
| 16 | std::vector<std::string> testData{"additional", "data"}; |
| 17 | uint64_t timestamp{100}; |
| 18 | std::string message{"test error"}; |
Matt Spinler | 375ac9b | 2018-05-01 15:20:55 -0500 | [diff] [blame] | 19 | std::string fwLevel{"level42"}; |
Matt Spinler | fb978da | 2022-01-21 08:42:24 -0600 | [diff] [blame] | 20 | std::string inputPath = getEntrySerializePath(id, TestSerialization::dir); |
Deepak Kodihalli | 707a3e1 | 2017-06-14 03:56:12 -0500 | [diff] [blame] | 21 | auto input = std::make_unique<Entry>( |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 22 | bus, std::string(OBJ_ENTRY) + '/' + std::to_string(id), id, timestamp, |
| 23 | Entry::Level::Informational, std::move(message), std::move(testData), |
Matt Spinler | fb978da | 2022-01-21 08:42:24 -0600 | [diff] [blame] | 24 | std::move(assocations), fwLevel, inputPath, manager); |
Deepak Kodihalli | 707a3e1 | 2017-06-14 03:56:12 -0500 | [diff] [blame] | 25 | auto path = serialize(*input, TestSerialization::dir); |
Matt Spinler | fb978da | 2022-01-21 08:42:24 -0600 | [diff] [blame] | 26 | EXPECT_EQ(path, inputPath); |
Deepak Kodihalli | 707a3e1 | 2017-06-14 03:56:12 -0500 | [diff] [blame] | 27 | |
Patrick Williams | 7ba6544 | 2021-04-22 09:17:18 -0500 | [diff] [blame] | 28 | auto idStr = path.filename(); |
| 29 | id = std::stol(idStr.c_str()); |
Deepak Kodihalli | 707a3e1 | 2017-06-14 03:56:12 -0500 | [diff] [blame] | 30 | auto output = std::make_unique<Entry>( |
Patrick Williams | 7ba6544 | 2021-04-22 09:17:18 -0500 | [diff] [blame] | 31 | bus, std::filesystem::path(OBJ_ENTRY) / idStr, id, manager); |
Deepak Kodihalli | 707a3e1 | 2017-06-14 03:56:12 -0500 | [diff] [blame] | 32 | deserialize(path, *output); |
| 33 | |
| 34 | EXPECT_EQ(input->id(), output->id()); |
| 35 | EXPECT_EQ(input->severity(), output->severity()); |
| 36 | EXPECT_EQ(input->timestamp(), output->timestamp()); |
| 37 | EXPECT_EQ(input->message(), output->message()); |
| 38 | EXPECT_EQ(input->additionalData(), output->additionalData()); |
| 39 | EXPECT_EQ(input->resolved(), output->resolved()); |
| 40 | EXPECT_EQ(input->associations(), output->associations()); |
Matt Spinler | 375ac9b | 2018-05-01 15:20:55 -0500 | [diff] [blame] | 41 | EXPECT_EQ(input->version(), output->version()); |
| 42 | EXPECT_EQ(input->purpose(), output->purpose()); |
Matt Spinler | 1e71a4d | 2020-03-04 13:40:22 -0600 | [diff] [blame] | 43 | EXPECT_EQ(input->updateTimestamp(), output->updateTimestamp()); |
Deepak Kodihalli | 707a3e1 | 2017-06-14 03:56:12 -0500 | [diff] [blame] | 44 | } |
| 45 | |
| 46 | } // namespace test |
| 47 | } // namespace logging |
| 48 | } // namespace phosphor |