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