blob: 270f8bca25e007001ae89330fb0a7995be26610c [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"};
Deepak Kodihalli707a3e12017-06-14 03:56:12 -050020 auto input = std::make_unique<Entry>(
Patrick Venturef18bf832018-10-26 18:14:00 -070021 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 Kodihalli707a3e12017-06-14 03:56:12 -050024 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 Venturef18bf832018-10-26 18:14:00 -070029 bus, std::string(OBJ_ENTRY) + '/' + idStr, id, manager);
Deepak Kodihalli707a3e12017-06-14 03:56:12 -050030 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 Spinler375ac9b2018-05-01 15:20:55 -050039 EXPECT_EQ(input->version(), output->version());
40 EXPECT_EQ(input->purpose(), output->purpose());
Matt Spinler1e71a4d2020-03-04 13:40:22 -060041 EXPECT_EQ(input->updateTimestamp(), output->updateTimestamp());
Deepak Kodihalli707a3e12017-06-14 03:56:12 -050042}
43
44} // namespace test
45} // namespace logging
46} // namespace phosphor