Enable clang-format
Ideally would have done this from the beginning,
but better later than never.
Change-Id: Ib4c73085c4817496c9f2ee505c19149a67b394dc
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
diff --git a/test/test_policy.cpp b/test/test_policy.cpp
index 0993e8f..a9cb0ec 100644
--- a/test/test_policy.cpp
+++ b/test/test_policy.cpp
@@ -117,36 +117,33 @@
}
])";
-
/**
* Helper class to write the above json to a file and then
* remove it when the tests are over.
*/
class PolicyTableTest : public ::testing::Test
{
- protected:
+ protected:
+ virtual void SetUp()
+ {
+ char dir[] = {"./jsonTestXXXXXX"};
- virtual void SetUp()
- {
- char dir[] = {"./jsonTestXXXXXX"};
+ jsonDir = mkdtemp(dir);
+ jsonFile = jsonDir / "policy.json";
- jsonDir = mkdtemp(dir);
- jsonFile = jsonDir / "policy.json";
+ std::ofstream f{jsonFile};
+ f << json;
+ }
- std::ofstream f{jsonFile};
- f << json;
- }
+ virtual void TearDown()
+ {
+ fs::remove_all(jsonDir);
+ }
- virtual void TearDown()
- {
- fs::remove_all(jsonDir);
- }
-
- fs::path jsonDir;
- fs::path jsonFile;
+ fs::path jsonDir;
+ fs::path jsonFile;
};
-
/**
* Test finding entries in the policy table
*/
@@ -156,7 +153,7 @@
ASSERT_EQ(policy.isLoaded(), true);
////////////////////////////////////
- //Basic search, no modifier
+ // Basic search, no modifier
std::string err{"xyz.openbmc_project.Error.Test2"};
std::string mod;
@@ -169,13 +166,13 @@
}
/////////////////////////////////////
- //Not found
+ // Not found
err = "foo";
details = policy.find(err, mod);
ASSERT_EQ(static_cast<bool>(details), false);
/////////////////////////////////////
- //Test with a modifier
+ // Test with a modifier
err = "xyz.openbmc_project.Error.Test3";
mod = "mod3";
@@ -199,120 +196,93 @@
policy::Table policy{jsonFile};
ASSERT_EQ(policy.isLoaded(), true);
- //A basic search with no modifier
+ // A basic search with no modifier
{
- DbusPropertyMap testProperties
- {
- {"Message"s, Value{"xyz.openbmc_project.Error.Test1"s}}
- };
+ DbusPropertyMap testProperties{
+ {"Message"s, Value{"xyz.openbmc_project.Error.Test1"s}}};
auto values = policy::find(policy, testProperties);
ASSERT_EQ(std::get<policy::EIDField>(values), "ABCD1234");
ASSERT_EQ(std::get<policy::MsgField>(values), "Error ABCD1234");
}
- //Use CALLOUT_INVENTORY_PATH from the AdditionalData property
+ // Use CALLOUT_INVENTORY_PATH from the AdditionalData property
{
- std::vector<std::string> ad{
- "FOO=BAR"s,
- "CALLOUT_INVENTORY_PATH=mod2"s};
- DbusPropertyMap testProperties
- {
+ std::vector<std::string> ad{"FOO=BAR"s, "CALLOUT_INVENTORY_PATH=mod2"s};
+ DbusPropertyMap testProperties{
{"Message"s, Value{"xyz.openbmc_project.Error.Test3"s}},
- {"AdditionalData"s, ad}
- };
+ {"AdditionalData"s, ad}};
auto values = policy::find(policy, testProperties);
ASSERT_EQ(std::get<policy::EIDField>(values), "BBBBBB");
ASSERT_EQ(std::get<policy::MsgField>(values), "Error BBBBBB");
}
- //Use an I2C DEVICE_PATH from the AdditionalData property
+ // Use an I2C DEVICE_PATH from the AdditionalData property
{
- std::vector<std::string> ad{
- "FOO=BAR"s,
- "CALLOUT_DEVICE_PATH=/some/i2c/path"s};
- DbusPropertyMap testProperties
- {
+ std::vector<std::string> ad{"FOO=BAR"s,
+ "CALLOUT_DEVICE_PATH=/some/i2c/path"s};
+ DbusPropertyMap testProperties{
{"Message"s, Value{"xyz.openbmc_project.Error.Test4"s}},
- {"AdditionalData"s, ad}
- };
+ {"AdditionalData"s, ad}};
auto values = policy::find(policy, testProperties);
ASSERT_EQ(std::get<policy::EIDField>(values), "DDDDDDDD");
ASSERT_EQ(std::get<policy::MsgField>(values), "Error DDDDDDDD");
}
- //Use an FSI DEVICE_PATH from the AdditionalData property
+ // Use an FSI DEVICE_PATH from the AdditionalData property
{
- std::vector<std::string> ad{
- "FOO=BAR"s,
- "CALLOUT_DEVICE_PATH=/some/fsi/path"s};
- DbusPropertyMap testProperties
- {
+ std::vector<std::string> ad{"FOO=BAR"s,
+ "CALLOUT_DEVICE_PATH=/some/fsi/path"s};
+ DbusPropertyMap testProperties{
{"Message"s, Value{"xyz.openbmc_project.Error.Test4"s}},
- {"AdditionalData"s, ad}
- };
+ {"AdditionalData"s, ad}};
auto values = policy::find(policy, testProperties);
ASSERT_EQ(std::get<policy::EIDField>(values), "EEEEEEEE");
ASSERT_EQ(std::get<policy::MsgField>(values), "Error EEEEEEEE");
}
- //Use PROCEDURE from the AdditionalData property
+ // Use PROCEDURE from the AdditionalData property
{
- std::vector<std::string> ad{
- "FOO=BAR"s,
- "PROCEDURE=109"s};
- DbusPropertyMap testProperties
- {
+ std::vector<std::string> ad{"FOO=BAR"s, "PROCEDURE=109"s};
+ DbusPropertyMap testProperties{
{"Message"s, Value{"xyz.openbmc_project.Error.Test5"s}},
- {"AdditionalData"s, ad}
- };
+ {"AdditionalData"s, ad}};
auto values = policy::find(policy, testProperties);
ASSERT_EQ(std::get<policy::EIDField>(values), "FFFFFFFF");
ASSERT_EQ(std::get<policy::MsgField>(values), "Error FFFFFFFF");
}
- //Use RAIL_NAME from the AdditionalData property
+ // Use RAIL_NAME from the AdditionalData property
{
- std::vector<std::string> ad{
- "FOO=BAR"s,
- "RAIL_NAME=RAIL_5"s};
- DbusPropertyMap testProperties
- {
+ std::vector<std::string> ad{"FOO=BAR"s, "RAIL_NAME=RAIL_5"s};
+ DbusPropertyMap testProperties{
{"Message"s, Value{"xyz.openbmc_project.Error.Test6"s}},
- {"AdditionalData"s, ad}
- };
+ {"AdditionalData"s, ad}};
auto values = policy::find(policy, testProperties);
ASSERT_EQ(std::get<policy::EIDField>(values), "GGGGGGGG");
ASSERT_EQ(std::get<policy::MsgField>(values), "Error GGGGGGGG");
}
- //Use INPUT_NAME from the AdditionalData property
+ // Use INPUT_NAME from the AdditionalData property
{
- std::vector<std::string> ad{
- "FOO=BAR"s,
- "INPUT_NAME=INPUT_42"s};
- DbusPropertyMap testProperties
- {
+ std::vector<std::string> ad{"FOO=BAR"s, "INPUT_NAME=INPUT_42"s};
+ DbusPropertyMap testProperties{
{"Message"s, Value{"xyz.openbmc_project.Error.Test7"s}},
- {"AdditionalData"s, ad}
- };
+ {"AdditionalData"s, ad}};
auto values = policy::find(policy, testProperties);
ASSERT_EQ(std::get<policy::EIDField>(values), "HHHHHHHH");
ASSERT_EQ(std::get<policy::MsgField>(values), "Error HHHHHHHH");
}
- //Test not finding an entry.
+ // Test not finding an entry.
{
- DbusPropertyMap testProperties
- {
- {"Message"s, Value{"hello world"s}}
- };
+ DbusPropertyMap testProperties{{"Message"s, Value{"hello world"s}}};
auto values = policy::find(policy, testProperties);
ASSERT_EQ(std::get<policy::EIDField>(values), policy.defaultEID());
@@ -321,18 +291,13 @@
// Test that strange AdditionalData values don't break anything
{
- std::vector<std::string> ad{
- "FOO"s,
- "INPUT_NAME="s};
- DbusPropertyMap testProperties
- {
+ std::vector<std::string> ad{"FOO"s, "INPUT_NAME="s};
+ DbusPropertyMap testProperties{
{"Message"s, Value{"xyz.openbmc_project.Error.Test7"s}},
- {"AdditionalData"s, ad}
- };
+ {"AdditionalData"s, ad}};
auto values = policy::find(policy, testProperties);
ASSERT_EQ(std::get<policy::EIDField>(values), policy.defaultEID());
ASSERT_EQ(std::get<policy::MsgField>(values), policy.defaultMsg());
}
}
-