add .clang-format
Change-Id: I6627b5569c2e0f730be7331403218b823a2c622f
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/test/controller_mock.hpp b/test/controller_mock.hpp
index 241e83a..38d0446 100644
--- a/test/controller_mock.hpp
+++ b/test/controller_mock.hpp
@@ -1,18 +1,20 @@
#pragma once
-#include <gmock/gmock.h>
-
#include "pid/controller.hpp"
+#include <gmock/gmock.h>
+
class ControllerMock : public PIDController
{
- public:
- virtual ~ControllerMock() = default;
+ public:
+ virtual ~ControllerMock() = default;
- ControllerMock(const std::string& id, PIDZone* owner)
- : PIDController(id, owner) {}
+ ControllerMock(const std::string& id, PIDZone* owner) :
+ PIDController(id, owner)
+ {
+ }
- MOCK_METHOD0(input_proc, float());
- MOCK_METHOD0(setpt_proc, float());
- MOCK_METHOD1(output_proc, void(float));
+ MOCK_METHOD0(input_proc, float());
+ MOCK_METHOD0(setpt_proc, float());
+ MOCK_METHOD1(output_proc, void(float));
};
diff --git a/test/dbus_active_unittest.cpp b/test/dbus_active_unittest.cpp
index c83e9ce..5a7bcfe 100644
--- a/test/dbus_active_unittest.cpp
+++ b/test/dbus_active_unittest.cpp
@@ -1,17 +1,18 @@
#include "dbus/dbusactiveread.hpp"
+#include "test/dbushelper_mock.hpp"
-#include <gmock/gmock.h>
-#include <gtest/gtest.h>
#include <sdbusplus/test/sdbus_mock.hpp>
#include <string>
-#include "test/dbushelper_mock.hpp"
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+using ::testing::_;
using ::testing::Invoke;
using ::testing::NotNull;
-using ::testing::_;
-TEST(DbusActiveReadTest, BoringConstructorTest) {
+TEST(DbusActiveReadTest, BoringConstructorTest)
+{
// Verify we can construct it.
sdbusplus::SdBusMock sdbus_mock;
@@ -23,7 +24,8 @@
DbusActiveRead ar(bus_mock, path, service, &helper);
}
-TEST(DbusActiveReadTest, Read_VerifyCallsToDbusForValue) {
+TEST(DbusActiveReadTest, Read_VerifyCallsToDbusForValue)
+{
// Verify it calls to get the value from dbus when requested.
sdbusplus::SdBusMock sdbus_mock;
@@ -35,14 +37,13 @@
DbusActiveRead ar(bus_mock, path, service, &helper);
EXPECT_CALL(helper, GetProperties(_, service, path, NotNull()))
- .WillOnce(Invoke([&](sdbusplus::bus::bus& bus,
- const std::string& service,
- const std::string& path,
- struct SensorProperties* prop) {
- prop->scale = -3;
- prop->value = 10000;
- prop->unit = "x";
- }));
+ .WillOnce(
+ Invoke([&](sdbusplus::bus::bus& bus, const std::string& service,
+ const std::string& path, struct SensorProperties* prop) {
+ prop->scale = -3;
+ prop->value = 10000;
+ prop->unit = "x";
+ }));
ReadReturn r = ar.read();
EXPECT_EQ(10, r.value);
diff --git a/test/dbus_passive_unittest.cpp b/test/dbus_passive_unittest.cpp
index e84de89..6b8cc8e 100644
--- a/test/dbus_passive_unittest.cpp
+++ b/test/dbus_passive_unittest.cpp
@@ -1,23 +1,24 @@
#include "dbus/dbuspassive.hpp"
+#include "test/dbushelper_mock.hpp"
-#include <gmock/gmock.h>
-#include <gtest/gtest.h>
#include <sdbusplus/test/sdbus_mock.hpp>
#include <string>
-#include "test/dbushelper_mock.hpp"
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+using ::testing::_;
using ::testing::InSequence;
using ::testing::Invoke;
using ::testing::IsNull;
using ::testing::NotNull;
using ::testing::Return;
using ::testing::StrEq;
-using ::testing::_;
std::string SensorIntf = "xyz.openbmc_project.Sensor.Value";
-TEST(DbusPassiveTest, FactoryFailsWithInvalidType) {
+TEST(DbusPassiveTest, FactoryFailsWithInvalidType)
+{
// Verify the type is checked by the factory.
sdbusplus::SdBusMock sdbus_mock;
@@ -33,7 +34,8 @@
EXPECT_EQ(ri, nullptr);
}
-TEST(DbusPassiveTest, BoringConstructorTest) {
+TEST(DbusPassiveTest, BoringConstructorTest)
+{
// Just build the object, which should be avoided as this does no error
// checking at present.
@@ -47,61 +49,59 @@
EXPECT_CALL(helper, GetService(_, StrEq(SensorIntf), StrEq(path)))
.WillOnce(Return("asdf"));
- EXPECT_CALL(helper, GetProperties(_, StrEq("asdf"), StrEq(path),
- NotNull()))
- .WillOnce(Invoke([&](sdbusplus::bus::bus& bus,
- const std::string& service,
- const std::string& path,
- struct SensorProperties* prop) {
- prop->scale = -3;
- prop->value = 10;
- prop->unit = "x";
- }));
+ EXPECT_CALL(helper, GetProperties(_, StrEq("asdf"), StrEq(path), NotNull()))
+ .WillOnce(
+ Invoke([&](sdbusplus::bus::bus &bus, const std::string &service,
+ const std::string &path, struct SensorProperties *prop) {
+ prop->scale = -3;
+ prop->value = 10;
+ prop->unit = "x";
+ }));
DbusPassive(bus_mock, type, id, &helper);
// Success
}
-class DbusPassiveTestObj : public ::testing::Test {
- protected:
- DbusPassiveTestObj()
- : sdbus_mock(),
- bus_mock(std::move(sdbusplus::get_mocked_new(&sdbus_mock))),
- helper()
- {
- EXPECT_CALL(helper, GetService(_, StrEq(SensorIntf), StrEq(path)))
- .WillOnce(Return("asdf"));
+class DbusPassiveTestObj : public ::testing::Test
+{
+ protected:
+ DbusPassiveTestObj() :
+ sdbus_mock(),
+ bus_mock(std::move(sdbusplus::get_mocked_new(&sdbus_mock))), helper()
+ {
+ EXPECT_CALL(helper, GetService(_, StrEq(SensorIntf), StrEq(path)))
+ .WillOnce(Return("asdf"));
- EXPECT_CALL(helper, GetProperties(_, StrEq("asdf"), StrEq(path),
- NotNull()))
- .WillOnce(Invoke([&](sdbusplus::bus::bus& bus,
- const std::string& service,
- const std::string& path,
- struct SensorProperties* prop) {
+ EXPECT_CALL(helper,
+ GetProperties(_, StrEq("asdf"), StrEq(path), NotNull()))
+ .WillOnce(Invoke(
+ [&](sdbusplus::bus::bus &bus, const std::string &service,
+ const std::string &path, struct SensorProperties *prop) {
prop->scale = _scale;
prop->value = _value;
prop->unit = "x";
}));
- ri = DbusPassive::CreateDbusPassive(bus_mock, type, id, &helper);
- passive = reinterpret_cast<DbusPassive*>(ri.get());
- EXPECT_FALSE(passive == nullptr);
- }
+ ri = DbusPassive::CreateDbusPassive(bus_mock, type, id, &helper);
+ passive = reinterpret_cast<DbusPassive *>(ri.get());
+ EXPECT_FALSE(passive == nullptr);
+ }
- sdbusplus::SdBusMock sdbus_mock;
- sdbusplus::bus::bus bus_mock;
- DbusHelperMock helper;
- std::string type = "temp";
- std::string id = "id";
- std::string path = "/xyz/openbmc_project/sensors/temperature/id";
- int64_t _scale = -3;
- int64_t _value = 10;
+ sdbusplus::SdBusMock sdbus_mock;
+ sdbusplus::bus::bus bus_mock;
+ DbusHelperMock helper;
+ std::string type = "temp";
+ std::string id = "id";
+ std::string path = "/xyz/openbmc_project/sensors/temperature/id";
+ int64_t _scale = -3;
+ int64_t _value = 10;
- std::unique_ptr<ReadInterface> ri;
- DbusPassive *passive;
+ std::unique_ptr<ReadInterface> ri;
+ DbusPassive *passive;
};
-TEST_F(DbusPassiveTestObj, ReadReturnsExpectedValues) {
+TEST_F(DbusPassiveTestObj, ReadReturnsExpectedValues)
+{
// Verify read is returning the values.
ReadReturn v;
v.value = 0.01;
@@ -111,7 +111,8 @@
EXPECT_EQ(v.value, r.value);
}
-TEST_F(DbusPassiveTestObj, SetValueUpdatesValue) {
+TEST_F(DbusPassiveTestObj, SetValueUpdatesValue)
+{
// Verify setvalue does as advertised.
double value = 0.01;
@@ -122,17 +123,20 @@
EXPECT_EQ(value, r.value);
}
-TEST_F(DbusPassiveTestObj, GetScaleReturnsExpectedValue) {
+TEST_F(DbusPassiveTestObj, GetScaleReturnsExpectedValue)
+{
// Verify the scale is returned as expected.
EXPECT_EQ(_scale, passive->getScale());
}
-TEST_F(DbusPassiveTestObj, GetIdReturnsExpectedValue) {
+TEST_F(DbusPassiveTestObj, GetIdReturnsExpectedValue)
+{
// Verify getId returns the expected value.
EXPECT_EQ(id, passive->getId());
}
-TEST_F(DbusPassiveTestObj, VerifyHandlesDbusSignal) {
+TEST_F(DbusPassiveTestObj, VerifyHandlesDbusSignal)
+{
// The dbus passive sensor listens for updates and if it's the Value
// property, it needs to handle it.
@@ -146,8 +150,7 @@
// string, std::map<std::string, sdbusplus::message::variant<int64_t>>
// msg.read(msgSensor, msgData);
- EXPECT_CALL(sdbus_mock,
- sd_bus_message_read_basic(IsNull(), 's', NotNull()))
+ EXPECT_CALL(sdbus_mock, sd_bus_message_read_basic(IsNull(), 's', NotNull()))
.WillOnce(Invoke([&](sd_bus_message *m, char type, void *p) {
const char **s = static_cast<const char **>(p);
// Read the first parameter, the string.
@@ -169,7 +172,7 @@
// while !at_end()
EXPECT_CALL(sdbus_mock, sd_bus_message_at_end(IsNull(), 0))
.WillOnce(Return(0))
- .WillOnce(Return(1)); // So it exits the loop after reading one pair.
+ .WillOnce(Return(1)); // So it exits the loop after reading one pair.
// std::pair
EXPECT_CALL(sdbus_mock,
@@ -183,8 +186,7 @@
sd_bus_message_enter_container(IsNull(), 'v', StrEq("x")))
.WillOnce(Return(0));
- EXPECT_CALL(sdbus_mock,
- sd_bus_message_read_basic(IsNull(), 'x', NotNull()))
+ EXPECT_CALL(sdbus_mock, sd_bus_message_read_basic(IsNull(), 'x', NotNull()))
.WillOnce(Invoke([&](sd_bus_message *m, char type, void *p) {
int64_t *s = static_cast<int64_t *>(p);
*s = xValue;
@@ -203,7 +205,8 @@
EXPECT_EQ(10, r.value);
}
-TEST_F(DbusPassiveTestObj, VerifyIgnoresOtherPropertySignal) {
+TEST_F(DbusPassiveTestObj, VerifyIgnoresOtherPropertySignal)
+{
// The dbus passive sensor listens for updates and if it's the Value
// property, it needs to handle it. In this case, it won't be.
@@ -217,8 +220,7 @@
// string, std::map<std::string, sdbusplus::message::variant<int64_t>>
// msg.read(msgSensor, msgData);
- EXPECT_CALL(sdbus_mock,
- sd_bus_message_read_basic(IsNull(), 's', NotNull()))
+ EXPECT_CALL(sdbus_mock, sd_bus_message_read_basic(IsNull(), 's', NotNull()))
.WillOnce(Invoke([&](sd_bus_message *m, char type, void *p) {
const char **s = static_cast<const char **>(p);
// Read the first parameter, the string.
@@ -240,7 +242,7 @@
// while !at_end()
EXPECT_CALL(sdbus_mock, sd_bus_message_at_end(IsNull(), 0))
.WillOnce(Return(0))
- .WillOnce(Return(1)); // So it exits the loop after reading one pair.
+ .WillOnce(Return(1)); // So it exits the loop after reading one pair.
// std::pair
EXPECT_CALL(sdbus_mock,
@@ -254,8 +256,7 @@
sd_bus_message_enter_container(IsNull(), 'v', StrEq("x")))
.WillOnce(Return(0));
- EXPECT_CALL(sdbus_mock,
- sd_bus_message_read_basic(IsNull(), 'x', NotNull()))
+ EXPECT_CALL(sdbus_mock, sd_bus_message_read_basic(IsNull(), 'x', NotNull()))
.WillOnce(Invoke([&](sd_bus_message *m, char type, void *p) {
int64_t *s = static_cast<int64_t *>(p);
*s = xScale;
diff --git a/test/dbushelper_mock.hpp b/test/dbushelper_mock.hpp
index 23dd81c..6d3464e 100644
--- a/test/dbushelper_mock.hpp
+++ b/test/dbushelper_mock.hpp
@@ -1,21 +1,21 @@
#pragma once
-#include <gmock/gmock.h>
+#include "dbus/util.hpp"
+
#include <sdbusplus/bus.hpp>
#include <string>
-#include "dbus/util.hpp"
+#include <gmock/gmock.h>
class DbusHelperMock : public DbusHelperInterface
{
- public:
- virtual ~DbusHelperMock() = default;
+ public:
+ virtual ~DbusHelperMock() = default;
- MOCK_METHOD3(GetService, std::string(sdbusplus::bus::bus&,
- const std::string&,
- const std::string&));
- MOCK_METHOD4(GetProperties, void(sdbusplus::bus::bus&,
- const std::string&,
- const std::string&,
- struct SensorProperties*));
+ MOCK_METHOD3(GetService,
+ std::string(sdbusplus::bus::bus&, const std::string&,
+ const std::string&));
+ MOCK_METHOD4(GetProperties,
+ void(sdbusplus::bus::bus&, const std::string&,
+ const std::string&, struct SensorProperties*));
};
diff --git a/test/helpers.hpp b/test/helpers.hpp
index 74c969f..a06eb2e 100644
--- a/test/helpers.hpp
+++ b/test/helpers.hpp
@@ -1,18 +1,19 @@
// THIS EXISTS AS A COPY OF SDBUSPLUS/TEST/HELPERS.HPP until that is merged.
#pragma once
-#include <gmock/gmock.h>
-#include <gtest/gtest.h>
#include <sdbusplus/test/sdbus_mock.hpp>
#include <string>
#include <vector>
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+
+using ::testing::_;
using ::testing::Invoke;
using ::testing::IsNull;
using ::testing::NotNull;
using ::testing::Return;
using ::testing::StrEq;
-using ::testing::_;
/** @brief Setup the expectations for sdbus-based object creation.
*
diff --git a/test/pid_fancontroller_unittest.cpp b/test/pid_fancontroller_unittest.cpp
index b127929..c7b7bc7 100644
--- a/test/pid_fancontroller_unittest.cpp
+++ b/test/pid_fancontroller_unittest.cpp
@@ -1,21 +1,22 @@
-#include "pid/fancontroller.hpp"
-
-#include <gmock/gmock.h>
-#include <gtest/gtest.h>
-#include <string>
-#include <vector>
-
#include "pid/ec/pid.hpp"
+#include "pid/fancontroller.hpp"
#include "test/sensor_mock.hpp"
#include "test/zone_mock.hpp"
+#include <string>
+#include <vector>
+
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+
+using ::testing::_;
using ::testing::DoubleEq;
using ::testing::Invoke;
using ::testing::Return;
using ::testing::StrEq;
-using ::testing::_;
-TEST(FanControllerTest, BoringFactoryTest) {
+TEST(FanControllerTest, BoringFactoryTest)
+{
// Verify the factory will properly build the FanPIDController in the
// boring (uninteresting) case.
ZoneMock z;
@@ -29,7 +30,8 @@
EXPECT_FALSE(p == nullptr);
}
-TEST(FanControllerTest, VerifyFactoryFailsWithZeroInputs) {
+TEST(FanControllerTest, VerifyFactoryFailsWithZeroInputs)
+{
// A fan controller needs at least one input.
ZoneMock z;
@@ -42,7 +44,8 @@
EXPECT_TRUE(p == nullptr);
}
-TEST(FanControllerTest, InputProc_AllSensorsReturnZero) {
+TEST(FanControllerTest, InputProc_AllSensorsReturnZero)
+{
// If all your inputs are 0, return 0.
ZoneMock z;
@@ -60,7 +63,8 @@
EXPECT_EQ(0.0, p->input_proc());
}
-TEST(FanControllerTest, InputProc_IfSensorNegativeIsIgnored) {
+TEST(FanControllerTest, InputProc_IfSensorNegativeIsIgnored)
+{
// A sensor value returning sub-zero is ignored as an error.
ZoneMock z;
@@ -77,7 +81,8 @@
EXPECT_EQ(0.0, p->input_proc());
}
-TEST(FanControllerTest, InputProc_ChoosesMinimumValue) {
+TEST(FanControllerTest, InputProc_ChoosesMinimumValue)
+{
// Verify it selects the minimum value from its inputs.
ZoneMock z;
@@ -97,7 +102,8 @@
}
// The direction is unused presently, but these tests validate the logic.
-TEST(FanControllerTest, SetPtProc_SpeedChanges_VerifyDirection) {
+TEST(FanControllerTest, SetPtProc_SpeedChanges_VerifyDirection)
+{
// The fan direction defaults to neutral, because we have no data. Verify
// that after this point it appropriately will indicate speeding up or
// slowing down based on the RPM values specified.
@@ -111,7 +117,7 @@
FanController::CreateFanPid(&z, "fan1", inputs, initial);
EXPECT_FALSE(p == nullptr);
// Grab pointer for mocking.
- FanController *fp = reinterpret_cast<FanController*>(p.get());
+ FanController *fp = reinterpret_cast<FanController *>(p.get());
// Fanspeed starts are Neutral.
EXPECT_EQ(FanSpeedDirection::NEUTRAL, fp->getFanDirection());
@@ -135,7 +141,8 @@
EXPECT_EQ(FanSpeedDirection::NEUTRAL, fp->getFanDirection());
}
-TEST(FanControllerTest, OutputProc_VerifiesIfFailsafeEnabledInputIsIgnored) {
+TEST(FanControllerTest, OutputProc_VerifiesIfFailsafeEnabledInputIsIgnored)
+{
// Verify that if failsafe mode is enabled and the input value for the fans
// is below the failsafe minimum value, the input is not used and the fans
// are driven at failsafe RPM.
@@ -156,8 +163,8 @@
std::unique_ptr<Sensor> s1 = std::make_unique<SensorMock>("fan0", timeout);
std::unique_ptr<Sensor> s2 = std::make_unique<SensorMock>("fan1", timeout);
// Grab pointers for mocking.
- SensorMock *sm1 = reinterpret_cast<SensorMock*>(s1.get());
- SensorMock *sm2 = reinterpret_cast<SensorMock*>(s2.get());
+ SensorMock *sm1 = reinterpret_cast<SensorMock *>(s1.get());
+ SensorMock *sm2 = reinterpret_cast<SensorMock *>(s2.get());
EXPECT_CALL(z, getSensor(StrEq("fan0"))).WillOnce(Return(s1.get()));
EXPECT_CALL(*sm1, write(0.75));
@@ -167,11 +174,13 @@
// This is a fan PID, so calling output_proc will try to write this value
// to the sensors.
- // Setting 50%, will end up being 75% because the sensors are in failsafe mode.
+ // Setting 50%, will end up being 75% because the sensors are in failsafe
+ // mode.
p->output_proc(50.0);
}
-TEST(FanControllerTest, OutputProc_BehavesAsExpected) {
+TEST(FanControllerTest, OutputProc_BehavesAsExpected)
+{
// Verifies that when the system is not in failsafe mode, the input value
// to output_proc is used to drive the sensors (fans).
@@ -190,8 +199,8 @@
std::unique_ptr<Sensor> s1 = std::make_unique<SensorMock>("fan0", timeout);
std::unique_ptr<Sensor> s2 = std::make_unique<SensorMock>("fan1", timeout);
// Grab pointers for mocking.
- SensorMock *sm1 = reinterpret_cast<SensorMock*>(s1.get());
- SensorMock *sm2 = reinterpret_cast<SensorMock*>(s2.get());
+ SensorMock *sm1 = reinterpret_cast<SensorMock *>(s1.get());
+ SensorMock *sm2 = reinterpret_cast<SensorMock *>(s2.get());
EXPECT_CALL(z, getSensor(StrEq("fan0"))).WillOnce(Return(s1.get()));
EXPECT_CALL(*sm1, write(0.5));
@@ -203,7 +212,8 @@
p->output_proc(50.0);
}
-TEST(FanControllerTest, OutputProc_VerifyFailSafeIgnoredIfInputHigher) {
+TEST(FanControllerTest, OutputProc_VerifyFailSafeIgnoredIfInputHigher)
+{
// If the requested output is higher than the failsafe value, then use the
// value provided to output_proc.
@@ -222,7 +232,7 @@
int64_t timeout = 0;
std::unique_ptr<Sensor> s1 = std::make_unique<SensorMock>("fan0", timeout);
// Grab pointer for mocking.
- SensorMock *sm1 = reinterpret_cast<SensorMock*>(s1.get());
+ SensorMock *sm1 = reinterpret_cast<SensorMock *>(s1.get());
// Converting from float to double for expectation.
float percent = 80;
diff --git a/test/pid_thermalcontroller_unittest.cpp b/test/pid_thermalcontroller_unittest.cpp
index b0de1a9..386c779 100644
--- a/test/pid_thermalcontroller_unittest.cpp
+++ b/test/pid_thermalcontroller_unittest.cpp
@@ -1,17 +1,18 @@
+#include "pid/ec/pid.hpp"
#include "pid/thermalcontroller.hpp"
+#include "test/zone_mock.hpp"
-#include <gmock/gmock.h>
-#include <gtest/gtest.h>
#include <string>
#include <vector>
-#include "pid/ec/pid.hpp"
-#include "test/zone_mock.hpp"
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
using ::testing::Return;
using ::testing::StrEq;
-TEST(ThermalControllerTest, BoringFactoryTest) {
+TEST(ThermalControllerTest, BoringFactoryTest)
+{
// Verifies building a ThermalPIDController with the factory works as
// expected in the boring (uninteresting) case.
@@ -21,14 +22,14 @@
float setpoint = 10.0;
ec::pidinfo initial;
- std::unique_ptr<PIDController> p =
- ThermalController::CreateThermalPid(&z, "therm1", inputs, setpoint,
- initial);
+ std::unique_ptr<PIDController> p = ThermalController::CreateThermalPid(
+ &z, "therm1", inputs, setpoint, initial);
// Success
EXPECT_FALSE(p == nullptr);
}
-TEST(ThermalControllerTest, VerifyFactoryFailsWithZeroInputs) {
+TEST(ThermalControllerTest, VerifyFactoryFailsWithZeroInputs)
+{
// A thermal controller needs at least one input.
ZoneMock z;
@@ -37,13 +38,13 @@
float setpoint = 10.0;
ec::pidinfo initial;
- std::unique_ptr<PIDController> p =
- ThermalController::CreateThermalPid(&z, "therm1", inputs, setpoint,
- initial);
+ std::unique_ptr<PIDController> p = ThermalController::CreateThermalPid(
+ &z, "therm1", inputs, setpoint, initial);
EXPECT_TRUE(p == nullptr);
}
-TEST(ThermalControllerTest, VerifyFactoryFailsForMoreThanOneInput) {
+TEST(ThermalControllerTest, VerifyFactoryFailsForMoreThanOneInput)
+{
// ThermalControllers currently only support one input, so don't let
// someone accidentally specify more.
@@ -53,13 +54,13 @@
float setpoint = 10.0;
ec::pidinfo initial;
- std::unique_ptr<PIDController> p =
- ThermalController::CreateThermalPid(&z, "therm1", inputs, setpoint,
- initial);
+ std::unique_ptr<PIDController> p = ThermalController::CreateThermalPid(
+ &z, "therm1", inputs, setpoint, initial);
EXPECT_TRUE(p == nullptr);
}
-TEST(ThermalControllerTest, InputProc_BehavesAsExpected) {
+TEST(ThermalControllerTest, InputProc_BehavesAsExpected)
+{
// This test just verifies input_proc behaves as expected.
ZoneMock z;
@@ -68,9 +69,8 @@
float setpoint = 10.0;
ec::pidinfo initial;
- std::unique_ptr<PIDController> p =
- ThermalController::CreateThermalPid(&z, "therm1", inputs, setpoint,
- initial);
+ std::unique_ptr<PIDController> p = ThermalController::CreateThermalPid(
+ &z, "therm1", inputs, setpoint, initial);
EXPECT_FALSE(p == nullptr);
EXPECT_CALL(z, getCachedValue(StrEq("fleeting0"))).WillOnce(Return(5.0));
@@ -78,7 +78,8 @@
EXPECT_EQ(5.0, p->input_proc());
}
-TEST(ThermalControllerTest, SetPtProc_BehavesAsExpected) {
+TEST(ThermalControllerTest, SetPtProc_BehavesAsExpected)
+{
// This test just verifies input_proc behaves as expected.
ZoneMock z;
@@ -87,15 +88,15 @@
float setpoint = 10.0;
ec::pidinfo initial;
- std::unique_ptr<PIDController> p =
- ThermalController::CreateThermalPid(&z, "therm1", inputs, setpoint,
- initial);
+ std::unique_ptr<PIDController> p = ThermalController::CreateThermalPid(
+ &z, "therm1", inputs, setpoint, initial);
EXPECT_FALSE(p == nullptr);
EXPECT_EQ(setpoint, p->setpt_proc());
}
-TEST(ThermalControllerTest, OutputProc_BehavesAsExpected) {
+TEST(ThermalControllerTest, OutputProc_BehavesAsExpected)
+{
// This test just verifies input_proc behaves as expected.
ZoneMock z;
@@ -104,9 +105,8 @@
float setpoint = 10.0;
ec::pidinfo initial;
- std::unique_ptr<PIDController> p =
- ThermalController::CreateThermalPid(&z, "therm1", inputs, setpoint,
- initial);
+ std::unique_ptr<PIDController> p = ThermalController::CreateThermalPid(
+ &z, "therm1", inputs, setpoint, initial);
EXPECT_FALSE(p == nullptr);
float value = 90.0;
diff --git a/test/pid_zone_unittest.cpp b/test/pid_zone_unittest.cpp
index c511b3c..a8e03a0 100644
--- a/test/pid_zone_unittest.cpp
+++ b/test/pid_zone_unittest.cpp
@@ -1,28 +1,30 @@
+#include "pid/ec/pid.hpp"
#include "pid/zone.hpp"
+#include "sensors/manager.hpp"
+#include "test/controller_mock.hpp"
+#include "test/helpers.hpp"
+#include "test/sensor_mock.hpp"
#include <chrono>
#include <cstring>
-#include <gmock/gmock.h>
-#include <gtest/gtest.h>
#include <sdbusplus/test/sdbus_mock.hpp>
#include <vector>
-#include "pid/ec/pid.hpp"
-#include "sensors/manager.hpp"
-#include "test/controller_mock.hpp"
-#include "test/sensor_mock.hpp"
-#include "test/helpers.hpp"
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+using ::testing::_;
using ::testing::IsNull;
using ::testing::Return;
using ::testing::StrEq;
-using ::testing::_;
static std::string modeInterface = "xyz.openbmc_project.Control.Mode";
-namespace {
+namespace
+{
-TEST(PidZoneConstructorTest, BoringConstructorTest) {
+TEST(PidZoneConstructorTest, BoringConstructorTest)
+{
// Build a PID Zone.
sdbusplus::SdBusMock sdbus_mock_passive, sdbus_mock_host, sdbus_mock_mode;
@@ -32,13 +34,10 @@
EXPECT_CALL(sdbus_mock_host,
sd_bus_add_object_manager(
- IsNull(),
- _,
- StrEq("/xyz/openbmc_project/extsensors")))
+ IsNull(), _, StrEq("/xyz/openbmc_project/extsensors")))
.WillOnce(Return(0));
- SensorManager m(std::move(bus_mock_passive),
- std::move(bus_mock_host));
+ SensorManager m(std::move(bus_mock_passive), std::move(bus_mock_host));
bool defer = true;
const char *objPath = "/path/";
@@ -48,74 +47,69 @@
int i;
std::vector<std::string> properties;
- SetupDbusObject(&sdbus_mock_mode, defer, objPath, modeInterface,
- properties, &i);
+ SetupDbusObject(&sdbus_mock_mode, defer, objPath, modeInterface, properties,
+ &i);
PIDZone p(zone, minThermalRpm, failSafePercent, m, bus_mock_mode, objPath,
defer);
// Success.
}
-}
+} // namespace
-class PidZoneTest : public ::testing::Test {
- protected:
- PidZoneTest()
- : property_index(),
- properties(),
- sdbus_mock_passive(),
- sdbus_mock_host(),
- sdbus_mock_mode()
- {
- EXPECT_CALL(sdbus_mock_host,
- sd_bus_add_object_manager(
- IsNull(),
- _,
- StrEq("/xyz/openbmc_project/extsensors")))
- .WillOnce(Return(0));
+class PidZoneTest : public ::testing::Test
+{
+ protected:
+ PidZoneTest() :
+ property_index(), properties(), sdbus_mock_passive(), sdbus_mock_host(),
+ sdbus_mock_mode()
+ {
+ EXPECT_CALL(sdbus_mock_host,
+ sd_bus_add_object_manager(
+ IsNull(), _, StrEq("/xyz/openbmc_project/extsensors")))
+ .WillOnce(Return(0));
- auto bus_mock_passive =
- sdbusplus::get_mocked_new(&sdbus_mock_passive);
- auto bus_mock_host = sdbusplus::get_mocked_new(&sdbus_mock_host);
- auto bus_mock_mode = sdbusplus::get_mocked_new(&sdbus_mock_mode);
+ auto bus_mock_passive = sdbusplus::get_mocked_new(&sdbus_mock_passive);
+ auto bus_mock_host = sdbusplus::get_mocked_new(&sdbus_mock_host);
+ auto bus_mock_mode = sdbusplus::get_mocked_new(&sdbus_mock_mode);
- // Compiler weirdly not happy about just instantiating mgr(...);
- SensorManager m(std::move(bus_mock_passive),
- std::move(bus_mock_host));
- mgr = std::move(m);
+ // Compiler weirdly not happy about just instantiating mgr(...);
+ SensorManager m(std::move(bus_mock_passive), std::move(bus_mock_host));
+ mgr = std::move(m);
- SetupDbusObject(&sdbus_mock_mode, defer, objPath, modeInterface,
- properties, &property_index);
+ SetupDbusObject(&sdbus_mock_mode, defer, objPath, modeInterface,
+ properties, &property_index);
- zone = std::make_unique<PIDZone>(zoneId, minThermalRpm,
- failSafePercent, mgr,
- bus_mock_mode, objPath, defer);
- }
+ zone = std::make_unique<PIDZone>(zoneId, minThermalRpm, failSafePercent,
+ mgr, bus_mock_mode, objPath, defer);
+ }
- // unused
- int property_index;
- std::vector<std::string> properties;
+ // unused
+ int property_index;
+ std::vector<std::string> properties;
- sdbusplus::SdBusMock sdbus_mock_passive;
- sdbusplus::SdBusMock sdbus_mock_host;
- sdbusplus::SdBusMock sdbus_mock_mode;
- int64_t zoneId = 1;
- float minThermalRpm = 1000.0;
- float failSafePercent = 0.75;
- bool defer = true;
- const char *objPath = "/path/";
- SensorManager mgr;
+ sdbusplus::SdBusMock sdbus_mock_passive;
+ sdbusplus::SdBusMock sdbus_mock_host;
+ sdbusplus::SdBusMock sdbus_mock_mode;
+ int64_t zoneId = 1;
+ float minThermalRpm = 1000.0;
+ float failSafePercent = 0.75;
+ bool defer = true;
+ const char *objPath = "/path/";
+ SensorManager mgr;
- std::unique_ptr<PIDZone> zone;
+ std::unique_ptr<PIDZone> zone;
};
-TEST_F(PidZoneTest, GetZoneId_ReturnsExpected) {
+TEST_F(PidZoneTest, GetZoneId_ReturnsExpected)
+{
// Verifies the zoneId returned is what we expect.
EXPECT_EQ(zoneId, zone->getZoneId());
}
-TEST_F(PidZoneTest, GetAndSetManualModeTest_BehavesAsExpected) {
+TEST_F(PidZoneTest, GetAndSetManualModeTest_BehavesAsExpected)
+{
// Verifies that the zone starts in manual mode. Verifies that one can set
// the mode.
EXPECT_FALSE(zone->getManualMode());
@@ -124,7 +118,8 @@
EXPECT_TRUE(zone->getManualMode());
}
-TEST_F(PidZoneTest, RpmSetPoints_AddMaxClear_BehaveAsExpected) {
+TEST_F(PidZoneTest, RpmSetPoints_AddMaxClear_BehaveAsExpected)
+{
// Tests addRPMSetPoint, clearRPMSetPoints, determineMaxRPMRequest
// and getMinThermalRpmSetPt.
@@ -148,7 +143,8 @@
EXPECT_EQ(zone->getMinThermalRpmSetPt(), zone->getMaxRPMRequest());
}
-TEST_F(PidZoneTest, RpmSetPoints_AddBelowMinimum_BehavesAsExpected) {
+TEST_F(PidZoneTest, RpmSetPoints_AddBelowMinimum_BehavesAsExpected)
+{
// Tests adding several RPM setpoints, however, they're all lower than the
// configured minimal thermal set-point RPM value.
@@ -165,12 +161,14 @@
EXPECT_EQ(zone->getMinThermalRpmSetPt(), zone->getMaxRPMRequest());
}
-TEST_F(PidZoneTest, GetFailSafePercent_ReturnsExpected) {
+TEST_F(PidZoneTest, GetFailSafePercent_ReturnsExpected)
+{
// Verify the value used to create the object is stored.
EXPECT_EQ(failSafePercent, zone->getFailSafePercent());
}
-TEST_F(PidZoneTest, ThermalInputs_FailsafeToValid_ReadsSensors) {
+TEST_F(PidZoneTest, ThermalInputs_FailsafeToValid_ReadsSensors)
+{
// This test will add a couple thermal inputs, and verify that the zone
// initializes into failsafe mode, and will read each sensor.
@@ -179,12 +177,12 @@
std::unique_ptr<Sensor> sensor1 =
std::make_unique<SensorMock>(name1, timeout);
- SensorMock *sensor_ptr1 = reinterpret_cast<SensorMock*>(sensor1.get());
+ SensorMock *sensor_ptr1 = reinterpret_cast<SensorMock *>(sensor1.get());
std::string name2 = "temp2";
std::unique_ptr<Sensor> sensor2 =
std::make_unique<SensorMock>(name2, timeout);
- SensorMock *sensor_ptr2 = reinterpret_cast<SensorMock*>(sensor2.get());
+ SensorMock *sensor_ptr2 = reinterpret_cast<SensorMock *>(sensor2.get());
std::string type = "unchecked";
mgr.addSensor(type, name1, std::move(sensor1));
@@ -222,7 +220,8 @@
EXPECT_EQ(r2.value, zone->getCachedValue(name2));
}
-TEST_F(PidZoneTest, FanInputTest_VerifiesFanValuesCached) {
+TEST_F(PidZoneTest, FanInputTest_VerifiesFanValuesCached)
+{
// This will add a couple fan inputs, and verify the values are cached.
std::string name1 = "fan1";
@@ -230,12 +229,12 @@
std::unique_ptr<Sensor> sensor1 =
std::make_unique<SensorMock>(name1, timeout);
- SensorMock *sensor_ptr1 = reinterpret_cast<SensorMock*>(sensor1.get());
+ SensorMock *sensor_ptr1 = reinterpret_cast<SensorMock *>(sensor1.get());
std::string name2 = "fan2";
std::unique_ptr<Sensor> sensor2 =
std::make_unique<SensorMock>(name2, timeout);
- SensorMock *sensor_ptr2 = reinterpret_cast<SensorMock*>(sensor2.get());
+ SensorMock *sensor_ptr2 = reinterpret_cast<SensorMock *>(sensor2.get());
std::string type = "unchecked";
mgr.addSensor(type, name1, std::move(sensor1));
@@ -268,7 +267,8 @@
EXPECT_EQ(r2.value, zone->getCachedValue(name2));
}
-TEST_F(PidZoneTest, ThermalInput_ValueTimeoutEntersFailSafeMode) {
+TEST_F(PidZoneTest, ThermalInput_ValueTimeoutEntersFailSafeMode)
+{
// On the second updateSensors call, the updated timestamp will be beyond
// the timeout limit.
@@ -277,12 +277,12 @@
std::string name1 = "temp1";
std::unique_ptr<Sensor> sensor1 =
std::make_unique<SensorMock>(name1, timeout);
- SensorMock *sensor_ptr1 = reinterpret_cast<SensorMock*>(sensor1.get());
+ SensorMock *sensor_ptr1 = reinterpret_cast<SensorMock *>(sensor1.get());
std::string name2 = "temp2";
std::unique_ptr<Sensor> sensor2 =
std::make_unique<SensorMock>(name2, timeout);
- SensorMock *sensor_ptr2 = reinterpret_cast<SensorMock*>(sensor2.get());
+ SensorMock *sensor_ptr2 = reinterpret_cast<SensorMock *>(sensor2.get());
std::string type = "unchecked";
mgr.addSensor(type, name1, std::move(sensor1));
@@ -327,7 +327,8 @@
EXPECT_TRUE(zone->getFailSafeMode());
}
-TEST_F(PidZoneTest, GetSensorTest_ReturnsExpected) {
+TEST_F(PidZoneTest, GetSensorTest_ReturnsExpected)
+{
// One can grab a sensor from the manager through the zone.
int64_t timeout = 1;
@@ -335,7 +336,7 @@
std::string name1 = "temp1";
std::unique_ptr<Sensor> sensor1 =
std::make_unique<SensorMock>(name1, timeout);
- SensorMock *sensor_ptr1 = reinterpret_cast<SensorMock*>(sensor1.get());
+ SensorMock *sensor_ptr1 = reinterpret_cast<SensorMock *>(sensor1.get());
std::string type = "unchecked";
mgr.addSensor(type, name1, std::move(sensor1));
@@ -347,17 +348,18 @@
EXPECT_EQ(mgr.getSensor(name1), zone->getSensor(name1));
}
-TEST_F(PidZoneTest, AddThermalPIDTest_VerifiesThermalPIDsProcessed) {
+TEST_F(PidZoneTest, AddThermalPIDTest_VerifiesThermalPIDsProcessed)
+{
// Tests adding a thermal PID controller to the zone, and verifies it's
// touched during processing.
std::unique_ptr<PIDController> tpid =
std::make_unique<ControllerMock>("thermal1", zone.get());
- ControllerMock *tmock = reinterpret_cast<ControllerMock*>(tpid.get());
+ ControllerMock *tmock = reinterpret_cast<ControllerMock *>(tpid.get());
// Access the internal pid configuration to clear it out (unrelated to the
// test).
- ec::pid_info_t* info = tpid->get_pid_info();
+ ec::pid_info_t *info = tpid->get_pid_info();
std::memset(info, 0x00, sizeof(ec::pid_info_t));
zone->addThermalPID(std::move(tpid));
@@ -371,17 +373,18 @@
zone->process_thermals();
}
-TEST_F(PidZoneTest, AddFanPIDTest_VerifiesFanPIDsProcessed) {
+TEST_F(PidZoneTest, AddFanPIDTest_VerifiesFanPIDsProcessed)
+{
// Tests adding a fan PID controller to the zone, and verifies it's
// touched during processing.
std::unique_ptr<PIDController> tpid =
std::make_unique<ControllerMock>("fan1", zone.get());
- ControllerMock *tmock = reinterpret_cast<ControllerMock*>(tpid.get());
+ ControllerMock *tmock = reinterpret_cast<ControllerMock *>(tpid.get());
// Access the internal pid configuration to clear it out (unrelated to the
// test).
- ec::pid_info_t* info = tpid->get_pid_info();
+ ec::pid_info_t *info = tpid->get_pid_info();
std::memset(info, 0x00, sizeof(ec::pid_info_t));
zone->addFanPID(std::move(tpid));
@@ -394,15 +397,15 @@
zone->process_fans();
}
-TEST_F(PidZoneTest, ManualModeDbusTest_VerifySetManualBehavesAsExpected) {
+TEST_F(PidZoneTest, ManualModeDbusTest_VerifySetManualBehavesAsExpected)
+{
// The manual(bool) method is inherited from the dbus mode interface.
// Verifies that someone doesn't remove the internal call to the dbus
// object from which we're inheriting.
EXPECT_CALL(sdbus_mock_mode,
- sd_bus_emit_properties_changed_strv(IsNull(), StrEq(objPath),
- StrEq(modeInterface),
- NotNull()))
+ sd_bus_emit_properties_changed_strv(
+ IsNull(), StrEq(objPath), StrEq(modeInterface), NotNull()))
.WillOnce(Invoke([&](sd_bus *bus, const char *path,
const char *interface, char **names) {
EXPECT_STREQ("Manual", names[0]);
@@ -415,7 +418,8 @@
EXPECT_TRUE(zone->getManualMode());
}
-TEST_F(PidZoneTest, FailsafeDbusTest_VerifiesReturnsExpected) {
+TEST_F(PidZoneTest, FailsafeDbusTest_VerifiesReturnsExpected)
+{
// This property is implemented by us as read-only, such that trying to
// write to it will have no effect.
EXPECT_EQ(zone->failSafe(), zone->getFailSafeMode());
diff --git a/test/readinterface_mock.hpp b/test/readinterface_mock.hpp
index b8ab5ac..1d2c82d 100644
--- a/test/readinterface_mock.hpp
+++ b/test/readinterface_mock.hpp
@@ -6,8 +6,8 @@
class ReadInterfaceMock : public ReadInterface
{
- public:
- virtual ~ReadInterfaceMock() = default;
+ public:
+ virtual ~ReadInterfaceMock() = default;
- MOCK_METHOD0(read, ReadReturn());
+ MOCK_METHOD0(read, ReadReturn());
};
diff --git a/test/sensor_host_unittest.cpp b/test/sensor_host_unittest.cpp
index 5e8af4b..99d4924 100644
--- a/test/sensor_host_unittest.cpp
+++ b/test/sensor_host_unittest.cpp
@@ -1,25 +1,27 @@
#include "sensors/host.hpp"
+#include "test/helpers.hpp"
#include <chrono>
-#include <gmock/gmock.h>
-#include <gtest/gtest.h>
#include <memory>
#include <sdbusplus/test/sdbus_mock.hpp>
#include <string>
#include <vector>
-#include "test/helpers.hpp"
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
using ::testing::IsNull;
using ::testing::Return;
using ::testing::StrEq;
-TEST(HostSensorTest, BoringConstructorTest) {
+TEST(HostSensorTest, BoringConstructorTest)
+{
// WARN: The host sensor is not presently meant to be created this way,
// TODO: Can I move the constructor into private?
}
-TEST(HostSensorTest, CreateHostTempSensorTest) {
+TEST(HostSensorTest, CreateHostTempSensorTest)
+{
// The normal case for this sensor is to be a temperature sensor, where
// the value is treated as a margin sensor.
@@ -40,24 +42,19 @@
// The CreateTemp updates all the properties, however, only Scale is set
// to non-default.
- SetupDbusObject(
- &sdbus_mock,
- defer,
- objPath,
- interface,
- properties,
- &i);
+ SetupDbusObject(&sdbus_mock, defer, objPath, interface, properties, &i);
// This is called during object destruction.
EXPECT_CALL(sdbus_mock,
sd_bus_emit_object_removed(IsNull(), StrEq(objPath)))
.WillOnce(Return(0));
- std::unique_ptr<Sensor> s = HostSensor::CreateTemp(
- name, timeout, bus_mock, objPath, defer);
+ std::unique_ptr<Sensor> s =
+ HostSensor::CreateTemp(name, timeout, bus_mock, objPath, defer);
}
-TEST(HostSensorTest, VerifyWriteThenReadMatches) {
+TEST(HostSensorTest, VerifyWriteThenReadMatches)
+{
// Verify that when value is updated, the information matches
// what we expect when read back.
@@ -76,20 +73,14 @@
std::vector<std::string> properties = {"Scale"};
int i;
- SetupDbusObject(
- &sdbus_mock,
- defer,
- objPath,
- interface,
- properties,
- &i);
+ SetupDbusObject(&sdbus_mock, defer, objPath, interface, properties, &i);
EXPECT_CALL(sdbus_mock,
sd_bus_emit_object_removed(IsNull(), StrEq(objPath)))
.WillOnce(Return(0));
- std::unique_ptr<Sensor> s = HostSensor::CreateTemp(
- name, timeout, bus_mock, objPath, defer);
+ std::unique_ptr<Sensor> s =
+ HostSensor::CreateTemp(name, timeout, bus_mock, objPath, defer);
// Value is updated from dbus calls only (normally).
HostSensor *hs = static_cast<HostSensor *>(s.get());
@@ -99,20 +90,13 @@
EXPECT_EQ(r.value, 0);
EXPECT_CALL(sdbus_mock,
- sd_bus_emit_properties_changed_strv(
- IsNull(),
- StrEq(objPath),
- StrEq(interface),
- NotNull()))
- .WillOnce(
- Invoke([=](sd_bus *bus,
- const char *path,
- const char *interface,
- char **names) {
- EXPECT_STREQ("Value", names[0]);
- return 0;
- })
- );
+ sd_bus_emit_properties_changed_strv(
+ IsNull(), StrEq(objPath), StrEq(interface), NotNull()))
+ .WillOnce(Invoke([=](sd_bus *bus, const char *path,
+ const char *interface, char **names) {
+ EXPECT_STREQ("Value", names[0]);
+ return 0;
+ }));
std::chrono::high_resolution_clock::time_point t1 =
std::chrono::high_resolution_clock::now();
@@ -121,8 +105,9 @@
r = hs->read();
EXPECT_EQ(r.value, new_value * 0.001);
- auto duration = std::chrono::duration_cast<std::chrono::seconds>(
- t1 - r.updated).count();
+ auto duration =
+ std::chrono::duration_cast<std::chrono::seconds>(t1 - r.updated)
+ .count();
// Verify it was updated within the last second.
EXPECT_TRUE(duration < 1);
diff --git a/test/sensor_manager_unittest.cpp b/test/sensor_manager_unittest.cpp
index eed26cd..54253ac 100644
--- a/test/sensor_manager_unittest.cpp
+++ b/test/sensor_manager_unittest.cpp
@@ -1,17 +1,18 @@
#include "sensors/manager.hpp"
+#include "test/sensor_mock.hpp"
+
+#include <sdbusplus/test/sdbus_mock.hpp>
#include <gmock/gmock.h>
#include <gtest/gtest.h>
-#include <sdbusplus/test/sdbus_mock.hpp>
-
-#include "test/sensor_mock.hpp"
using ::testing::_;
using ::testing::IsNull;
using ::testing::Return;
using ::testing::StrEq;
-TEST(SensorManagerTest, BoringConstructorTest) {
+TEST(SensorManagerTest, BoringConstructorTest)
+{
// Build a boring SensorManager.
sdbusplus::SdBusMock sdbus_mock_passive, sdbus_mock_host;
@@ -20,16 +21,15 @@
EXPECT_CALL(sdbus_mock_host,
sd_bus_add_object_manager(
- IsNull(),
- _,
- StrEq("/xyz/openbmc_project/extsensors")))
+ IsNull(), _, StrEq("/xyz/openbmc_project/extsensors")))
.WillOnce(Return(0));
SensorManager s(std::move(bus_mock_passive), std::move(bus_mock_host));
// Success
}
-TEST(SensorManagerTest, AddSensorInvalidTypeTest) {
+TEST(SensorManagerTest, AddSensorInvalidTypeTest)
+{
// AddSensor doesn't validate the type of sensor you're adding, because
// ultimately it doesn't care -- but if we decide to change that this
// test will start failing :D
@@ -40,9 +40,7 @@
EXPECT_CALL(sdbus_mock_host,
sd_bus_add_object_manager(
- IsNull(),
- _,
- StrEq("/xyz/openbmc_project/extsensors")))
+ IsNull(), _, StrEq("/xyz/openbmc_project/extsensors")))
.WillOnce(Return(0));
SensorManager s(std::move(bus_mock_passive), std::move(bus_mock_host));
diff --git a/test/sensor_mock.hpp b/test/sensor_mock.hpp
index 2b63d02..2cc8d28 100644
--- a/test/sensor_mock.hpp
+++ b/test/sensor_mock.hpp
@@ -1,18 +1,19 @@
#pragma once
-#include <gmock/gmock.h>
-
#include "interfaces.hpp"
#include "sensors/sensor.hpp"
+#include <gmock/gmock.h>
+
class SensorMock : public Sensor
{
- public:
- virtual ~SensorMock() = default;
+ public:
+ virtual ~SensorMock() = default;
- SensorMock(const std::string& name, int64_t timeout)
- : Sensor(name, timeout) {}
+ SensorMock(const std::string& name, int64_t timeout) : Sensor(name, timeout)
+ {
+ }
- MOCK_METHOD0(read, ReadReturn());
- MOCK_METHOD1(write, void(double));
+ MOCK_METHOD0(read, ReadReturn());
+ MOCK_METHOD1(write, void(double));
};
diff --git a/test/sensor_pluggable_unittest.cpp b/test/sensor_pluggable_unittest.cpp
index 1e32230..015b911 100644
--- a/test/sensor_pluggable_unittest.cpp
+++ b/test/sensor_pluggable_unittest.cpp
@@ -1,15 +1,16 @@
#include "sensors/pluggable.hpp"
-
-#include <chrono>
-#include <gmock/gmock.h>
-#include <gtest/gtest.h>
-
#include "test/readinterface_mock.hpp"
#include "test/writeinterface_mock.hpp"
+#include <chrono>
+
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+
using ::testing::Invoke;
-TEST(PluggableSensorTest, BoringConstructorTest) {
+TEST(PluggableSensorTest, BoringConstructorTest)
+{
// Build a boring Pluggable Sensor.
int64_t min = 0;
@@ -26,7 +27,8 @@
// Successfully created it.
}
-TEST(PluggableSensorTest, TryReadingTest) {
+TEST(PluggableSensorTest, TryReadingTest)
+{
// Verify calling read, calls the ReadInterface.
int64_t min = 0;
@@ -47,12 +49,7 @@
r.value = 0.1;
r.updated = std::chrono::high_resolution_clock::now();
- EXPECT_CALL(*rip, read())
- .WillOnce(
- Invoke([&](void) {
- return r;
- })
- );
+ EXPECT_CALL(*rip, read()).WillOnce(Invoke([&](void) { return r; }));
// TODO(venture): Implement comparison operator for ReadReturn.
ReadReturn v = p.read();
@@ -60,7 +57,8 @@
EXPECT_EQ(r.updated, v.updated);
}
-TEST(PluggableSensorTest, TryWritingTest) {
+TEST(PluggableSensorTest, TryWritingTest)
+{
// Verify calling write, calls the WriteInterface.
int64_t min = 0;
diff --git a/test/util_unittest.cpp b/test/util_unittest.cpp
index 8abf1eb..6fe77b2 100644
--- a/test/util_unittest.cpp
+++ b/test/util_unittest.cpp
@@ -1,69 +1,80 @@
#include "util.hpp"
-#include <gmock/gmock.h>
-#include <gtest/gtest.h>
#include <string>
-TEST(UtilTest, WriteTypeEmptyString_ReturnsNONE) {
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+
+TEST(UtilTest, WriteTypeEmptyString_ReturnsNONE)
+{
// Verify it responds to an empty string.
EXPECT_EQ(IOInterfaceType::NONE, GetWriteInterfaceType(""));
}
-TEST(UtilTest, WriteTypeNonePath_ReturnsNONE) {
+TEST(UtilTest, WriteTypeNonePath_ReturnsNONE)
+{
// Verify it responds to a path of "None"
EXPECT_EQ(IOInterfaceType::NONE, GetWriteInterfaceType("None"));
}
-TEST(UtilTest, WriteTypeSysfs_ReturnsSYSFS) {
+TEST(UtilTest, WriteTypeSysfs_ReturnsSYSFS)
+{
// Verify the sysfs type is determined with an expected path
std::string path = "/sys/devices/asfdadsf";
EXPECT_EQ(IOInterfaceType::SYSFS, GetWriteInterfaceType(path));
}
-TEST(UtilTest, WriteTypeUnknown_ReturnsUNKNOWN) {
+TEST(UtilTest, WriteTypeUnknown_ReturnsUNKNOWN)
+{
// Verify it reports unknown by default.
std::string path = "/xyz/openbmc_project";
EXPECT_EQ(IOInterfaceType::UNKNOWN, GetWriteInterfaceType(path));
}
-TEST(UtilTest, ReadTypeEmptyString_ReturnsNONE) {
+TEST(UtilTest, ReadTypeEmptyString_ReturnsNONE)
+{
// Verify it responds to an empty string.
EXPECT_EQ(IOInterfaceType::NONE, GetReadInterfaceType(""));
}
-TEST(UtilTest, ReadTypeNonePath_ReturnsNONE) {
+TEST(UtilTest, ReadTypeNonePath_ReturnsNONE)
+{
// Verify it responds to a path of "None"
EXPECT_EQ(IOInterfaceType::NONE, GetReadInterfaceType("None"));
}
-TEST(UtilTest, ReadTypeExternalSensors_ReturnsEXTERNAL) {
+TEST(UtilTest, ReadTypeExternalSensors_ReturnsEXTERNAL)
+{
// Verify it responds to a path that represents a host sensor.
std::string path = "/xyz/openbmc_project/extsensors/temperature/fleeting0";
EXPECT_EQ(IOInterfaceType::EXTERNAL, GetReadInterfaceType(path));
}
-TEST(UtilTest, ReadTypeOpenBMCSensor_ReturnsDBUSPASSIVE) {
+TEST(UtilTest, ReadTypeOpenBMCSensor_ReturnsDBUSPASSIVE)
+{
// Verify it responds to a path that represents a dbus sensor.
std::string path = "/xyz/openbmc_project/sensors/fan_tach/fan1";
EXPECT_EQ(IOInterfaceType::DBUSPASSIVE, GetReadInterfaceType(path));
}
-TEST(UtilTest, ReadTypeSysfsPath_ReturnsSYSFS) {
+TEST(UtilTest, ReadTypeSysfsPath_ReturnsSYSFS)
+{
// Verify the sysfs type is determined with an expected path
std::string path = "/sys/devices/asdf/asdf0";
EXPECT_EQ(IOInterfaceType::SYSFS, GetReadInterfaceType(path));
}
-TEST(UtilTest, ReadTypeUnknownDefault_ReturnsUNKNOWN) {
+TEST(UtilTest, ReadTypeUnknownDefault_ReturnsUNKNOWN)
+{
// Verify it reports unknown by default.
std::string path = "asdf09as0df9a0fd";
diff --git a/test/writeinterface_mock.hpp b/test/writeinterface_mock.hpp
index 6aaa4de..6e5b350 100644
--- a/test/writeinterface_mock.hpp
+++ b/test/writeinterface_mock.hpp
@@ -6,11 +6,12 @@
class WriteInterfaceMock : public WriteInterface
{
- public:
- virtual ~WriteInterfaceMock() = default;
+ public:
+ virtual ~WriteInterfaceMock() = default;
- WriteInterfaceMock(int64_t min, int64_t max)
- : WriteInterface(min, max) {}
+ WriteInterfaceMock(int64_t min, int64_t max) : WriteInterface(min, max)
+ {
+ }
- MOCK_METHOD1(write, void(double));
+ MOCK_METHOD1(write, void(double));
};
diff --git a/test/zone_mock.hpp b/test/zone_mock.hpp
index f08c68f..8dbf24a 100644
--- a/test/zone_mock.hpp
+++ b/test/zone_mock.hpp
@@ -1,19 +1,20 @@
#pragma once
-#include <gmock/gmock.h>
+#include "pid/zone.hpp"
+
#include <string>
-#include "pid/zone.hpp"
+#include <gmock/gmock.h>
class ZoneMock : public ZoneInterface
{
- public:
- virtual ~ZoneMock() = default;
+ public:
+ virtual ~ZoneMock() = default;
- MOCK_METHOD1(getCachedValue, double(const std::string&));
- MOCK_METHOD1(addRPMSetPoint, void(float));
- MOCK_CONST_METHOD0(getMaxRPMRequest, float());
- MOCK_CONST_METHOD0(getFailSafeMode, bool());
- MOCK_CONST_METHOD0(getFailSafePercent, float());
- MOCK_METHOD1(getSensor, Sensor*(std::string));
+ MOCK_METHOD1(getCachedValue, double(const std::string&));
+ MOCK_METHOD1(addRPMSetPoint, void(float));
+ MOCK_CONST_METHOD0(getMaxRPMRequest, float());
+ MOCK_CONST_METHOD0(getFailSafeMode, bool());
+ MOCK_CONST_METHOD0(getFailSafePercent, float());
+ MOCK_METHOD1(getSensor, Sensor*(std::string));
};