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"}; |
Deepak Kodihalli | 707a3e1 | 2017-06-14 03:56:12 -0500 | [diff] [blame] | 20 | auto input = std::make_unique<Entry>( |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 21 | bus, std::string(OBJ_ENTRY) + '/' + std::to_string(id), id, timestamp, |
| 22 | Entry::Level::Informational, std::move(message), std::move(testData), |
| 23 | std::move(assocations), fwLevel, manager); |
Deepak Kodihalli | 707a3e1 | 2017-06-14 03:56:12 -0500 | [diff] [blame] | 24 | auto path = serialize(*input, TestSerialization::dir); |
| 25 | |
| 26 | auto idStr = path.filename().c_str(); |
| 27 | id = std::stol(idStr); |
| 28 | auto output = std::make_unique<Entry>( |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 29 | bus, std::string(OBJ_ENTRY) + '/' + idStr, id, manager); |
Deepak Kodihalli | 707a3e1 | 2017-06-14 03:56:12 -0500 | [diff] [blame] | 30 | deserialize(path, *output); |
| 31 | |
| 32 | EXPECT_EQ(input->id(), output->id()); |
| 33 | EXPECT_EQ(input->severity(), output->severity()); |
| 34 | EXPECT_EQ(input->timestamp(), output->timestamp()); |
| 35 | EXPECT_EQ(input->message(), output->message()); |
| 36 | EXPECT_EQ(input->additionalData(), output->additionalData()); |
| 37 | EXPECT_EQ(input->resolved(), output->resolved()); |
| 38 | EXPECT_EQ(input->associations(), output->associations()); |
Matt Spinler | 375ac9b | 2018-05-01 15:20:55 -0500 | [diff] [blame] | 39 | EXPECT_EQ(input->version(), output->version()); |
| 40 | EXPECT_EQ(input->purpose(), output->purpose()); |
Deepak Kodihalli | 707a3e1 | 2017-06-14 03:56:12 -0500 | [diff] [blame] | 41 | } |
| 42 | |
| 43 | } // namespace test |
| 44 | } // namespace logging |
| 45 | } // namespace phosphor |