summaryrefslogtreecommitdiffstats
path: root/mslverify
diff options
context:
space:
mode:
authorBrad Bishop <bradleyb@fuzziesquirrel.com>2018-03-29 10:34:05 -0400
committerBrad Bishop <bradleyb@fuzziesquirrel.com>2018-03-29 10:34:46 -0400
commitd1eac88d18ae7dd11033dba87b6aebb220da9064 (patch)
tree9744e38138ff853c53868d847f86e9ad58e9ac66 /mslverify
parent1abcb06bedadfbd40b4ec6f7e5f6a95021df3c96 (diff)
downloadphosphor-dbus-monitor-d1eac88d18ae7dd11033dba87b6aebb220da9064.tar.gz
phosphor-dbus-monitor-d1eac88d18ae7dd11033dba87b6aebb220da9064.zip
Enable clang-format
Fix up errors and enable clang-format during CI builds. Change-Id: I4176b81f8b85a287af9354165e09ff66aeb9fb29 Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Diffstat (limited to 'mslverify')
-rw-r--r--mslverify/util.hpp182
-rw-r--r--mslverify/verify.cpp69
2 files changed, 86 insertions, 165 deletions
diff --git a/mslverify/util.hpp b/mslverify/util.hpp
index 2c26fc2..f487cee 100644
--- a/mslverify/util.hpp
+++ b/mslverify/util.hpp
@@ -15,7 +15,7 @@ namespace errors = sdbusplus::xyz::openbmc_project::Common::Error;
} // namespace detail
/** @brief Alias for PropertiesChanged signal callbacks. */
-template <typename ...T>
+template <typename... T>
using Properties = std::map<std::string, sdbusplus::message::variant<T...>>;
namespace sdbusplus
@@ -30,31 +30,23 @@ static auto& getBus()
}
/** @brief Invoke a method. */
-template <typename ...Args>
-static auto callMethod(
- ::sdbusplus::bus::bus& bus,
- const std::string& busName,
- const std::string& path,
- const std::string& interface,
- const std::string& method,
- Args&& ... args)
+template <typename... Args>
+static auto callMethod(::sdbusplus::bus::bus& bus, const std::string& busName,
+ const std::string& path, const std::string& interface,
+ const std::string& method, Args&&... args)
{
- auto reqMsg = bus.new_method_call(
- busName.c_str(),
- path.c_str(),
- interface.c_str(),
- method.c_str());
+ auto reqMsg = bus.new_method_call(busName.c_str(), path.c_str(),
+ interface.c_str(), method.c_str());
reqMsg.append(std::forward<Args>(args)...);
auto respMsg = bus.call(reqMsg);
if (respMsg.is_method_error())
{
phosphor::logging::log<phosphor::logging::level::INFO>(
- "Failed to invoke DBus method.",
- phosphor::logging::entry("PATH=%s", path.c_str()),
- phosphor::logging::entry(
- "INTERFACE=%s", interface.c_str()),
- phosphor::logging::entry("METHOD=%s", method.c_str()));
+ "Failed to invoke DBus method.",
+ phosphor::logging::entry("PATH=%s", path.c_str()),
+ phosphor::logging::entry("INTERFACE=%s", interface.c_str()),
+ phosphor::logging::entry("METHOD=%s", method.c_str()));
phosphor::logging::elog<detail::errors::InternalFailure>();
}
@@ -62,90 +54,59 @@ static auto callMethod(
}
/** @brief Invoke a method. */
-template <typename ...Args>
-static auto callMethod(
- const std::string& busName,
- const std::string& path,
- const std::string& interface,
- const std::string& method,
- Args&& ... args)
+template <typename... Args>
+static auto callMethod(const std::string& busName, const std::string& path,
+ const std::string& interface, const std::string& method,
+ Args&&... args)
{
- return callMethod(
- getBus(),
- busName,
- path,
- interface,
- method,
- std::forward<Args>(args)...);
+ return callMethod(getBus(), busName, path, interface, method,
+ std::forward<Args>(args)...);
}
/** @brief Invoke a method and read the response. */
-template <typename Ret, typename ...Args>
-static auto callMethodAndRead(
- ::sdbusplus::bus::bus& bus,
- const std::string& busName,
- const std::string& path,
- const std::string& interface,
- const std::string& method,
- Args&& ... args)
+template <typename Ret, typename... Args>
+static auto
+ callMethodAndRead(::sdbusplus::bus::bus& bus, const std::string& busName,
+ const std::string& path, const std::string& interface,
+ const std::string& method, Args&&... args)
{
- ::sdbusplus::message::message respMsg =
- callMethod<Args...>(
- bus,
- busName,
- path,
- interface,
- method,
- std::forward<Args>(args)...);
+ ::sdbusplus::message::message respMsg = callMethod<Args...>(
+ bus, busName, path, interface, method, std::forward<Args>(args)...);
Ret resp;
respMsg.read(resp);
return resp;
}
/** @brief Invoke a method and read the response. */
- template <typename Ret, typename ...Args>
-static auto callMethodAndRead(
- const std::string& busName,
- const std::string& path,
- const std::string& interface,
- const std::string& method,
- Args&& ... args)
+template <typename Ret, typename... Args>
+static auto callMethodAndRead(const std::string& busName,
+ const std::string& path,
+ const std::string& interface,
+ const std::string& method, Args&&... args)
{
- return callMethodAndRead<Ret>(
- getBus(),
- busName,
- path,
- interface,
- method,
- std::forward<Args>(args)...);
+ return callMethodAndRead<Ret>(getBus(), busName, path, interface, method,
+ std::forward<Args>(args)...);
}
-
/** @brief Get service from the mapper. */
-static auto getService(
- ::sdbusplus::bus::bus& bus,
- const std::string& path,
- const std::string& interface)
+static auto getService(::sdbusplus::bus::bus& bus, const std::string& path,
+ const std::string& interface)
{
using namespace std::literals::string_literals;
using GetObject = std::map<std::string, std::vector<std::string>>;
auto mapperResp = callMethodAndRead<GetObject>(
- bus,
- "xyz.openbmc_project.ObjectMapper"s,
- "/xyz/openbmc_project/object_mapper"s,
- "xyz.openbmc_project.ObjectMapper"s,
- "GetObject"s,
- path,
- GetObject::mapped_type{interface});
+ bus, "xyz.openbmc_project.ObjectMapper"s,
+ "/xyz/openbmc_project/object_mapper"s,
+ "xyz.openbmc_project.ObjectMapper"s, "GetObject"s, path,
+ GetObject::mapped_type{interface});
if (mapperResp.empty())
{
phosphor::logging::log<phosphor::logging::level::INFO>(
- "Object not found.",
- phosphor::logging::entry("PATH=%s", path.c_str()),
- phosphor::logging::entry(
- "INTERFACE=%s", interface.c_str()));
+ "Object not found.",
+ phosphor::logging::entry("PATH=%s", path.c_str()),
+ phosphor::logging::entry("INTERFACE=%s", interface.c_str()));
phosphor::logging::elog<detail::errors::InternalFailure>();
}
return mapperResp.begin()->first;
@@ -153,23 +114,15 @@ static auto getService(
/** @brief Get a property without mapper lookup. */
template <typename Property>
-static auto getProperty(
- ::sdbusplus::bus::bus& bus,
- const std::string& busName,
- const std::string& path,
- const std::string& interface,
- const std::string& property)
+static auto getProperty(::sdbusplus::bus::bus& bus, const std::string& busName,
+ const std::string& path, const std::string& interface,
+ const std::string& property)
{
using namespace std::literals::string_literals;
- auto msg = callMethod(
- bus,
- busName,
- path,
- "org.freedesktop.DBus.Properties"s,
- "Get"s,
- interface,
- property);
+ auto msg =
+ callMethod(bus, busName, path, "org.freedesktop.DBus.Properties"s,
+ "Get"s, interface, property);
::sdbusplus::message::variant<Property> value;
msg.read(value);
return value.template get<Property>();
@@ -177,48 +130,29 @@ static auto getProperty(
/** @brief Get a property without mapper lookup. */
template <typename Property>
-static auto getProperty(
- const std::string& busName,
- const std::string& path,
- const std::string& interface,
- const std::string& property)
+static auto getProperty(const std::string& busName, const std::string& path,
+ const std::string& interface,
+ const std::string& property)
{
- return getProperty<Property>(
- getBus(),
- busName,
- path,
- interface,
- property);
+ return getProperty<Property>(getBus(), busName, path, interface, property);
}
/** @brief Get a property with mapper lookup. */
template <typename Property>
-static auto getProperty(
- ::sdbusplus::bus::bus& bus,
- const std::string& path,
- const std::string& interface,
- const std::string& property)
+static auto getProperty(::sdbusplus::bus::bus& bus, const std::string& path,
+ const std::string& interface,
+ const std::string& property)
{
- return getProperty<Property>(
- bus,
- getService(bus, path, interface),
- path,
- interface,
- property);
+ return getProperty<Property>(bus, getService(bus, path, interface), path,
+ interface, property);
}
/** @brief Get a property with mapper lookup. */
template <typename Property>
-static auto getProperty(
- const std::string& path,
- const std::string& interface,
- const std::string& property)
+static auto getProperty(const std::string& path, const std::string& interface,
+ const std::string& property)
{
- return getProperty<Property>(
- getBus(),
- path,
- interface,
- property);
+ return getProperty<Property>(getBus(), path, interface, property);
}
} // namespace sdbusplus
diff --git a/mslverify/verify.cpp b/mslverify/verify.cpp
index 1595166..c9c06aa 100644
--- a/mslverify/verify.cpp
+++ b/mslverify/verify.cpp
@@ -21,13 +21,13 @@
using namespace std::literals::string_literals;
-template <typename T>
-struct BusMeetsMSL
+template <typename T> struct BusMeetsMSL
{
std::string path;
- BusMeetsMSL(const std::string& p)
- :path(p) {}
+ BusMeetsMSL(const std::string& p) : path(p)
+ {
+ }
auto operator()(const T& arg)
{
@@ -36,16 +36,14 @@ struct BusMeetsMSL
const auto& busName = arg.first;
return util::sdbusplus::getProperty<bool>(
- busName,
- path,
- "xyz.openbmc_project.Inventory."
- "Decorator.MeetsMinimumShipLevel"s,
- "MeetsMinimumShipLevel"s);
+ busName, path,
+ "xyz.openbmc_project.Inventory."
+ "Decorator.MeetsMinimumShipLevel"s,
+ "MeetsMinimumShipLevel"s);
}
};
-template <typename T>
-struct PathMeetsMSL
+template <typename T> struct PathMeetsMSL
{
auto operator()(const T& arg)
{
@@ -55,19 +53,17 @@ struct PathMeetsMSL
const auto& path = arg.first;
return std::all_of(
- arg.second.begin(),
- arg.second.end(),
- BusMeetsMSL<typename decltype(arg.second)::value_type>(path));
+ arg.second.begin(), arg.second.end(),
+ BusMeetsMSL<typename decltype(arg.second)::value_type>(path));
}
};
int main(void)
{
- auto mslVerificationRequired =
- util::sdbusplus::getProperty<bool>(
- "/xyz/openbmc_project/control/minimum_ship_level_required"s,
- "xyz.openbmc_project.Control.MinimumShipLevel"s,
- "MinimumShipLevelRequired"s);
+ auto mslVerificationRequired = util::sdbusplus::getProperty<bool>(
+ "/xyz/openbmc_project/control/minimum_ship_level_required"s,
+ "xyz.openbmc_project.Control.MinimumShipLevel"s,
+ "MinimumShipLevelRequired"s);
if (!mslVerificationRequired)
{
@@ -80,32 +76,23 @@ int main(void)
// the minimum ship level has been met.
using SubTreeType =
- std::map<
- std::string,
- std::map<std::string, std::vector<std::string>>>;
-
- auto subtree =
- util::sdbusplus::callMethodAndRead<SubTreeType>(
- "xyz.openbmc_project.ObjectMapper"s,
- "/xyz/openbmc_project/object_mapper"s,
- "xyz.openbmc_project.ObjectMapper"s,
- "GetSubTree"s,
- "/"s,
- 0,
- std::vector<std::string>{
- "xyz.openbmc_project.Inventory"
- ".Decorator.MeetsMinimumShipLevel"s});
-
- auto result = std::all_of(
- subtree.begin(),
- subtree.end(),
- PathMeetsMSL<SubTreeType::value_type>());
+ std::map<std::string, std::map<std::string, std::vector<std::string>>>;
+
+ auto subtree = util::sdbusplus::callMethodAndRead<SubTreeType>(
+ "xyz.openbmc_project.ObjectMapper"s,
+ "/xyz/openbmc_project/object_mapper"s,
+ "xyz.openbmc_project.ObjectMapper"s, "GetSubTree"s, "/"s, 0,
+ std::vector<std::string>{"xyz.openbmc_project.Inventory"
+ ".Decorator.MeetsMinimumShipLevel"s});
+
+ auto result = std::all_of(subtree.begin(), subtree.end(),
+ PathMeetsMSL<SubTreeType::value_type>());
if (!result)
{
phosphor::logging::log<phosphor::logging::level::INFO>(
- "The physical system configuration does not "
- "satisfy the minimum ship level.");
+ "The physical system configuration does not "
+ "satisfy the minimum ship level.");
return 1;
}
OpenPOWER on IntegriCloud