Update repo to conform to openbmc code standard
Change-Id: If1d6b1f04514367cc544c2507a845b3e9d6d3435
Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
diff --git a/test/bus/list_names.cpp b/test/bus/list_names.cpp
index 65333b7..a1967d9 100644
--- a/test/bus/list_names.cpp
+++ b/test/bus/list_names.cpp
@@ -5,17 +5,15 @@
class ListNames : public ::testing::Test
{
- protected:
- decltype(sdbusplus::bus::new_default()) bus =
- sdbusplus::bus::new_default();
+ protected:
+ decltype(sdbusplus::bus::new_default()) bus = sdbusplus::bus::new_default();
};
TEST_F(ListNames, NoServiceNameWithoutRequestName)
{
auto names = bus.list_names_acquired();
- EXPECT_EQ(names.cend(),
- std::find(names.cbegin(), names.cend(), this_name));
+ EXPECT_EQ(names.cend(), std::find(names.cbegin(), names.cend(), this_name));
}
TEST_F(ListNames, HasServiceNameAfterRequestName)
@@ -38,7 +36,6 @@
std::find(names.cbegin(), names.cend(), bus.get_unique_name()));
}
-
TEST_F(ListNames, HasDbusServer)
{
auto names = bus.list_names_acquired();
diff --git a/test/bus/match.cpp b/test/bus/match.cpp
index c69c76b..80bc259 100644
--- a/test/bus/match.cpp
+++ b/test/bus/match.cpp
@@ -4,41 +4,37 @@
class Match : public ::testing::Test
{
- protected:
- decltype(sdbusplus::bus::new_default()) bus =
- sdbusplus::bus::new_default();
+ protected:
+ decltype(sdbusplus::bus::new_default()) bus = sdbusplus::bus::new_default();
- static constexpr auto busName =
- "xyz.openbmc_project.sdbusplus.test.Match";
+ static constexpr auto busName = "xyz.openbmc_project.sdbusplus.test.Match";
+ static auto matchRule()
+ {
+ using namespace sdbusplus::bus::match::rules;
+ return nameOwnerChanged() + argN(0, busName);
+ }
- static auto matchRule()
+ void waitForIt(bool& triggered)
+ {
+ for (size_t i = 0; (i < 16) && !triggered; ++i)
{
- using namespace sdbusplus::bus::match::rules;
- return nameOwnerChanged() + argN(0, busName);
+ bus.wait(0);
+ bus.process_discard();
}
-
- void waitForIt(bool& triggered)
- {
- for (size_t i = 0; (i < 16) && !triggered; ++i)
- {
- bus.wait(0);
- bus.process_discard();
- }
- }
+ }
};
TEST_F(Match, FunctorIs_sd_bus_message_handler_t)
{
bool triggered = false;
- auto trigger = [](sd_bus_message *m, void* context, sd_bus_error* e)
- {
- *static_cast<bool*>(context) = true;
- return 0;
- };
+ auto trigger = [](sd_bus_message* m, void* context, sd_bus_error* e) {
+ *static_cast<bool*>(context) = true;
+ return 0;
+ };
sdbusplus::bus::match_t m{bus, matchRule(), trigger, &triggered};
- auto m2 = std::move(m); // ensure match is move-safe.
+ auto m2 = std::move(m); // ensure match is move-safe.
waitForIt(triggered);
ASSERT_FALSE(triggered);
@@ -52,13 +48,12 @@
TEST_F(Match, FunctorIs_LambdaTakingMessage)
{
bool triggered = false;
- auto trigger = [&triggered](sdbusplus::message::message& m)
- {
- triggered = true;
- };
+ auto trigger = [&triggered](sdbusplus::message::message& m) {
+ triggered = true;
+ };
sdbusplus::bus::match_t m{bus, matchRule(), trigger};
- auto m2 = std::move(m); // ensure match is move-safe.
+ auto m2 = std::move(m); // ensure match is move-safe.
waitForIt(triggered);
ASSERT_FALSE(triggered);
@@ -74,20 +69,20 @@
class BoolHolder
{
- public:
- bool triggered = false;
+ public:
+ bool triggered = false;
- void callback(sdbusplus::message::message& m)
- {
- triggered = true;
- }
+ void callback(sdbusplus::message::message& m)
+ {
+ triggered = true;
+ }
};
BoolHolder b;
sdbusplus::bus::match_t m{bus, matchRule(),
- std::bind(std::mem_fn(&BoolHolder::callback),
- &b, std::placeholders::_1)};
- auto m2 = std::move(m); // ensure match is move-safe.
+ std::bind(std::mem_fn(&BoolHolder::callback), &b,
+ std::placeholders::_1)};
+ auto m2 = std::move(m); // ensure match is move-safe.
waitForIt(b.triggered);
ASSERT_FALSE(b.triggered);
diff --git a/test/message/append.cpp b/test/message/append.cpp
index c3a06db..7782f02 100644
--- a/test/message/append.cpp
+++ b/test/message/append.cpp
@@ -6,7 +6,7 @@
// Global to share the dbus type string between client and server.
static std::string verifyTypeString;
-using verifyCallback_t = void(*)(sd_bus_message*);
+using verifyCallback_t = void (*)(sd_bus_message*);
verifyCallback_t verifyCallback = nullptr;
static constexpr auto SERVICE = "sdbusplus.test.message.append";
@@ -28,12 +28,12 @@
{
auto bus = sdbusplus::bus::bus(reinterpret_cast<sdbusplus::bus::busp_t>(b));
- while(1)
+ while (1)
{
// Wait for messages.
auto m = bus.process().release();
- if(m == nullptr)
+ if (m == nullptr)
{
bus.wait();
continue;
@@ -50,8 +50,8 @@
}
else
{
- std::cout << "Warning: No verification for "
- << verifyTypeString << std::endl;
+ std::cout << "Warning: No verification for " << verifyTypeString
+ << std::endl;
}
// Reply to client.
sd_bus_reply_method_return(m, nullptr);
@@ -233,8 +233,7 @@
const char* str3 = "1234";
const char* const str4 = "5678";
const auto str5 = "!@#$";
- m.append(1, "asdf", "ASDF"s, str,
- std::move(str2), str3, str4, str5, 5);
+ m.append(1, "asdf", "ASDF"s, str, std::move(str2), str3, str4, str5, 5);
verifyTypeString = "isssssssi";
struct verify
@@ -245,8 +244,8 @@
const char *s0 = nullptr, *s1 = nullptr, *s2 = nullptr,
*s3 = nullptr, *s4 = nullptr, *s5 = nullptr,
*s6 = nullptr;
- sd_bus_message_read(m, "isssssssi", &a, &s0, &s1, &s2, &s3,
- &s4, &s5, &s6, &b);
+ sd_bus_message_read(m, "isssssssi", &a, &s0, &s1, &s2, &s3, &s4,
+ &s5, &s6, &b);
assert(a == 1);
assert(b == 5);
assert(0 == strcmp("asdf", s0));
@@ -283,7 +282,6 @@
assert(b == 4);
assert(0 == strcmp("/asdf", s0));
assert(0 == strcmp("iii", s1));
-
}
};
verifyCallback = &verify::op;
@@ -294,7 +292,7 @@
// Test vector.
{
auto m = newMethodCall__test(b);
- std::vector<std::string> s{ "1", "2", "3"};
+ std::vector<std::string> s{"1", "2", "3"};
m.append(1, s, 2);
verifyTypeString = "iasi";
@@ -306,9 +304,8 @@
sd_bus_message_read(m, "i", &a);
assert(a == 1);
- auto rc = sd_bus_message_enter_container(m,
- SD_BUS_TYPE_ARRAY,
- "s");
+ auto rc =
+ sd_bus_message_enter_container(m, SD_BUS_TYPE_ARRAY, "s");
assert(0 <= rc);
const char* s = nullptr;
@@ -324,19 +321,17 @@
sd_bus_message_read(m, "i", &a);
assert(a == 2);
-
}
};
verifyCallback = &verify::op;
-
b.call_noreply(m);
}
// Test map.
{
auto m = newMethodCall__test(b);
- std::map<std::string, int> s = { { "asdf", 3 }, { "jkl;", 4 } };
+ std::map<std::string, int> s = {{"asdf", 3}, {"jkl;", 4}};
m.append(1, s, 2);
verifyTypeString = "ia{si}i";
@@ -348,13 +343,11 @@
sd_bus_message_read(m, "i", &a);
assert(a == 1);
- auto rc = sd_bus_message_enter_container(m,
- SD_BUS_TYPE_ARRAY,
+ auto rc = sd_bus_message_enter_container(m, SD_BUS_TYPE_ARRAY,
"{si}");
assert(0 <= rc);
- rc = sd_bus_message_enter_container(m,
- SD_BUS_TYPE_DICT_ENTRY,
+ rc = sd_bus_message_enter_container(m, SD_BUS_TYPE_DICT_ENTRY,
"si");
assert(0 <= rc);
@@ -367,8 +360,7 @@
assert(1 == sd_bus_message_at_end(m, false));
sd_bus_message_exit_container(m);
- rc = sd_bus_message_enter_container(m,
- SD_BUS_TYPE_DICT_ENTRY,
+ rc = sd_bus_message_enter_container(m, SD_BUS_TYPE_DICT_ENTRY,
"si");
assert(0 <= rc);
@@ -395,7 +387,7 @@
// Test tuple.
{
auto m = newMethodCall__test(b);
- std::tuple<int, double, std::string> a{ 3, 4.1, "asdf" };
+ std::tuple<int, double, std::string> a{3, 4.1, "asdf"};
m.append(1, a, 2);
verifyTypeString = "i(ids)i";
@@ -410,8 +402,7 @@
sd_bus_message_read(m, "i", &a);
assert(a == 1);
- auto rc = sd_bus_message_enter_container(m,
- SD_BUS_TYPE_STRUCT,
+ auto rc = sd_bus_message_enter_container(m, SD_BUS_TYPE_STRUCT,
"ids");
assert(0 <= rc);
@@ -470,8 +461,8 @@
// Test map-variant.
{
auto m = newMethodCall__test(b);
- std::map<std::string, sdbusplus::message::variant<int, double>> a1 =
- { { "asdf", 3 }, { "jkl;", 4.1 } };
+ std::map<std::string, sdbusplus::message::variant<int, double>> a1 = {
+ {"asdf", 3}, {"jkl;", 4.1}};
m.append(1, a1, 2);
verifyTypeString = "ia{sv}i";
diff --git a/test/message/native_types.cpp b/test/message/native_types.cpp
index 3b46457..eed7669 100644
--- a/test/message/native_types.cpp
+++ b/test/message/native_types.cpp
@@ -28,24 +28,24 @@
TEST(MessageNativeTypeConversions, SignatureInVector)
{
- std::vector<sdbusplus::message::signature> v =
- { sdbusplus::message::signature("iii") };
+ std::vector<sdbusplus::message::signature> v = {
+ sdbusplus::message::signature("iii")};
ASSERT_EQ(v.front(), "iii");
}
TEST(MessageNativeTypeConversions, SignatureInMap)
{
- std::map<sdbusplus::message::signature, int> m =
- { { sdbusplus::message::signature("iii"), 1 } };
+ std::map<sdbusplus::message::signature, int> m = {
+ {sdbusplus::message::signature("iii"), 1}};
ASSERT_EQ(m[sdbusplus::message::signature("iii")], 1);
}
TEST(MessageNativeTypeConversions, SignatureInUnorderedMap)
{
- std::unordered_map<sdbusplus::message::signature, int> u =
- { { sdbusplus::message::signature("iii"), 2 } };
+ std::unordered_map<sdbusplus::message::signature, int> u = {
+ {sdbusplus::message::signature("iii"), 2}};
ASSERT_EQ(u[sdbusplus::message::signature("iii")], 2);
}
diff --git a/test/message/read.cpp b/test/message/read.cpp
index 2b137d7..8c2c4ea 100644
--- a/test/message/read.cpp
+++ b/test/message/read.cpp
@@ -6,7 +6,7 @@
// Global to share the dbus type string between client and server.
static std::string verifyTypeString;
-using verifyCallback_t = void(*)(sdbusplus::message::message&);
+using verifyCallback_t = void (*)(sdbusplus::message::message&);
verifyCallback_t verifyCallback = nullptr;
static constexpr auto SERVICE = "sdbusplus.test.message.read";
@@ -28,12 +28,12 @@
{
auto bus = sdbusplus::bus::bus(reinterpret_cast<sdbusplus::bus::busp_t>(b));
- while(1)
+ while (1)
{
// Wait for messages.
auto m = bus.process();
- if(!m)
+ if (!m)
{
bus.wait();
continue;
@@ -52,8 +52,8 @@
}
else
{
- std::cout << "Warning: No verification for "
- << verifyTypeString << std::endl;
+ std::cout << "Warning: No verification for " << verifyTypeString
+ << std::endl;
}
// Reply to client.
sd_bus_reply_method_return(m.release(), nullptr);
@@ -133,7 +133,7 @@
static void op(sdbusplus::message::message& m)
{
int32_t a = 0, b = 0, c = 0, d = 0, e = 0;
- m.read(a,b,c,d,e);
+ m.read(a, b, c, d, e);
assert(a == 1);
assert(b == 2);
assert(c == 3);
@@ -200,8 +200,7 @@
auto m = newMethodCall__test(b);
auto str = "jkl;"s;
auto str2 = "JKL:"s;
- m.append(1, "asdf", "ASDF"s, str,
- std::move(str2), 5);
+ m.append(1, "asdf", "ASDF"s, str, std::move(str2), 5);
verifyTypeString = "issssi";
struct verify
@@ -251,11 +250,10 @@
b.call_noreply(m);
}
-
// Test vector.
{
auto m = newMethodCall__test(b);
- std::vector<std::string> s{ "1", "2", "3"};
+ std::vector<std::string> s{"1", "2", "3"};
m.append(1, s, 2);
verifyTypeString = "iasi";
@@ -270,7 +268,7 @@
assert(s[0] == "1");
assert(s[1] == "2");
assert(s[2] == "3");
- decltype(s) s2 = { "1" , "2" , "3" };
+ decltype(s) s2 = {"1", "2", "3"};
assert(s == s2);
}
};
@@ -282,7 +280,7 @@
// Test map.
{
auto m = newMethodCall__test(b);
- std::map<std::string, int> s = { { "asdf", 3 }, { "jkl;", 4 } };
+ std::map<std::string, int> s = {{"asdf", 3}, {"jkl;", 4}};
m.append(1, s, 2);
verifyTypeString = "ia{si}i";
@@ -309,7 +307,7 @@
// Test tuple.
{
auto m = newMethodCall__test(b);
- std::tuple<int, double, std::string> a{ 3, 4.1, "asdf" };
+ std::tuple<int, double, std::string> a{3, 4.1, "asdf"};
m.append(1, a, 2);
verifyTypeString = "i(ids)i";
@@ -386,8 +384,8 @@
// Test map-variant.
{
auto m = newMethodCall__test(b);
- std::map<std::string, sdbusplus::message::variant<int, double>> a1 =
- { { "asdf", 3 }, { "jkl;", 4.1 } };
+ std::map<std::string, sdbusplus::message::variant<int, double>> a1 = {
+ {"asdf", 3}, {"jkl;", 4.1}};
m.append(1, a1, 2);
verifyTypeString = "ia{sv}i";
@@ -396,8 +394,8 @@
static void op(sdbusplus::message::message& m)
{
int32_t a = 0, b = 0;
- std::map<std::string,
- sdbusplus::message::variant<int, double>> a1{};
+ std::map<std::string, sdbusplus::message::variant<int, double>>
+ a1{};
m.read(a, a1, b);
assert(a == 1);
@@ -411,7 +409,6 @@
b.call_noreply(m);
}
-
// Shutdown server.
{
auto m = b.new_method_call(SERVICE, "/", INTERFACE, QUIT_METHOD);
diff --git a/test/message/types.cpp b/test/message/types.cpp
index 604996e..e779c79 100644
--- a/test/message/types.cpp
+++ b/test/message/types.cpp
@@ -2,17 +2,16 @@
#include <sdbusplus/message/types.hpp>
#include <sdbusplus/utility/tuple_to_array.hpp>
-template <typename ...Args>
-auto dbus_string(Args&& ... args)
+template <typename... Args> auto dbus_string(Args&&... args)
{
- return std::string(
- sdbusplus::utility::tuple_to_array(
- sdbusplus::message::types::type_id<Args...>()).data());
+ return std::string(sdbusplus::utility::tuple_to_array(
+ sdbusplus::message::types::type_id<Args...>())
+ .data());
}
TEST(MessageTypes, Integer)
{
- ASSERT_EQ(dbus_string(1),"i");
+ ASSERT_EQ(dbus_string(1), "i");
}
TEST(MessageTypes, Double)
diff --git a/test/utility/type_traits.cpp b/test/utility/type_traits.cpp
index 3a31d06..f2beed7 100644
--- a/test/utility/type_traits.cpp
+++ b/test/utility/type_traits.cpp
@@ -4,17 +4,14 @@
{
using sdbusplus::utility::array_to_ptr_t;
- static_assert(
- std::is_same<char, array_to_ptr_t<char, char>>::value,
- "array_to_ptr_t<char, char> != char");
+ static_assert(std::is_same<char, array_to_ptr_t<char, char>>::value,
+ "array_to_ptr_t<char, char> != char");
- static_assert(
- std::is_same<char*, array_to_ptr_t<char, char*>>::value,
- "array_to_ptr_t<char, char*> != char*");
+ static_assert(std::is_same<char*, array_to_ptr_t<char, char*>>::value,
+ "array_to_ptr_t<char, char*> != char*");
- static_assert(
- std::is_same<char*, array_to_ptr_t<char, char[100]>>::value,
- "array_to_ptr_t<char, char[100]> != char*");
+ static_assert(std::is_same<char*, array_to_ptr_t<char, char[100]>>::value,
+ "array_to_ptr_t<char, char[100]> != char*");
static_assert(
std::is_same<char[100], array_to_ptr_t<int, char[100]>>::value,
diff --git a/test/vtable/vtable.cpp b/test/vtable/vtable.cpp
index ab1e34a..bc67382 100644
--- a/test/vtable/vtable.cpp
+++ b/test/vtable/vtable.cpp
@@ -1,22 +1,19 @@
#include <sdbusplus/vtable.hpp>
#include <gtest/gtest.h>
-static const sdbusplus::vtable::vtable_t example[] =
- {
- sdbusplus::vtable::start(),
- sdbusplus::vtable::method((const char*)1, (const char*)2,
- (const char*)3,
- (sd_bus_message_handler_t)4),
- sdbusplus::vtable::signal((const char*)5, (const char*)6),
- sdbusplus::vtable::property((const char*)7, (const char*)8,
- (sd_bus_property_get_t)9,
- sdbusplus::vtable::property_::const_),
- sdbusplus::vtable::property((const char*)10, (const char*)11,
- (sd_bus_property_get_t)12,
- (sd_bus_property_set_t)13),
- sdbusplus::vtable::property_o((const char*)14, (const char*)15, 16),
- sdbusplus::vtable::end()
- };
+static const sdbusplus::vtable::vtable_t example[] = {
+ sdbusplus::vtable::start(),
+ sdbusplus::vtable::method((const char*)1, (const char*)2, (const char*)3,
+ (sd_bus_message_handler_t)4),
+ sdbusplus::vtable::signal((const char*)5, (const char*)6),
+ sdbusplus::vtable::property((const char*)7, (const char*)8,
+ (sd_bus_property_get_t)9,
+ sdbusplus::vtable::property_::const_),
+ sdbusplus::vtable::property((const char*)10, (const char*)11,
+ (sd_bus_property_get_t)12,
+ (sd_bus_property_set_t)13),
+ sdbusplus::vtable::property_o((const char*)14, (const char*)15, 16),
+ sdbusplus::vtable::end()};
extern const sd_bus_vtable example2[];
extern const size_t example2_size;
diff --git a/test/vtable/vtable_c.c b/test/vtable/vtable_c.c
index 442d6c7..d01506b 100644
--- a/test/vtable/vtable_c.c
+++ b/test/vtable/vtable_c.c
@@ -1,21 +1,17 @@
#include <systemd/sd-bus.h>
-
-const sd_bus_vtable example2[] =
- {
- SD_BUS_VTABLE_START(0),
- SD_BUS_METHOD((const char*)1, (const char*)2,
- (const char*)3, (sd_bus_message_handler_t)4, 0),
- SD_BUS_SIGNAL((const char*)5, (const char*)6, 0),
- SD_BUS_PROPERTY((const char*)7, (const char*)8,
- (sd_bus_property_get_t)9, 0,
- SD_BUS_VTABLE_PROPERTY_CONST),
- SD_BUS_WRITABLE_PROPERTY((const char*)10, (const char*)11,
- (sd_bus_property_get_t)12,
- (sd_bus_property_set_t)13, 0, 0),
- SD_BUS_PROPERTY((const char*)14, (const char*)15, NULL, 16, 0),
- SD_BUS_VTABLE_END,
- };
+const sd_bus_vtable example2[] = {
+ SD_BUS_VTABLE_START(0),
+ SD_BUS_METHOD((const char*)1, (const char*)2, (const char*)3,
+ (sd_bus_message_handler_t)4, 0),
+ SD_BUS_SIGNAL((const char*)5, (const char*)6, 0),
+ SD_BUS_PROPERTY((const char*)7, (const char*)8, (sd_bus_property_get_t)9, 0,
+ SD_BUS_VTABLE_PROPERTY_CONST),
+ SD_BUS_WRITABLE_PROPERTY((const char*)10, (const char*)11,
+ (sd_bus_property_get_t)12,
+ (sd_bus_property_set_t)13, 0, 0),
+ SD_BUS_PROPERTY((const char*)14, (const char*)15, NULL, 16, 0),
+ SD_BUS_VTABLE_END,
+};
const size_t example2_size = sizeof(example2);
-