blob: 2c83f1ec9740a7fb0de254113bf43d2203c84101 [file] [log] [blame]
Deepak Kodihalli707a3e12017-06-14 03:56:12 -05001#include "elog_entry.hpp"
2#include "elog_serialize.hpp"
Patrick Venturef18bf832018-10-26 18:14:00 -07003#include "serialization_tests.hpp"
Deepak Kodihalli707a3e12017-06-14 03:56:12 -05004
5namespace phosphor
6{
7namespace logging
8{
9namespace test
10{
11
12TEST_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 Spinler375ac9b2018-05-01 15:20:55 -050019 std::string fwLevel{"level42"};
Matt Spinlerfb978da2022-01-21 08:42:24 -060020 std::string inputPath = getEntrySerializePath(id, TestSerialization::dir);
Deepak Kodihalli707a3e12017-06-14 03:56:12 -050021 auto input = std::make_unique<Entry>(
Patrick Venturef18bf832018-10-26 18:14:00 -070022 bus, std::string(OBJ_ENTRY) + '/' + std::to_string(id), id, timestamp,
23 Entry::Level::Informational, std::move(message), std::move(testData),
Matt Spinlerfb978da2022-01-21 08:42:24 -060024 std::move(assocations), fwLevel, inputPath, manager);
Deepak Kodihalli707a3e12017-06-14 03:56:12 -050025 auto path = serialize(*input, TestSerialization::dir);
Matt Spinlerfb978da2022-01-21 08:42:24 -060026 EXPECT_EQ(path, inputPath);
Deepak Kodihalli707a3e12017-06-14 03:56:12 -050027
Patrick Williams7ba65442021-04-22 09:17:18 -050028 auto idStr = path.filename();
29 id = std::stol(idStr.c_str());
Deepak Kodihalli707a3e12017-06-14 03:56:12 -050030 auto output = std::make_unique<Entry>(
Patrick Williams7ba65442021-04-22 09:17:18 -050031 bus, std::filesystem::path(OBJ_ENTRY) / idStr, id, manager);
Deepak Kodihalli707a3e12017-06-14 03:56:12 -050032 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 Spinler375ac9b2018-05-01 15:20:55 -050041 EXPECT_EQ(input->version(), output->version());
42 EXPECT_EQ(input->purpose(), output->purpose());
Matt Spinler1e71a4d2020-03-04 13:40:22 -060043 EXPECT_EQ(input->updateTimestamp(), output->updateTimestamp());
Deepak Kodihalli707a3e12017-06-14 03:56:12 -050044}
45
46} // namespace test
47} // namespace logging
48} // namespace phosphor