add .clang-format
Change-Id: I6d9ec8401dcd46781ea258bf8998faa2507fa91d
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/test/argument_test.cpp b/test/argument_test.cpp
index e293e99..3cb5dc9 100644
--- a/test/argument_test.cpp
+++ b/test/argument_test.cpp
@@ -1,8 +1,9 @@
-#include <string>
-#include <vector>
+#include "argument_test.hpp"
#include "argument.hpp"
-#include "argument_test.hpp"
+
+#include <string>
+#include <vector>
static const std::string expected_path1 = "/arg1-test-path";
static const std::string expected_target1 = "t1.target";
@@ -10,7 +11,7 @@
// Allow for a single unrecognized option then the Usage printout
static const std::string invalid_arg_regex =
- "^[^\n]*unrecognized option[^\n]*\nUsage: ";
+ "^[^\n]*unrecognized option[^\n]*\nUsage: ";
static const std::string clean_usage_regex = "^Usage: ";
@@ -27,10 +28,8 @@
/** @brief ArgumentParser should return no values if given no options */
TEST_F(ArgumentTest, NoOptions)
{
- char * const args[] = {
- &arg0[0], nullptr
- };
- ArgumentParser ap(sizeof(args)/sizeof(char *) - 1, args);
+ char* const args[] = {&arg0[0], nullptr};
+ ArgumentParser ap(sizeof(args) / sizeof(char*) - 1, args);
EXPECT_EQ(std::vector<std::string>({}), ap["path"]);
EXPECT_EQ(std::vector<std::string>({}), ap["continue"]);
EXPECT_EQ(std::vector<std::string>({}), ap["arbitrary_unknown"]);
@@ -44,13 +43,11 @@
{
std::string arg_continue = "--continue";
std::string arg_extra = "not-a-bool";
- char * const args[] = {
- &arg0[0], &arg_continue[0], &arg_extra[0], nullptr
- };
- ArgumentParser ap(sizeof(args)/sizeof(char *) - 1, args);
+ char* const args[] = {&arg0[0], &arg_continue[0], &arg_extra[0], nullptr};
+ ArgumentParser ap(sizeof(args) / sizeof(char*) - 1, args);
EXPECT_EQ(std::vector<std::string>({}), ap["path"]);
EXPECT_EQ(std::vector<std::string>({ArgumentParser::trueString}),
- ap["continue"]);
+ ap["continue"]);
}
/** @brief ArgumentParser should return a string for long options that
@@ -61,10 +58,9 @@
std::string arg_path = "--path";
std::string arg_path_val = expected_path1;
std::string arg_extra = "/unused-path";
- char * const args[] = {
- &arg0[0], &arg_path[0], &arg_path_val[0], &arg_extra[0], nullptr
- };
- ArgumentParser ap(sizeof(args)/sizeof(char *) - 1, args);
+ char* const args[] = {&arg0[0], &arg_path[0], &arg_path_val[0],
+ &arg_extra[0], nullptr};
+ ArgumentParser ap(sizeof(args) / sizeof(char*) - 1, args);
EXPECT_EQ(std::vector<std::string>({expected_path1}), ap["path"]);
}
@@ -75,10 +71,8 @@
{
std::string arg_path = "--path=" + expected_path1;
std::string arg_extra = "/unused-path";
- char * const args[] = {
- &arg0[0], &arg_path[0], &arg_extra[0], nullptr
- };
- ArgumentParser ap(sizeof(args)/sizeof(char *) - 1, args);
+ char* const args[] = {&arg0[0], &arg_path[0], &arg_extra[0], nullptr};
+ ArgumentParser ap(sizeof(args) / sizeof(char*) - 1, args);
EXPECT_EQ(std::vector<std::string>({expected_path1}), ap["path"]);
}
@@ -90,10 +84,9 @@
std::string arg_path = "-p";
std::string arg_path_val = expected_path1;
std::string arg_extra = "/unused-path";
- char * const args[] = {
- &arg0[0], &arg_path[0], &arg_path_val[0], &arg_extra[0], nullptr
- };
- ArgumentParser ap(sizeof(args)/sizeof(char *) - 1, args);
+ char* const args[] = {&arg0[0], &arg_path[0], &arg_path_val[0],
+ &arg_extra[0], nullptr};
+ ArgumentParser ap(sizeof(args) / sizeof(char*) - 1, args);
EXPECT_EQ(std::vector<std::string>({expected_path1}), ap["path"]);
}
@@ -109,17 +102,17 @@
std::string arg_target = "--target=" + expected_target2;
std::string arg_target_short = "-t";
std::string arg_target_val = expected_target1;
- char * const args[] = {
- &arg0[0], &arg_continue_short[0], &arg_path[0], &arg_continue_long[0],
- &arg_target[0], &arg_target_short[0], &arg_target_val[0], nullptr
- };
- ArgumentParser ap(sizeof(args)/sizeof(char *) - 1, args);
+ char* const args[] = {&arg0[0], &arg_continue_short[0],
+ &arg_path[0], &arg_continue_long[0],
+ &arg_target[0], &arg_target_short[0],
+ &arg_target_val[0], nullptr};
+ ArgumentParser ap(sizeof(args) / sizeof(char*) - 1, args);
EXPECT_EQ(std::vector<std::string>({expected_path1}), ap["path"]);
- EXPECT_EQ(std::vector<std::string>({
- ArgumentParser::trueString, ArgumentParser::trueString}),
- ap["continue"]);
+ EXPECT_EQ(std::vector<std::string>(
+ {ArgumentParser::trueString, ArgumentParser::trueString}),
+ ap["continue"]);
EXPECT_EQ(std::vector<std::string>({expected_target2, expected_target1}),
- ap["target"]);
+ ap["target"]);
}
/** @brief ArgumentParser should print usage information when given a help
@@ -129,11 +122,9 @@
{
std::string arg_extra = "extra";
std::string arg_help = "-h";
- char * const args[] = {
- &arg0[0], &arg_extra[0], &arg_help[0], nullptr
- };
- EXPECT_EXIT(ArgumentParser(sizeof(args)/sizeof(char *) - 1, args),
- ::testing::ExitedWithCode(255), clean_usage_regex);
+ char* const args[] = {&arg0[0], &arg_extra[0], &arg_help[0], nullptr};
+ EXPECT_EXIT(ArgumentParser(sizeof(args) / sizeof(char*) - 1, args),
+ ::testing::ExitedWithCode(255), clean_usage_regex);
}
/** @brief ArgumentParser should print usage information when given a help
@@ -143,11 +134,9 @@
{
std::string arg_help = "--help";
std::string arg_extra = "extra";
- char * const args[] = {
- &arg0[0], &arg_help[0], &arg_extra[0], nullptr
- };
- EXPECT_EXIT(ArgumentParser(sizeof(args)/sizeof(char *) - 1, args),
- ::testing::ExitedWithCode(255), clean_usage_regex);
+ char* const args[] = {&arg0[0], &arg_help[0], &arg_extra[0], nullptr};
+ EXPECT_EXIT(ArgumentParser(sizeof(args) / sizeof(char*) - 1, args),
+ ::testing::ExitedWithCode(255), clean_usage_regex);
}
/** @brief ArgumentParser should print an invalid argument error and
@@ -159,12 +148,11 @@
std::string arg_continue = "--continue";
std::string arg_bad = "--bad_arg";
std::string arg_target = "--target=/unused-path";
- char * const args[] = {
- &arg0[0], &arg_continue[0], &arg_bad[0], &arg_target[0], nullptr
- };
- EXPECT_EXIT(ArgumentParser(sizeof(args)/sizeof(char *) - 1, args),
- ::testing::ExitedWithCode(255), invalid_arg_regex);
+ char* const args[] = {&arg0[0], &arg_continue[0], &arg_bad[0],
+ &arg_target[0], nullptr};
+ EXPECT_EXIT(ArgumentParser(sizeof(args) / sizeof(char*) - 1, args),
+ ::testing::ExitedWithCode(255), invalid_arg_regex);
}
-} // namespace watchdog
-} // namespace phosphor
+} // namespace watchdog
+} // namespace phosphor
diff --git a/test/argument_test.hpp b/test/argument_test.hpp
index 9e8c565..46e8762 100644
--- a/test/argument_test.hpp
+++ b/test/argument_test.hpp
@@ -11,11 +11,11 @@
class ArgumentTest : public testing::Test
{
- protected:
- void SetUp() override;
+ protected:
+ void SetUp() override;
- std::string arg0;
+ std::string arg0;
};
-} // namespace watchdog
-} // namespace phosphor
+} // namespace watchdog
+} // namespace phosphor
diff --git a/test/timer_test.cpp b/test/timer_test.cpp
index 3deef08..ea00228 100644
--- a/test/timer_test.cpp
+++ b/test/timer_test.cpp
@@ -21,11 +21,11 @@
// Waiting 2 seconds to expect expiration
int count = 0;
- while(count < expireTime.count() && !timer.expired())
+ while (count < expireTime.count() && !timer.expired())
{
// Returns -0- on timeout and positive number on dispatch
auto sleepTime = duration_cast<microseconds>(seconds(1));
- if(!sd_event_run(eventP.get(), sleepTime.count()))
+ if (!sd_event_run(eventP.get(), sleepTime.count()))
{
count++;
}
@@ -46,8 +46,8 @@
// Expect timer to expire in 2 seconds
auto expireTime = seconds(2s);
- phosphor::watchdog::Timer timer(eventP,
- std::bind(&TimerTest::timeOutHandler, this));
+ phosphor::watchdog::Timer timer(
+ eventP, std::bind(&TimerTest::timeOutHandler, this));
// Set the expiration and enable the timer
timer.start(duration_cast<milliseconds>(expireTime));
@@ -55,11 +55,11 @@
// Waiting 2 seconds to expect expiration
int count = 0;
- while(count < expireTime.count() && !timer.expired())
+ while (count < expireTime.count() && !timer.expired())
{
// Returns -0- on timeout and positive number on dispatch
auto sleepTime = duration_cast<microseconds>(seconds(1));
- if(!sd_event_run(eventP.get(), sleepTime.count()))
+ if (!sd_event_run(eventP.get(), sleepTime.count()))
{
count++;
}
diff --git a/test/timer_test.hpp b/test/timer_test.hpp
index 3f6ffea..cab9086 100644
--- a/test/timer_test.hpp
+++ b/test/timer_test.hpp
@@ -1,40 +1,39 @@
#include <iostream>
-#include <gtest/gtest.h>
#include <timer.hpp>
+#include <gtest/gtest.h>
+
// Base class for testing Timer
class TimerTest : public testing::Test
{
- public:
- // systemd event handler
- sd_event* events;
+ public:
+ // systemd event handler
+ sd_event* events;
- // Need this so that events can be initialized.
- int rc;
+ // Need this so that events can be initialized.
+ int rc;
- // Tells if the watchdog timer expired.
- bool expired = false;
+ // Tells if the watchdog timer expired.
+ bool expired = false;
- // Gets called as part of each TEST_F construction
- TimerTest()
- : rc(sd_event_default(&events)),
- eventP(events)
- {
- // Check for successful creation of
- // event handler and bus handler
- EXPECT_GE(rc, 0);
+ // Gets called as part of each TEST_F construction
+ TimerTest() : rc(sd_event_default(&events)), eventP(events)
+ {
+ // Check for successful creation of
+ // event handler and bus handler
+ EXPECT_GE(rc, 0);
- // Its already wrapped in eventP
- events = nullptr;
- }
+ // Its already wrapped in eventP
+ events = nullptr;
+ }
- // unique_ptr for sd_event
- phosphor::watchdog::EventPtr eventP;
+ // unique_ptr for sd_event
+ phosphor::watchdog::EventPtr eventP;
- // Handler called by timer expiration
- inline void timeOutHandler()
- {
- std::cout << "Time out handler called" << std::endl;
- expired = true;
- }
+ // Handler called by timer expiration
+ inline void timeOutHandler()
+ {
+ std::cout << "Time out handler called" << std::endl;
+ expired = true;
+ }
};
diff --git a/test/watchdog_test.cpp b/test/watchdog_test.cpp
index 34d1d24..f24d45e 100644
--- a/test/watchdog_test.cpp
+++ b/test/watchdog_test.cpp
@@ -1,24 +1,23 @@
+#include "watchdog_test.hpp"
+
#include <chrono>
#include <memory>
#include <utility>
-#include "watchdog_test.hpp"
-
using namespace phosphor::watchdog;
seconds WdogTest::waitForWatchdog(seconds timeLimit)
{
auto previousTimeRemaining = wdog->timeRemaining();
auto ret = 0s;
- while (ret < timeLimit &&
- previousTimeRemaining >= wdog->timeRemaining() &&
+ while (ret < timeLimit && previousTimeRemaining >= wdog->timeRemaining() &&
wdog->timerEnabled())
{
previousTimeRemaining = wdog->timeRemaining();
// Returns -0- on timeout and positive number on dispatch
auto sleepTime = 1s;
- if(!sd_event_run(eventP.get(), microseconds(sleepTime).count()))
+ if (!sd_event_run(eventP.get(), microseconds(sleepTime).count()))
{
ret += sleepTime;
}
@@ -194,7 +193,8 @@
};
std::map<Watchdog::Action, Watchdog::TargetName> emptyActionTargets;
wdog = std::make_unique<Watchdog>(bus, TEST_PATH, eventP,
- std::move(emptyActionTargets), std::move(fallback));
+ std::move(emptyActionTargets),
+ std::move(fallback));
EXPECT_EQ(primaryInterval, milliseconds(wdog->interval(primaryIntervalMs)));
EXPECT_FALSE(wdog->enabled());
EXPECT_EQ(0, wdog->timeRemaining());
@@ -218,7 +218,7 @@
auto newIntervalMs = milliseconds(newInterval).count();
EXPECT_EQ(newInterval, milliseconds(wdog->interval(newIntervalMs)));
EXPECT_EQ(Watchdog::Action::None,
- wdog->expireAction(Watchdog::Action::None));
+ wdog->expireAction(Watchdog::Action::None));
EXPECT_FALSE(wdog->enabled());
EXPECT_GE(remaining, milliseconds(wdog->timeRemaining()));
@@ -277,7 +277,8 @@
};
std::map<Watchdog::Action, Watchdog::TargetName> emptyActionTargets;
wdog = std::make_unique<Watchdog>(bus, TEST_PATH, eventP,
- std::move(emptyActionTargets), std::move(fallback));
+ std::move(emptyActionTargets),
+ std::move(fallback));
EXPECT_EQ(primaryInterval, milliseconds(wdog->interval(primaryIntervalMs)));
EXPECT_FALSE(wdog->enabled());
EXPECT_EQ(0, wdog->timeRemaining());
@@ -331,7 +332,8 @@
};
std::map<Watchdog::Action, Watchdog::TargetName> emptyActionTargets;
wdog = std::make_unique<Watchdog>(bus, TEST_PATH, eventP,
- std::move(emptyActionTargets), std::move(fallback));
+ std::move(emptyActionTargets),
+ std::move(fallback));
EXPECT_EQ(primaryInterval, milliseconds(wdog->interval(primaryIntervalMs)));
EXPECT_FALSE(wdog->enabled());
auto remaining = milliseconds(wdog->timeRemaining());
diff --git a/test/watchdog_test.hpp b/test/watchdog_test.hpp
index 87c64e9..50fa8f1 100644
--- a/test/watchdog_test.hpp
+++ b/test/watchdog_test.hpp
@@ -1,6 +1,6 @@
-#include <timer_test.hpp>
#include <chrono>
#include <memory>
+#include <timer_test.hpp>
#include <watchdog.hpp>
using namespace std::chrono;
@@ -9,44 +9,43 @@
// Test Watchdog functionality
class WdogTest : public TimerTest
{
- public:
- // Gets called as part of each TEST_F construction
- WdogTest()
- : bus(sdbusplus::bus::new_default()),
- wdog(std::make_unique<phosphor::watchdog::Watchdog>(
- bus, TEST_PATH, eventP)),
- defaultInterval(milliseconds(wdog->interval())),
- defaultDrift(30)
- {
- // Check for successful creation of
- // event handler and bus handler
- EXPECT_GE(rc, 0);
+ public:
+ // Gets called as part of each TEST_F construction
+ WdogTest() :
+ bus(sdbusplus::bus::new_default()),
+ wdog(std::make_unique<phosphor::watchdog::Watchdog>(bus, TEST_PATH,
+ eventP)),
+ defaultInterval(milliseconds(wdog->interval())), defaultDrift(30)
+ {
+ // Check for successful creation of
+ // event handler and bus handler
+ EXPECT_GE(rc, 0);
- // Initially the watchdog would be disabled
- EXPECT_FALSE(wdog->enabled());
- }
+ // Initially the watchdog would be disabled
+ EXPECT_FALSE(wdog->enabled());
+ }
- //sdbusplus handle
- sdbusplus::bus::bus bus;
+ // sdbusplus handle
+ sdbusplus::bus::bus bus;
- // Watchdog object
- std::unique_ptr<phosphor::watchdog::Watchdog> wdog;
+ // Watchdog object
+ std::unique_ptr<phosphor::watchdog::Watchdog> wdog;
- // This is the default interval as given in Interface definition
- milliseconds defaultInterval;
+ // This is the default interval as given in Interface definition
+ milliseconds defaultInterval;
- // Acceptable drift when we compare the interval to timeRemaining.
- // This is needed since it depends on when do we get scheduled and it
- // has happened that remaining time was off by few msecs.
- milliseconds defaultDrift;
+ // Acceptable drift when we compare the interval to timeRemaining.
+ // This is needed since it depends on when do we get scheduled and it
+ // has happened that remaining time was off by few msecs.
+ milliseconds defaultDrift;
- protected:
- // Dummy name for object path
- // This is just to satisfy the constructor. Does not have
- // a need to check if the objects paths have been created.
- static constexpr auto TEST_PATH = "/test/path";
+ protected:
+ // Dummy name for object path
+ // This is just to satisfy the constructor. Does not have
+ // a need to check if the objects paths have been created.
+ static constexpr auto TEST_PATH = "/test/path";
- // Returns how long it took for the current watchdog timer to be
- // disabled or have its timeRemaining reset.
- seconds waitForWatchdog(seconds timeLimit);
+ // Returns how long it took for the current watchdog timer to be
+ // disabled or have its timeRemaining reset.
+ seconds waitForWatchdog(seconds timeLimit);
};