blob: be9a7c740457b81a35684ddf858a2a02a58adcc7 [file] [log] [blame]
Deepak Kodihalli707a3e12017-06-14 03:56:12 -05001#include "serialization_tests.hpp"
2#include "elog_entry.hpp"
3#include "elog_serialize.hpp"
4
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>(
21 bus,
22 std::string(OBJ_ENTRY) + '/' + std::to_string(id),
23 id,
24 timestamp,
25 Entry::Level::Informational,
26 std::move(message),
27 std::move(testData),
28 std::move(assocations),
Matt Spinler375ac9b2018-05-01 15:20:55 -050029 fwLevel,
Deepak Kodihalli707a3e12017-06-14 03:56:12 -050030 manager);
31 auto path = serialize(*input, TestSerialization::dir);
32
33 auto idStr = path.filename().c_str();
34 id = std::stol(idStr);
35 auto output = std::make_unique<Entry>(
36 bus,
37 std::string(OBJ_ENTRY) + '/' + idStr,
38 id,
39 manager);
40 deserialize(path, *output);
41
42 EXPECT_EQ(input->id(), output->id());
43 EXPECT_EQ(input->severity(), output->severity());
44 EXPECT_EQ(input->timestamp(), output->timestamp());
45 EXPECT_EQ(input->message(), output->message());
46 EXPECT_EQ(input->additionalData(), output->additionalData());
47 EXPECT_EQ(input->resolved(), output->resolved());
48 EXPECT_EQ(input->associations(), output->associations());
Matt Spinler375ac9b2018-05-01 15:20:55 -050049 EXPECT_EQ(input->version(), output->version());
50 EXPECT_EQ(input->purpose(), output->purpose());
Deepak Kodihalli707a3e12017-06-14 03:56:12 -050051}
52
53} // namespace test
54} // namespace logging
55} // namespace phosphor
56
57