From f18bf836d206b1bc5b4fd849127a2e706eddf0aa Mon Sep 17 00:00:00 2001 From: Patrick Venture Date: Fri, 26 Oct 2018 18:14:00 -0700 Subject: add .clang-format Change-Id: I2c36b7886a25d0b235693b0776019d29608e1d52 Signed-off-by: Patrick Venture --- test/elog_errorwrap_test.cpp | 9 ++- test/elog_errorwrap_test.hpp | 106 +++++++++++++++------------------ test/remote_logging_test_address.cpp | 6 +- test/remote_logging_test_config.cpp | 7 ++- test/remote_logging_test_port.cpp | 6 +- test/remote_logging_tests.hpp | 66 ++++++++++---------- test/serialization_test_path.cpp | 9 +-- test/serialization_test_properties.cpp | 22 ++----- test/serialization_tests.hpp | 37 ++++++------ 9 files changed, 120 insertions(+), 148 deletions(-) (limited to 'test') diff --git a/test/elog_errorwrap_test.cpp b/test/elog_errorwrap_test.cpp index f341447..c94c638 100644 --- a/test/elog_errorwrap_test.cpp +++ b/test/elog_errorwrap_test.cpp @@ -16,7 +16,7 @@ TEST_F(TestLogManager, logCap) // Max num of Info( and below Sev) errors can be created is qual to // ERROR_INFO_CAP - EXPECT_EQ(ERROR_INFO_CAP , manager.getInfoErrSize()); + EXPECT_EQ(ERROR_INFO_CAP, manager.getInfoErrSize()); for (auto i = 0; i < ERROR_CAP + 20; i++) { @@ -24,9 +24,8 @@ TEST_F(TestLogManager, logCap) } // Max num of high severity errors can be created is qual to ERROR_CAP EXPECT_EQ(ERROR_CAP, manager.getRealErrSize()); - } -}// namespace internal -}// namespace logging -}// namespace phosphor +} // namespace internal +} // namespace logging +} // namespace phosphor diff --git a/test/elog_errorwrap_test.hpp b/test/elog_errorwrap_test.hpp index 7c673b6..537a7ff 100644 --- a/test/elog_errorwrap_test.hpp +++ b/test/elog_errorwrap_test.hpp @@ -1,14 +1,17 @@ +#include "config.h" + +#include "elog_serialize.hpp" #include "log_manager.hpp" #include "xyz/openbmc_project/Common/error.hpp" -#include -#include -#include + #include +#include #include #include -#include -#include "elog_serialize.hpp" -#include "config.h" +#include + +#include +#include namespace phosphor { @@ -21,30 +24,24 @@ namespace fs = std::experimental::filesystem; class journalInterface { - public: - virtual void journalSync() = 0; - virtual int sd_journal_open(sd_journal** j, int k) = 0; - virtual int sd_journal_get_data(sd_journal* j, - const char* transactionIdVar, - const void** data, - size_t length) = 0; - virtual void sd_journal_close(sd_journal* j) = 0; + public: + virtual void journalSync() = 0; + virtual int sd_journal_open(sd_journal** j, int k) = 0; + virtual int sd_journal_get_data(sd_journal* j, const char* transactionIdVar, + const void** data, size_t length) = 0; + virtual void sd_journal_close(sd_journal* j) = 0; }; class journalImpl : public journalInterface { - public: - void journalSync(); - int sd_journal_open(sd_journal** j, int k); - int sd_journal_get_data(sd_journal* j, - const char* transactionIdVar, - const void** data, - size_t length); - void sd_journal_close(sd_journal* j); + public: + void journalSync(); + int sd_journal_open(sd_journal** j, int k); + int sd_journal_get_data(sd_journal* j, const char* transactionIdVar, + const void** data, size_t length); + void sd_journal_close(sd_journal* j); }; - - int journalImpl::sd_journal_open(sd_journal** j, int k) { return 1; @@ -57,8 +54,7 @@ void journalImpl::journalSync() int journalImpl::sd_journal_get_data(sd_journal* j, const char* transactionIdVar, - const void** data, - size_t length) + const void** data, size_t length) { return 1; } @@ -68,42 +64,36 @@ void journalImpl::sd_journal_close(sd_journal* j) return; } - -class MockJournal : public Manager +class MockJournal : public Manager { - public: - MockJournal(sdbusplus::bus::bus& bus, - const char* objPath): Manager(bus, objPath) {}; - MOCK_METHOD0(journalSync, void()); - MOCK_METHOD2(sd_journal_open, int(sd_journal**, int)); - MOCK_METHOD4(sd_journal_get_data, int(sd_journal*, - const char*, - const void**, size_t)); - MOCK_METHOD1(sd_journal_close, void(sd_journal*)); + public: + MockJournal(sdbusplus::bus::bus& bus, const char* objPath) : + Manager(bus, objPath){}; + MOCK_METHOD0(journalSync, void()); + MOCK_METHOD2(sd_journal_open, int(sd_journal**, int)); + MOCK_METHOD4(sd_journal_get_data, + int(sd_journal*, const char*, const void**, size_t)); + MOCK_METHOD1(sd_journal_close, void(sd_journal*)); }; - - class TestLogManager : public testing::Test { - public: - sdbusplus::bus::bus bus; - MockJournal manager; - TestLogManager() - : bus(sdbusplus::bus::new_default()), - manager(bus, "/xyz/openbmc_test/abc") - { - fs::create_directories(ERRLOG_PERSIST_PATH); - } - - ~TestLogManager() - { - fs::remove_all(ERRLOG_PERSIST_PATH); - } - + public: + sdbusplus::bus::bus bus; + MockJournal manager; + TestLogManager() : + bus(sdbusplus::bus::new_default()), + manager(bus, "/xyz/openbmc_test/abc") + { + fs::create_directories(ERRLOG_PERSIST_PATH); + } + + ~TestLogManager() + { + fs::remove_all(ERRLOG_PERSIST_PATH); + } }; - -}// nmaespace internal -}// namespace logging -}// namespace phosphor +} // namespace internal +} // namespace logging +} // namespace phosphor diff --git a/test/remote_logging_test_address.cpp b/test/remote_logging_test_address.cpp index 1291a2e..5c8794e 100644 --- a/test/remote_logging_test_address.cpp +++ b/test/remote_logging_test_address.cpp @@ -21,6 +21,6 @@ TEST_F(TestRemoteLogging, testBadAddress) EXPECT_THROW(config->address("not_an_IP"), InvalidArgument); } -}// namespace test -}// namespace logging -}// namespace phosphor +} // namespace test +} // namespace logging +} // namespace phosphor diff --git a/test/remote_logging_test_config.cpp b/test/remote_logging_test_config.cpp index 8c3a98a..59feedd 100644 --- a/test/remote_logging_test_config.cpp +++ b/test/remote_logging_test_config.cpp @@ -1,4 +1,5 @@ #include "remote_logging_tests.hpp" + #include namespace phosphor @@ -53,6 +54,6 @@ TEST_F(TestRemoteLogging, testClearPort) EXPECT_EQ(getConfig(configFilePath.c_str()), "#*.* @@remote-host:port"); } -}// namespace test -}// namespace logging -}// namespace phosphor +} // namespace test +} // namespace logging +} // namespace phosphor diff --git a/test/remote_logging_test_port.cpp b/test/remote_logging_test_port.cpp index a9d3bc3..cf1a42e 100644 --- a/test/remote_logging_test_port.cpp +++ b/test/remote_logging_test_port.cpp @@ -13,6 +13,6 @@ TEST_F(TestRemoteLogging, testGoodPort) EXPECT_EQ(config->port(), 100); } -}// namespace test -}// namespace logging -}// namespace phosphor +} // namespace test +} // namespace logging +} // namespace phosphor diff --git a/test/remote_logging_tests.hpp b/test/remote_logging_tests.hpp index 3606f5a..936e3bb 100644 --- a/test/remote_logging_tests.hpp +++ b/test/remote_logging_tests.hpp @@ -1,9 +1,12 @@ -#include -#include -#include #include "config.h" + #include "phosphor-rsyslog-config/server-conf.hpp" + +#include +#include + #include "gmock/gmock.h" +#include namespace phosphor { @@ -20,45 +23,40 @@ fs::path dir(fs::path(mkdtemp(tmplt))); class MockServer : public phosphor::rsyslog_config::Server { - public: - MockServer(sdbusplus::bus::bus& bus, - const std::string& path, + public: + MockServer(sdbusplus::bus::bus& bus, const std::string& path, const char* filePath) : - phosphor::rsyslog_config::Server(bus, path, filePath) - { - } + phosphor::rsyslog_config::Server(bus, path, filePath) + { + } - MOCK_METHOD0(restart, void()); + MOCK_METHOD0(restart, void()); }; class TestRemoteLogging : public testing::Test { - public: - TestRemoteLogging() - { - configFilePath = std::string(dir.c_str()) + "/server.conf"; - config = - new MockServer(bus, - BUSPATH_REMOTE_LOGGING_CONFIG, - configFilePath.c_str()); - } - - ~TestRemoteLogging() - { - delete config; - } - - static void TearDownTestCase() - { - fs::remove_all(dir); - } - - MockServer* config; - std::string configFilePath; + public: + TestRemoteLogging() + { + configFilePath = std::string(dir.c_str()) + "/server.conf"; + config = new MockServer(bus, BUSPATH_REMOTE_LOGGING_CONFIG, + configFilePath.c_str()); + } + + ~TestRemoteLogging() + { + delete config; + } + + static void TearDownTestCase() + { + fs::remove_all(dir); + } + + MockServer* config; + std::string configFilePath; }; } // namespace test } // namespace logging } // namespace phosphor - - diff --git a/test/serialization_test_path.cpp b/test/serialization_test_path.cpp index 50e7d08..379b124 100644 --- a/test/serialization_test_path.cpp +++ b/test/serialization_test_path.cpp @@ -1,6 +1,6 @@ -#include "serialization_tests.hpp" #include "elog_entry.hpp" #include "elog_serialize.hpp" +#include "serialization_tests.hpp" namespace phosphor { @@ -13,10 +13,7 @@ TEST_F(TestSerialization, testPath) { auto id = 99; auto e = std::make_unique( - bus, - std::string(OBJ_ENTRY) + '/' + std::to_string(id), - id, - manager); + bus, std::string(OBJ_ENTRY) + '/' + std::to_string(id), id, manager); auto path = serialize(*e, TestSerialization::dir); EXPECT_EQ(path.c_str(), TestSerialization::dir / std::to_string(id)); } @@ -24,5 +21,3 @@ TEST_F(TestSerialization, testPath) } // namespace test } // namespace logging } // namespace phosphor - - diff --git a/test/serialization_test_properties.cpp b/test/serialization_test_properties.cpp index be9a7c7..8c92024 100644 --- a/test/serialization_test_properties.cpp +++ b/test/serialization_test_properties.cpp @@ -1,6 +1,6 @@ -#include "serialization_tests.hpp" #include "elog_entry.hpp" #include "elog_serialize.hpp" +#include "serialization_tests.hpp" namespace phosphor { @@ -18,25 +18,15 @@ TEST_F(TestSerialization, testProperties) std::string message{"test error"}; std::string fwLevel{"level42"}; auto input = std::make_unique( - bus, - std::string(OBJ_ENTRY) + '/' + std::to_string(id), - id, - timestamp, - Entry::Level::Informational, - std::move(message), - std::move(testData), - std::move(assocations), - fwLevel, - manager); + bus, std::string(OBJ_ENTRY) + '/' + std::to_string(id), id, timestamp, + Entry::Level::Informational, std::move(message), std::move(testData), + std::move(assocations), fwLevel, manager); auto path = serialize(*input, TestSerialization::dir); auto idStr = path.filename().c_str(); id = std::stol(idStr); auto output = std::make_unique( - bus, - std::string(OBJ_ENTRY) + '/' + idStr, - id, - manager); + bus, std::string(OBJ_ENTRY) + '/' + idStr, id, manager); deserialize(path, *output); EXPECT_EQ(input->id(), output->id()); @@ -53,5 +43,3 @@ TEST_F(TestSerialization, testProperties) } // namespace test } // namespace logging } // namespace phosphor - - diff --git a/test/serialization_tests.hpp b/test/serialization_tests.hpp index a8054d3..6e41379 100644 --- a/test/serialization_tests.hpp +++ b/test/serialization_tests.hpp @@ -1,9 +1,13 @@ -#include -#include +#include "config.h" + +#include "log_manager.hpp" + #include + +#include #include -#include "log_manager.hpp" -#include "config.h" + +#include namespace phosphor { @@ -20,22 +24,19 @@ phosphor::logging::internal::Manager manager(bus, OBJ_INTERNAL); class TestSerialization : public testing::Test { - public: - TestSerialization() : - dir(fs::path(mkdtemp(tmplt))) - { - } - - ~TestSerialization() - { - fs::remove_all(dir); - } - - fs::path dir; + public: + TestSerialization() : dir(fs::path(mkdtemp(tmplt))) + { + } + + ~TestSerialization() + { + fs::remove_all(dir); + } + + fs::path dir; }; } // namespace test } // namespace logging } // namespace phosphor - - -- cgit v1.2.1