Add virtual functions to ManagedObjectStore and remove production unit test downcasts. Google-Bug-Id:513334516 PiperOrigin-RevId: 978134077 Change-Id: I31bb4b2435efc24d60489ebf6fd3c1649580461a
diff --git a/g3/managed_store.hpp b/g3/managed_store.hpp index 816873c..534127d 100644 --- a/g3/managed_store.hpp +++ b/g3/managed_store.hpp
@@ -33,6 +33,7 @@ #include "boost/asio/error.hpp" #include "boost/asio/io_context.hpp" #include "boost/asio/posix/basic_stream_descriptor.hpp" +#include "boost/asio/post.hpp" // NOLINT #include "boost/asio/steady_timer.hpp" #include "boost/container/flat_map.hpp" // NOLINT(readability/boost) #include "boost/system/error_code.hpp" @@ -285,8 +286,8 @@ system_bus_->async_method_call( std::forward<decltype(callback)>(callback), service, path, "org.freedesktop.DBus.Properties", "Set", interface, propertyName, - std::variant<std::decay_t<decltype(propertyValue)>>( - std::forward<decltype(propertyValue)>(propertyValue))); + std::variant<std::decay_t<PropertyType>>( + std::forward<PropertyType>(propertyValue))); }); } @@ -311,6 +312,7 @@ }); } + // SignCSR in google_service_root.h virtual void PostDbusCallWithObjectPathAndTwoStrings( [[maybe_unused]] const std::shared_ptr<boost::asio::io_context::strand>& strand, @@ -329,6 +331,7 @@ }); } + // executeRootOfTrustCommand in google_service_root.h virtual void PostDbusCallWithObjectPath( [[maybe_unused]] const std::shared_ptr<boost::asio::io_context::strand>& strand, @@ -345,6 +348,7 @@ }); } + // nvmeMetricFetcher returning unix_fd in nvme_metric_utils.h virtual void PostDbusCallWithStringRetMsgAndFd( [[maybe_unused]] const std::shared_ptr<boost::asio::io_context::strand>& strand, @@ -833,8 +837,138 @@ // tests in g3. Please note you should extend this with more mock functions // and only place them after this comment. public: - // Associated with Generic D-Bus Method Call with NO arguments (e.g., used by - // doNMI in systems.h) + using GetAncestorsResponseType = std::array<const char*, 1>; + + using ResolveHostnameCb = absl::AnyInvocable<void( + const boost::system::error_code&, + const std::vector<std::tuple<int32_t, int32_t, std::vector<uint8_t>>>&, + const std::string&, const uint64_t)>; + + using PostCodeEntry = std::tuple<uint64_t, std::vector<uint8_t>>; + + using CreateDumpParamVec = + std::vector<std::pair<std::string, std::variant<std::string, uint64_t>>>; + + using NumericThresholdParams = + std::tuple<std::string, uint64_t, std::string, double>; + + using SPDMGetSignedMeasurmentsCb = absl::AnyInvocable<void( + const boost::system::error_code&, const sdbusplus::message::object_path&, + const std::string&, const std::string&, const std::string&, + const std::string&, const std::string&)>; + + using DiscreteThresholdParams = + std::tuple<std::string, std::string, uint64_t, std::string>; + + using TriggerThresholdParamsExt = + std::variant<std::monostate, std::vector<NumericThresholdParams>, + std::vector<DiscreteThresholdParams>>; + + using TriggerSensorsParams = + std::vector<std::pair<sdbusplus::message::object_path, std::string>>; + + using TriggerGetParamsVariant = + std::variant<std::monostate, bool, std::string, TriggerThresholdParamsExt, + TriggerSensorsParams, std::vector<std::string>, + std::vector<sdbusplus::message::object_path>>; + + using TriggerGetAllCb = absl::AnyInvocable<void( + const boost::system::error_code&, + const std::vector<std::pair<std::string, TriggerGetParamsVariant>>&)>; + + using PostPackageRepairStatusParam = + std::vector<std::tuple<uint16_t, uint16_t, uint16_t, uint16_t, + std::vector<uint16_t>>>; + + using ReadingParameters = + std::vector<std::tuple<sdbusplus::message::object_path, std::string, + std::string, std::string>>; + + // setProperty in storage_utils.h, log_services.cc + virtual void setProperty(const std::string& service, const std::string& path, + const std::string& interface, + const std::string& propertyName, + const std::string& propertyValue, + SetPropertyCb&& callback) { + boost::asio::post( + io_context_main_thread_, + [this, service, path, interface, propertyName, propertyValue, + callback(std::forward<SetPropertyCb>(callback))]() mutable { + system_bus_->async_method_call( + std::forward<decltype(callback)>(callback), service, path, + "org.freedesktop.DBus.Properties", "Set", interface, propertyName, + std::variant<std::string>(propertyValue)); + }); + } + + // setProperty (bool) in storage.h (e.g., setCustomSSDOemGpio) + virtual void setProperty(const std::string& service, const std::string& path, + const std::string& interface, + const std::string& propertyName, bool propertyValue, + SetPropertyCb&& callback) { + boost::asio::post( + io_context_main_thread_, + [this, service, path, interface, propertyName, propertyValue, + callback(std::forward<SetPropertyCb>(callback))]() mutable { + system_bus_->async_method_call( + std::forward<decltype(callback)>(callback), service, path, + "org.freedesktop.DBus.Properties", "Set", interface, propertyName, + std::variant<bool>(propertyValue)); + }); + } + + // setProperty (uint32_t) in storage_utils.h, sensors.h + virtual void setProperty(const std::string& service, const std::string& path, + const std::string& interface, + const std::string& propertyName, + uint32_t propertyValue, SetPropertyCb&& callback) { + boost::asio::post( + io_context_main_thread_, + [this, service, path, interface, propertyName, propertyValue, + callback(std::forward<SetPropertyCb>(callback))]() mutable { + system_bus_->async_method_call( + std::forward<decltype(callback)>(callback), service, path, + "org.freedesktop.DBus.Properties", "Set", interface, propertyName, + std::variant<uint32_t>(propertyValue)); + }); + } + + // setProperty (double) in sensors.h + virtual void setProperty(const std::string& service, const std::string& path, + const std::string& interface, + const std::string& propertyName, + double propertyValue, SetPropertyCb&& callback) { + boost::asio::post( + io_context_main_thread_, + [this, service, path, interface, propertyName, propertyValue, + callback(std::forward<SetPropertyCb>(callback))]() mutable { + system_bus_->async_method_call( + std::forward<decltype(callback)>(callback), service, path, + "org.freedesktop.DBus.Properties", "Set", interface, propertyName, + std::variant<double>(propertyValue)); + }); + } + + // setProperty (DbusVariantType) in systems.h, chassis.h, managers.h + virtual void setProperty(const std::string& service, const std::string& path, + const std::string& interface, + const std::string& propertyName, + dbus::utility::DbusVariantType&& propertyValue, + SetPropertyCb&& callback) { + boost::asio::post( + io_context_main_thread_, + [this, service, path, interface, propertyName, + propertyValue(std::move(propertyValue)), + callback(std::forward<SetPropertyCb>(callback))]() mutable { + system_bus_->async_method_call( + std::forward<decltype(callback)>(callback), service, path, + "org.freedesktop.DBus.Properties", "Set", interface, propertyName, + std::move(propertyValue)); + }); + } + + // Generic D-Bus call with no arguments (e.g., doNMI in systems.h, + // resetChassis in chassis.h) virtual void PostDbusCallToIoContextThreadSafe( [[maybe_unused]] const std::shared_ptr<boost::asio::io_context::strand>& strand, @@ -849,111 +983,290 @@ }); } - // Associated with D-Bus Property Set operation - // (org.freedesktop.DBus.Properties.Set) (e.g., used by setBootType, - // sendPowerSystemCommand in systems.h) - virtual void PostDbusCallToIoContextThreadSafe( - [[maybe_unused]] const std::shared_ptr<boost::asio::io_context::strand>& - strand, - absl::AnyInvocable<void(const boost::system::error_code&)>&& callback, - const std::string& service, const std::string& objpath, - const std::string& interf, const std::string& set, - const std::string& set_interf, const std::string& property_name, - dbus::utility::DbusVariantType&& prop_value) { - boost::asio::post(io_context_main_thread_, - [this, callback(std::move(callback)), service, objpath, - interf, set, set_interf, property_name, - prop_value(std::move(prop_value))]() mutable { - system_bus_->async_method_call( - std::move(callback), service, objpath, interf, set, - set_interf, property_name, std::move(prop_value)); - }); - } - - // Associated with Generic D-Bus Method Call with ONE object_path and TWO - // string arguments + // Introspect in openbmc_dbus_rest.h, log_services.cc virtual void PostDbusCallToIoContextThreadSafe( [[maybe_unused]] const std::shared_ptr<boost::asio::io_context::strand>& strand, absl::AnyInvocable<void(const boost::system::error_code&, - const std::vector<uint8_t>&)>&& callback, + const std::string&)>&& callback, const std::string& service, const std::string& objpath, - const std::string& interface, const std::string& method, - const sdbusplus::message::object_path& arg1, const std::string& arg2, - const std::string& arg3) { - boost::asio::post(io_context_main_thread_, - [this, callback(std::move(callback)), service, objpath, - interface, method, arg1, arg2, arg3]() mutable { - system_bus_->async_method_call( - std::move(callback), service, objpath, interface, - method, arg1, arg2, arg3); - }); + const std::string& interface, const std::string& method) { + boost::asio::post( + io_context_main_thread_, [this, callback(std::move(callback)), service, + objpath, interface, method]() mutable { + system_bus_->async_method_call(std::move(callback), service, objpath, + interface, method); + }); } - // Associated with LockdownInband D-Bus Method Call (e.g., used by - // lockdownInband in google_service_nvme.h) + // Introspect with interfaces in openbmc_dbus_rest.h virtual void PostDbusCallToIoContextThreadSafe( [[maybe_unused]] const std::shared_ptr<boost::asio::io_context::strand>& strand, - absl::AnyInvocable<void( - const boost::system::error_code&, const sdbusplus::message_t& msg, - const std::tuple<uint32_t, uint32_t, uint32_t, std::string, - uint32_t>&)>&& callback, + absl::AnyInvocable<void(const boost::system::error_code&, + const std::string&)>&& callback, const std::string& service, const std::string& objpath, const std::string& interface, const std::string& method, - const uint8_t prohibit, const std::vector<uint8_t>& admin_cmds, - const std::vector<uint8_t>& features, - const std::vector<uint8_t>& log_pages) { + const std::string& object, const std::vector<std::string>& interfaces) { boost::asio::post( io_context_main_thread_, [this, callback(std::move(callback)), service, objpath, interface, - method, prohibit, admin_cmds(std::move(admin_cmds)), - features(std::move(features)), - log_pages(std::move(log_pages))]() mutable { - system_bus_->async_method_call( - std::move(callback), service, objpath, interface, method, - prohibit, std::move(admin_cmds), std::move(features), - std::move(log_pages)); + method, object, interfaces(std::move(interfaces))]() mutable { + system_bus_->async_method_call(std::move(callback), service, objpath, + interface, method, object, + std::move(interfaces)); }); } - // Associated with GetFeature D-Bus Method Call (e.g., used by GetFeature in - // nvme_features.h) + // ListNames in openbmc_dbus_rest.h virtual void PostDbusCallToIoContextThreadSafe( [[maybe_unused]] const std::shared_ptr<boost::asio::io_context::strand>& strand, absl::AnyInvocable<void(const boost::system::error_code&, - const sdbusplus::message_t&, - const std::vector<uint8_t>&)>&& callback, + std::vector<std::string>&)>&& callback, const std::string& service, const std::string& objpath, - const std::string& interface, const std::string& method, - const std::string& arg) { + const std::string& interface, const std::string& method) { boost::asio::post( io_context_main_thread_, [this, callback(std::move(callback)), service, - objpath, interface, method, arg]() mutable { + objpath, interface, method]() mutable { system_bus_->async_method_call(std::move(callback), service, objpath, - interface, method, arg); + interface, method); }); } - // Associated with Generic D-Bus Method Call with ONE uint16_t argument (e.g., - // used by PLDMd reload file and sync cache for VMTPPR in bios.h) + + // ListNames with interfaces in openbmc_dbus_rest.h + virtual void PostDbusCallToIoContextThreadSafe( + [[maybe_unused]] const std::shared_ptr<boost::asio::io_context::strand>& + strand, + absl::AnyInvocable<void(const boost::system::error_code&, + const std::vector<std::string>&)>&& callback, + const std::string& service, const std::string& objpath, + const std::string& interface, const std::string& method, + const std::string& object, const std::vector<std::string>& interfaces) { + boost::asio::post( + io_context_main_thread_, + [this, callback(std::move(callback)), service, objpath, interface, + method, object, interfaces(std::move(interfaces))]() mutable { + system_bus_->async_method_call(std::move(callback), service, objpath, + interface, method, object, + std::move(interfaces)); + }); + } + + // GetObject in storage_utils.h, certificate_service.h + virtual void PostDbusCallToIoContextThreadSafe( + [[maybe_unused]] const std::shared_ptr<boost::asio::io_context::strand>& + strand, + absl::AnyInvocable<void(const boost::system::error_code&, + const dbus::utility::MapperGetObject&)>&& + callback, + const std::string& service, const std::string& objpath, + const std::string& interface, const std::string& method, + const std::string& path, const std::vector<std::string>& interfaces) { + boost::asio::post(io_context_main_thread_, + [this, callback(std::move(callback)), service, objpath, + interface, method, path, interfaces]() mutable { + system_bus_->async_method_call( + std::move(callback), service, objpath, interface, + method, path, interfaces); + }); + } + + // GetAssociatedSubTree in storage_utils.h + virtual void PostDbusCallToIoContextThreadSafe( + [[maybe_unused]] const std::shared_ptr<boost::asio::io_context::strand>& + strand, + absl::AnyInvocable<void(const boost::system::error_code&, + const dbus::utility::MapperGetSubTreeResponse&)>&& + callback, + const std::string& service, const std::string& objpath, + const std::string& interface, const std::string& method, + const sdbusplus::message::object_path& associatedPath, + const sdbusplus::message::object_path& path, int32_t depth, + const std::vector<std::string>& interfaces) { + boost::asio::post( + io_context_main_thread_, + [this, callback(std::move(callback)), service, objpath, interface, + method, associatedPath, path, depth, interfaces]() mutable { + system_bus_->async_method_call(std::move(callback), service, objpath, + interface, method, associatedPath, + path, depth, interfaces); + }); + } + + // GetAssociatedSubTreePaths in storage_utils.h + virtual void PostDbusCallToIoContextThreadSafe( + [[maybe_unused]] const std::shared_ptr<boost::asio::io_context::strand>& + strand, + absl::AnyInvocable< + void(const boost::system::error_code&, + const dbus::utility::MapperGetSubTreePathsResponse&)>&& callback, + const std::string& service, const std::string& objpath, + const std::string& interface, const std::string& method, + const sdbusplus::message::object_path& associatedPath, + const sdbusplus::message::object_path& path, int32_t depth, + const std::vector<std::string>& interfaces) { + boost::asio::post( + io_context_main_thread_, + [this, callback(std::move(callback)), service, objpath, interface, + method, associatedPath, path, depth, interfaces]() mutable { + system_bus_->async_method_call(std::move(callback), service, objpath, + interface, method, associatedPath, + path, depth, interfaces); + }); + } + + // GetAncestors in log_services.cc, storage_utils.h + virtual void PostDbusCallToIoContextThreadSafe( + [[maybe_unused]] const std::shared_ptr<boost::asio::io_context::strand>& + strand, + absl::AnyInvocable< + void(const boost::system::error_code&, + const dbus::utility::MapperGetAncestorsResponse&)>&& callback, + const std::string& service, const std::string& objpath, + const std::string& interface, const std::string& method, + const std::string& obj_name, const GetAncestorsResponseType& interfaces) { + boost::asio::post(io_context_main_thread_, + [this, callback(std::move(callback)), service, objpath, + interface, method, obj_name, interfaces]() mutable { + system_bus_->async_method_call( + std::move(callback), service, objpath, interface, + method, obj_name, interfaces); + }); + } + + // RestartUnit / StartUnit / StopUnit from systemd in log_services.cc, + // network_protocol.h virtual void PostDbusCallToIoContextThreadSafe( [[maybe_unused]] const std::shared_ptr<boost::asio::io_context::strand>& strand, absl::AnyInvocable<void(const boost::system::error_code&)>&& callback, const std::string& service, const std::string& objpath, const std::string& interface, const std::string& method, - uint16_t file_handle) { + const std::string& service_name, const std::string& command) { boost::asio::post(io_context_main_thread_, [this, callback(std::move(callback)), service, objpath, - interface, method, file_handle]() mutable { + interface, method, service_name, command]() mutable { system_bus_->async_method_call( std::move(callback), service, objpath, interface, - method, file_handle); + method, service_name, command); }); } - using PostCodeEntry = std::tuple<uint64_t, std::vector<uint8_t>>; + // getProperty (org.freedesktop.DBus.Properties.Get) in storage_utils.h + virtual void PostDbusCallToIoContextThreadSafe( + [[maybe_unused]] const std::shared_ptr<boost::asio::io_context::strand>& + strand, + absl::AnyInvocable<void(const boost::system::error_code&, + const dbus::utility::DbusVariantType&)>&& + callback, + const std::string& service, const std::string& objpath, + const std::string& interface, const std::string& get, + const std::string& get_interf, const std::string& property) { + boost::asio::post(io_context_main_thread_, + [this, callback(std::move(callback)), service, objpath, + interface, get, get_interf, property]() mutable { + system_bus_->async_method_call( + std::move(callback), service, objpath, interface, + get, get_interf, property); + }); + } + + // setProperty (org.freedesktop.DBus.Properties.Set) in systems.h (e.g., + // setBootType, sendPowerSystemCommand) + virtual void PostDbusCallToIoContextThreadSafe( + [[maybe_unused]] const std::shared_ptr<boost::asio::io_context::strand>& + strand, + absl::AnyInvocable<void(const boost::system::error_code&)>&& callback, + const std::string& service, const std::string& objpath, + const std::string& interface, const std::string& set, + const std::string& set_interf, const std::string& property_name, + dbus::utility::DbusVariantType&& property) { + boost::asio::post( + io_context_main_thread_, + [this, callback(std::move(callback)), service, objpath, interface, set, + set_interf, property_name, property(std::move(property))]() mutable { + system_bus_->async_method_call(std::move(callback), service, objpath, + interface, set, set_interf, + property_name, std::move(property)); + }); + } + + // setProperty returning sdbusplus::message_t in power.h, sensors.h + virtual void PostDbusCallToIoContextThreadSafe( + [[maybe_unused]] const std::shared_ptr<boost::asio::io_context::strand>& + strand, + absl::AnyInvocable<void(const boost::system::error_code&, + const sdbusplus::message_t&)>&& callback, + const std::string& service, const std::string& objpath, + const std::string& interface, const std::string& set, + const std::string& set_interf, const std::string& property_name, + dbus::utility::DbusVariantType property) { + boost::asio::post( + io_context_main_thread_, + [this, callback(std::move(callback)), service, objpath, interface, set, + set_interf, property_name, property(std::move(property))]() mutable { + system_bus_->async_method_call(std::move(callback), service, objpath, + interface, set, set_interf, + property_name, std::move(property)); + }); + } + + // asyncResolve in async_resolve.h + virtual void PostDbusCallToIoContextThreadSafe( + [[maybe_unused]] const std::shared_ptr<boost::asio::io_context::strand>& + strand, + ResolveHostnameCb&& callback, const std::string& service, + const std::string& objpath, const std::string& interface, + const std::string& method, int param1, const std::string& param2, + int param3, uint64_t param4) { + boost::asio::post( + io_context_main_thread_, + [this, callback(std::move(callback)), service, objpath, interface, + method, param1, param2, param3, param4]() mutable { + system_bus_->async_method_call(std::move(callback), service, objpath, + interface, method, param1, param2, + param3, param4); + }); + } + + // createVLAN in ethernet.h + virtual void PostDbusCallToIoContextThreadSafe( + [[maybe_unused]] const std::shared_ptr<boost::asio::io_context::strand>& + strand, + absl::AnyInvocable<void(const boost::system::error_code&)>&& callback, + const std::string& service, const std::string& objpath, + const std::string& interface, const std::string& method, + const std::string& param1, uint32_t param2) { + boost::asio::post(io_context_main_thread_, + [this, callback(std::move(callback)), service, objpath, + interface, method, param1, param2]() mutable { + system_bus_->async_method_call( + std::move(callback), service, objpath, interface, + method, param1, param2); + }); + } + + // createIPv4 / createIPv6 in ethernet.h + virtual void PostDbusCallToIoContextThreadSafe( + [[maybe_unused]] const std::shared_ptr<boost::asio::io_context::strand>& + strand, + absl::AnyInvocable<void(const boost::system::error_code&)>&& callback, + const std::string& service, const std::string& objpath, + const std::string& interface, const std::string& create_ip, + const std::string& protocol, const std::string& address, + uint8_t prefix_length, const std::string& param4) { + boost::asio::post( + io_context_main_thread_, + [this, callback(std::move(callback)), service, objpath, interface, + create_ip, protocol, address, prefix_length, param4]() mutable { + system_bus_->async_method_call(std::move(callback), service, objpath, + interface, create_ip, protocol, + address, prefix_length, param4); + }); + } + + // getPostCodeData (GetPostCodes) in log_services.cc virtual void PostDbusCallToIoContextThreadSafe( [[maybe_unused]] const std::shared_ptr<boost::asio::io_context::strand>& strand, @@ -970,6 +1283,40 @@ get_postcodes, param1); }); } + + // getPostPackageRepairStatus in log_services.cc + virtual void PostDbusCallToIoContextThreadSafe( + [[maybe_unused]] const std::shared_ptr<boost::asio::io_context::strand>& + strand, + absl::AnyInvocable<void(const boost::system::error_code&, + const PostPackageRepairStatusParam&)>&& callback, + const std::string& service, const std::string& objpath, + const std::string& interface, const std::string& method) { + boost::asio::post( + io_context_main_thread_, [this, callback(std::move(callback)), service, + objpath, interface, method]() mutable { + system_bus_->async_method_call(std::move(callback), service, objpath, + interface, method); + }); + } + + // getPostPackageRepairConfig in log_services.cc + virtual void PostDbusCallToIoContextThreadSafe( + [[maybe_unused]] const std::shared_ptr<boost::asio::io_context::strand>& + strand, + absl::AnyInvocable<void(const boost::system::error_code&, + const std::vector<uint16_t>&)>&& callback, + const std::string& service, const std::string& objpath, + const std::string& interface, const std::string& method) { + boost::asio::post( + io_context_main_thread_, [this, callback(std::move(callback)), service, + objpath, interface, method]() mutable { + system_bus_->async_method_call(std::move(callback), service, objpath, + interface, method); + }); + } + + // getPostCodeData (GetPostCodesTS returning flat_map) in log_services.cc virtual void PostDbusCallToIoContextThreadSafe( [[maybe_unused]] const std::shared_ptr<boost::asio::io_context::strand>& strand, @@ -988,7 +1335,80 @@ get_postcodes, param1); }); } - // Associated with GetRawFru in managers.h + + // deleteLogEntry in log_services.cc, certificate_service.h + virtual void PostDbusCallToIoContextThreadSafe( + [[maybe_unused]] const std::shared_ptr<boost::asio::io_context::strand>& + strand, + absl::AnyInvocable<void(const boost::system::error_code&, + const sdbusplus::message_t&)>&& callback, + const std::string& service, const std::string& objpath, + const std::string& interface, const std::string& method) { + boost::asio::post( + io_context_main_thread_, [this, callback(std::move(callback)), service, + objpath, interface, method]() mutable { + system_bus_->async_method_call(std::move(callback), service, objpath, + interface, method); + }); + } + + // getLogEntry in log_services.cc + virtual void PostDbusCallToIoContextThreadSafe( + [[maybe_unused]] const std::shared_ptr<boost::asio::io_context::strand>& + strand, + absl::AnyInvocable<void(const boost::system::error_code&, + const sdbusplus::message::unix_fd&)>&& callback, + const std::string& service, const std::string& objpath, + const std::string& interface, const std::string& get_entry) { + boost::asio::post( + io_context_main_thread_, [this, callback(std::move(callback)), service, + objpath, interface, get_entry]() mutable { + system_bus_->async_method_call(std::move(callback), service, objpath, + interface, get_entry); + }); + } + + // createDump in log_services.cc + virtual void PostDbusCallToIoContextThreadSafe( + [[maybe_unused]] const std::shared_ptr<boost::asio::io_context::strand>& + strand, + absl::AnyInvocable< + void(const boost::system::error_code&, const sdbusplus::message_t&, + const sdbusplus::message::object_path&)>&& callback, + const std::string& service, const std::string& objpath, + const std::string& interface, const std::string& create_dump, + const CreateDumpParamVec& create_dump_param_vec) { + boost::asio::post( + io_context_main_thread_, + [this, callback(std::move(callback)), service, objpath, interface, + create_dump, + create_dump_param_vec(std::move(create_dump_param_vec))]() mutable { + system_bus_->async_method_call(std::move(callback), service, objpath, + interface, create_dump, + std::move(create_dump_param_vec)); + }); + } + + // getUserInfo in user_monitor.h, openbmc_dbus_rest.h + virtual void PostDbusCallToIoContextThreadSafe( + [[maybe_unused]] const std::shared_ptr<boost::asio::io_context::strand>& + strand, + absl::AnyInvocable<void(const boost::system::error_code&, + const dbus::utility::DBusPropertiesMap&)>&& + callback, + const std::string& service, const std::string& objpath, + const std::string& interface, const std::string& get_user_info, + const std::string& username) { + boost::asio::post(io_context_main_thread_, + [this, callback(std::move(callback)), service, objpath, + interface, get_user_info, username]() mutable { + system_bus_->async_method_call( + std::move(callback), service, objpath, interface, + get_user_info, username); + }); + } + + // readFruData in managers.h virtual void PostDbusCallToIoContextThreadSafe( [[maybe_unused]] const std::shared_ptr<boost::asio::io_context::strand>& strand, @@ -1005,6 +1425,518 @@ method, bus, address); }); } + + // SendHostCommand in google_service_root.h + virtual void PostDbusCallToIoContextThreadSafe( + [[maybe_unused]] const std::shared_ptr<boost::asio::io_context::strand>& + strand, + absl::AnyInvocable<void(const boost::system::error_code&, + const std::vector<uint8_t>&)>&& callback, + const std::string& service, const std::string& objpath, + const std::string& interface, const std::string& send_host_command, + const std::vector<unsigned char>& payload) { + boost::asio::post( + io_context_main_thread_, + [this, callback(std::move(callback)), service, objpath, interface, + send_host_command, payload(std::move(payload))]() mutable { + system_bus_->async_method_call(std::move(callback), service, objpath, + interface, send_host_command, + std::move(payload)); + }); + } + + // GetLogPage in google_service_nvme.h + virtual void PostDbusCallToIoContextThreadSafe( + [[maybe_unused]] const std::shared_ptr<boost::asio::io_context::strand>& + strand, + absl::AnyInvocable<void(const boost::system::error_code&, + const sdbusplus::message::unix_fd&)>&& callback, + const std::string& service, const std::string& objpath, + const std::string& interface, const std::string& get_log_page, + uint8_t lid, uint32_t nsid, uint8_t lsp, uint16_t lsi) { + boost::asio::post(io_context_main_thread_, + [this, callback(std::move(callback)), service, objpath, + interface, get_log_page, lid, nsid, lsp, lsi]() mutable { + system_bus_->async_method_call( + std::move(callback), service, objpath, interface, + get_log_page, lid, nsid, lsp, lsi); + }); + } + + // LockdownInband in google_service_nvme.h + virtual void PostDbusCallToIoContextThreadSafe( + [[maybe_unused]] const std::shared_ptr<boost::asio::io_context::strand>& + strand, + absl::AnyInvocable<void( + const boost::system::error_code&, const sdbusplus::message_t& msg, + const std::tuple<uint32_t, uint32_t, uint32_t, std::string, + uint32_t>&)>&& callback, + const std::string& service, const std::string& objpath, + const std::string& interface, const std::string& lockdown_inband, + const uint8_t prohibit, const std::vector<uint8_t>& admin_cmds, + const std::vector<uint8_t>& features, + const std::vector<uint8_t>& log_pages) { + boost::asio::post( + io_context_main_thread_, + [this, callback(std::move(callback)), service, objpath, interface, + lockdown_inband, prohibit, admin_cmds(std::move(admin_cmds)), + features(std::move(features)), + log_pages(std::move(log_pages))]() mutable { + system_bus_->async_method_call( + std::move(callback), service, objpath, interface, lockdown_inband, + prohibit, std::move(admin_cmds), std::move(features), + std::move(log_pages)); + }); + } + + // Identify in google_service_nvme.h + virtual void PostDbusCallToIoContextThreadSafe( + [[maybe_unused]] const std::shared_ptr<boost::asio::io_context::strand>& + strand, + absl::AnyInvocable<void(const boost::system::error_code&, + const sdbusplus::message::unix_fd&)>&& callback, + const std::string& service, const std::string& objpath, + const std::string& interface, const std::string& identify, uint8_t cns, + uint32_t nsid, uint16_t cntid) { + boost::asio::post(io_context_main_thread_, + [this, callback(std::move(callback)), service, objpath, + interface, identify, cns, nsid, cntid]() mutable { + system_bus_->async_method_call( + std::move(callback), service, objpath, interface, + identify, cns, nsid, cntid); + }); + } + + // executeRde in redfish_aggregator.h + virtual void PostDbusCallToIoContextThreadSafe( + [[maybe_unused]] const std::shared_ptr<boost::asio::io_context::strand>& + strand, + absl::AnyInvocable<void(const boost::system::error_code&, + const std::string&)>&& callback, + const std::string& service, const std::string& objpath, + const std::string& interface, const std::string& execute_rde, int random, + uint8_t id, const std::string& uri, const std::string& udev_id, + const std::string& payload) { + boost::asio::post( + io_context_main_thread_, + [this, callback(std::move(callback)), service, objpath, interface, + execute_rde, random, id, uri, udev_id, payload]() mutable { + system_bus_->async_method_call(std::move(callback), service, objpath, + interface, execute_rde, random, id, + uri, udev_id, payload); + }); + } + + // createStorageVolume in storage.h + virtual void PostDbusCallToIoContextThreadSafe( + [[maybe_unused]] const std::shared_ptr<boost::asio::io_context::strand>& + strand, + absl::AnyInvocable< + void(const boost::system::error_code&, const sdbusplus::message_t&, + const sdbusplus::message::object_path&)>&& callback, + const std::string& service, const std::string& objpath, + const std::string& interface, const std::string& create_volume, + uint64_t size, size_t lba_index, bool metadata_at_end) { + boost::asio::post( + io_context_main_thread_, + [this, callback(std::move(callback)), service, objpath, interface, + create_volume, size, lba_index, metadata_at_end]() mutable { + system_bus_->async_method_call(std::move(callback), service, objpath, + interface, create_volume, size, + lba_index, metadata_at_end); + }); + } + + // storageApplyAttachDetach (AttachVolume/DetachVolume) in storage.h + virtual void PostDbusCallToIoContextThreadSafe( + [[maybe_unused]] const std::shared_ptr<boost::asio::io_context::strand>& + strand, + absl::AnyInvocable<void(const boost::system::error_code&, + const sdbusplus::message_t&)>&& callback, + const std::string& service, const std::string& objpath, + const std::string& interface, const std::string& attach_volume, + const sdbusplus::message::object_path& v) { + boost::asio::post(io_context_main_thread_, + [this, callback(std::move(callback)), service, objpath, + interface, attach_volume, v]() mutable { + system_bus_->async_method_call( + std::move(callback), service, objpath, interface, + attach_volume, v); + }); + } + + // securitySendAction in storage.h + virtual void PostDbusCallToIoContextThreadSafe( + [[maybe_unused]] const std::shared_ptr<boost::asio::io_context::strand>& + strand, + absl::AnyInvocable<void(const boost::system::error_code&, + const sdbusplus::message_t&)>&& callback, + const std::string& service, const std::string& objpath, + const std::string& interface, const std::string& security_send, + uint8_t proto, uint16_t proto_specific, + const std::vector<uint8_t>& data) { + boost::asio::post(io_context_main_thread_, + [this, callback(std::move(callback)), service, objpath, + interface, security_send, proto, proto_specific, + data(std::move(data))]() mutable { + system_bus_->async_method_call( + std::move(callback), service, objpath, interface, + security_send, proto, proto_specific, + std::move(data)); + }); + } + + // securityReceiveAction in storage.h + virtual void PostDbusCallToIoContextThreadSafe( + [[maybe_unused]] const std::shared_ptr<boost::asio::io_context::strand>& + strand, + absl::AnyInvocable<void(const boost::system::error_code&, + const sdbusplus::message_t&, + const std::vector<uint8_t>&)>&& callback, + const std::string& service, const std::string& objpath, + const std::string& interface, const std::string& security_recieve, + uint8_t proto, uint16_t proto_specific, uint32_t transfer_length) { + boost::asio::post( + io_context_main_thread_, + [this, callback(std::move(callback)), service, objpath, interface, + security_recieve, proto, proto_specific, transfer_length]() mutable { + system_bus_->async_method_call(std::move(callback), service, objpath, + interface, security_recieve, proto, + proto_specific, transfer_length); + }); + } + + // eraseDrive in storage.h + virtual void PostDbusCallToIoContextThreadSafe( + [[maybe_unused]] const std::shared_ptr<boost::asio::io_context::strand>& + strand, + absl::AnyInvocable<void(const boost::system::error_code&, + const sdbusplus::message_t&)>&& callback, + const std::string& service, const std::string& objpath, + const std::string& interface, const std::string& drive_erase, + const std::string& action_name) { + boost::asio::post(io_context_main_thread_, + [this, callback(std::move(callback)), service, objpath, + interface, drive_erase, action_name]() mutable { + system_bus_->async_method_call( + std::move(callback), service, objpath, interface, + drive_erase, action_name); + }); + } + + // addObject in managers.h + virtual void PostDbusCallToIoContextThreadSafe( + [[maybe_unused]] const std::shared_ptr<boost::asio::io_context::strand>& + strand, + absl::AnyInvocable<void(const boost::system::error_code&)>&& callback, + const std::string& service, const std::string& objpath, + const std::string& interface, const std::string& add_object, + const dbus::utility::DBusPropertiesMap& output) { + boost::asio::post( + io_context_main_thread_, + [this, callback(std::move(callback)), service, objpath, interface, + add_object, output(std::move(output))]() mutable { + system_bus_->async_method_call(std::move(callback), service, objpath, + interface, add_object, + std::move(output)); + }); + } + + // installCertificate in certificate_service.h + virtual void PostDbusCallToIoContextThreadSafe( + [[maybe_unused]] const std::shared_ptr<boost::asio::io_context::strand>& + strand, + absl::AnyInvocable<void(const boost::system::error_code&, + const std::string&)>&& callback, + const std::string& service, const std::string& objpath, + const std::string& interface, const std::string& install, + const std::string& file_path) { + boost::asio::post(io_context_main_thread_, + [this, callback(std::move(callback)), service, objpath, + interface, install, file_path]() mutable { + system_bus_->async_method_call( + std::move(callback), service, objpath, interface, + install, file_path); + }); + } + + // replaceCertificate in certificate_service.h + virtual void PostDbusCallToIoContextThreadSafe( + [[maybe_unused]] const std::shared_ptr<boost::asio::io_context::strand>& + strand, + absl::AnyInvocable<void(const boost::system::error_code&)>&& callback, + const std::string& service, const std::string& objpath, + const std::string& interface, const std::string& replace, + const std::string& file_path) { + boost::asio::post(io_context_main_thread_, + [this, callback(std::move(callback)), service, objpath, + interface, replace, file_path]() mutable { + system_bus_->async_method_call( + std::move(callback), service, objpath, interface, + replace, file_path); + }); + } + + // getSignedMeasurements (SPDMGetSignedMeasurements) in component_integrity.h + virtual void PostDbusCallToIoContextThreadSafe( + [[maybe_unused]] const std::shared_ptr<boost::asio::io_context::strand>& + strand, + SPDMGetSignedMeasurmentsCb&& callback, const std::string& service, + const std::string& objpath, const std::string& interface, + const std::string& replace, + const std::vector<size_t>& opt_measurement_indexes, + const std::string& opt_nonce, size_t opt_slot_id) { + boost::asio::post( + io_context_main_thread_, + [this, callback(std::move(callback)), service, objpath, interface, + replace, opt_measurement_indexes(std::move(opt_measurement_indexes)), + opt_nonce, opt_slot_id]() mutable { + system_bus_->async_method_call( + std::move(callback), service, objpath, interface, replace, + std::move(opt_measurement_indexes), opt_nonce, opt_slot_id); + }); + } + + // getBootTimeCheckpointLogEntries in log_services.cc + virtual void PostDbusCallToIoContextThreadSafe( + [[maybe_unused]] const std::shared_ptr<boost::asio::io_context::strand>& + strand, + absl::AnyInvocable< + void(const boost::system::error_code&, + const std::vector<std::tuple<std::string, int64_t, int64_t>>&)>&& + callback, + const std::string& service, const std::string& objpath, + const std::string& interface, const std::string& method) { + boost::asio::post( + io_context_main_thread_, [this, callback(std::move(callback)), service, + objpath, interface, method]() mutable { + system_bus_->async_method_call(std::move(callback), service, objpath, + interface, method); + }); + } + + // getBootTimeDurationLogEntries in log_services.cc + virtual void PostDbusCallToIoContextThreadSafe( + [[maybe_unused]] const std::shared_ptr<boost::asio::io_context::strand>& + strand, + absl::AnyInvocable<void( + const boost::system::error_code&, + const std::vector<std::tuple<std::string, int64_t>>&)>&& callback, + const std::string& service, const std::string& objpath, + const std::string& interface, const std::string& method) { + boost::asio::post( + io_context_main_thread_, [this, callback(std::move(callback)), service, + objpath, interface, method]() mutable { + system_bus_->async_method_call(std::move(callback), service, objpath, + interface, method); + }); + } + + // PLDMd reload file and sync cache for VMTPPR in bios.h + virtual void PostDbusCallToIoContextThreadSafe( + [[maybe_unused]] const std::shared_ptr<boost::asio::io_context::strand>& + strand, + absl::AnyInvocable<void(const boost::system::error_code&)>&& callback, + const std::string& service, const std::string& objpath, + const std::string& interface, const std::string& method, + uint16_t file_handle) { + boost::asio::post(io_context_main_thread_, + [this, callback(std::move(callback)), service, objpath, + interface, method, file_handle]() mutable { + system_bus_->async_method_call( + std::move(callback), service, objpath, interface, + method, file_handle); + }); + } + + // GetAll in trigger.h, telemetry_service.h + virtual void PostDbusCallToIoContextThreadSafe( + [[maybe_unused]] const std::shared_ptr<boost::asio::io_context::strand>& + strand, + TriggerGetAllCb&& callback, const std::string& service, + const std::string& objpath, const std::string& interface, + const std::string& get_all, const std::string& target_interface) { + boost::asio::post(io_context_main_thread_, + [this, callback(std::move(callback)), service, objpath, + interface, get_all, target_interface]() mutable { + system_bus_->async_method_call( + std::move(callback), service, objpath, interface, + get_all, target_interface); + }); + } + + // setPostPackageRepairConfig in log_services.cc + virtual void PostDbusCallToIoContextThreadSafe( + [[maybe_unused]] const std::shared_ptr<boost::asio::io_context::strand>& + strand, + absl::AnyInvocable<void(const boost::system::error_code&, const bool&)>&& + callback, + const std::string& service, const std::string& objpath, + const std::string& interface, const std::string& method, + const std::uint16_t& flag, const bool& data) { + boost::asio::post(io_context_main_thread_, + [this, callback(std::move(callback)), service, objpath, + interface, method, flag, data]() mutable { + system_bus_->async_method_call( + std::move(callback), service, objpath, interface, + method, flag, data); + }); + } + + // setPostPackageRepairData in log_services.cc + virtual void PostDbusCallToIoContextThreadSafe( + [[maybe_unused]] const std::shared_ptr<boost::asio::io_context::strand>& + strand, + absl::AnyInvocable<void(const boost::system::error_code&, const bool&)>&& + callback, + const std::string& service, const std::string& objpath, + const std::string& interface, const std::string& method, + const uint16_t repairEntryNum, const uint16_t repairType, + const uint16_t socNum, const std::vector<uint16_t>& payload) { + boost::asio::post(io_context_main_thread_, + [this, callback(std::move(callback)), service, objpath, + interface, method, repairEntryNum, repairType, socNum, + payload(std::move(payload))]() mutable { + system_bus_->async_method_call( + std::move(callback), service, objpath, interface, + method, repairEntryNum, repairType, socNum, + std::move(payload)); + }); + } + + // startRuntimeRepair in log_services.cc + virtual void PostDbusCallToIoContextThreadSafe( + [[maybe_unused]] const std::shared_ptr<boost::asio::io_context::strand>& + strand, + absl::AnyInvocable<void(const boost::system::error_code&, + const uint32_t&)>&& callback, + const std::string& service, const std::string& objpath, + const std::string& interface, const std::string& method, + const uint16_t Index) { + boost::asio::post( + io_context_main_thread_, [this, callback(std::move(callback)), service, + objpath, interface, method, Index]() mutable { + system_bus_->async_method_call(std::move(callback), service, objpath, + interface, method, Index); + }); + } + + // nvmeMetricFetcher returning unix_fd in nvme_metric_utils.h + virtual void PostDbusCallToIoContextThreadSafe( + [[maybe_unused]] const std::shared_ptr<boost::asio::io_context::strand>& + strand, + absl::AnyInvocable<void(const boost::system::error_code&, + const sdbusplus::message::unix_fd&)>&& callback, + const std::string& service, const std::string& objpath, + const std::string& interface, const std::string& method, + const std::string& arg) { + boost::asio::post( + io_context_main_thread_, [this, callback(std::move(callback)), service, + objpath, interface, method, arg]() mutable { + system_bus_->async_method_call(std::move(callback), service, objpath, + interface, method, arg); + }); + } + + // nvmeMetricFetcher returning message_t and unix_fd in nvme_metric_utils.h + virtual void PostDbusCallToIoContextThreadSafe( + [[maybe_unused]] const std::shared_ptr<boost::asio::io_context::strand>& + strand, + absl::AnyInvocable<void(const boost::system::error_code&, + const sdbusplus::message_t& msg, + const sdbusplus::message::unix_fd&)>&& callback, + const std::string& service, const std::string& objpath, + const std::string& interface, const std::string& method, + const std::string& arg) { + boost::asio::post( + io_context_main_thread_, [this, callback(std::move(callback)), service, + objpath, interface, method, arg]() mutable { + system_bus_->async_method_call(std::move(callback), service, objpath, + interface, method, arg); + }); + } + + // GetFeature in nvme_features.h + virtual void PostDbusCallToIoContextThreadSafe( + [[maybe_unused]] const std::shared_ptr<boost::asio::io_context::strand>& + strand, + absl::AnyInvocable<void(const boost::system::error_code&, + const sdbusplus::message_t&, + const std::vector<uint8_t>&)>&& callback, + const std::string& service, const std::string& objpath, + const std::string& interface, const std::string& method, + const std::string& arg) { + boost::asio::post( + io_context_main_thread_, [this, callback(std::move(callback)), service, + objpath, interface, method, arg]() mutable { + system_bus_->async_method_call(std::move(callback), service, objpath, + interface, method, arg); + }); + } + + // SetFeature in nvme_features.h + virtual void PostDbusCallToIoContextThreadSafe( + [[maybe_unused]] const std::shared_ptr<boost::asio::io_context::strand>& + strand, + absl::AnyInvocable<void(const boost::system::error_code&, + const sdbusplus::message_t&)>&& callback, + const std::string& service, const std::string& objpath, + const std::string& interface, const std::string& method, + const std::string& feature_name, const std::vector<uint8_t>& payload) { + boost::asio::post(io_context_main_thread_, + [this, callback(std::move(callback)), service, objpath, + interface, method, feature_name, payload]() mutable { + system_bus_->async_method_call( + std::move(callback), service, objpath, interface, + method, feature_name, payload); + }); + } + + // AddReport in metric_report_definition.h + virtual void PostDbusCallToIoContextThreadSafe( + [[maybe_unused]] const std::shared_ptr<boost::asio::io_context::strand>& + strand, + absl::AnyInvocable<void(const boost::system::error_code&, + const std::string&)>&& callback, + const std::string& service, const std::string& objpath, + const std::string& interface, const std::string& method, + const std::string& report_id, const std::string& reporting_type, + bool emits_readings_update, bool log_to_metric_reports_collection, + uint64_t interval, const ReadingParameters& reading_parameters) { + boost::asio::post( + io_context_main_thread_, + [this, callback(std::move(callback)), service, objpath, interface, + method, report_id, reporting_type, emits_readings_update, + log_to_metric_reports_collection, interval, + reading_parameters]() mutable { + system_bus_->async_method_call( + std::move(callback), service, objpath, interface, method, + report_id, reporting_type, emits_readings_update, + log_to_metric_reports_collection, interval, reading_parameters); + }); + } + + // SignCSR in google_service_root.h + virtual void PostDbusCallToIoContextThreadSafe( + [[maybe_unused]] const std::shared_ptr<boost::asio::io_context::strand>& + strand, + absl::AnyInvocable< + void(const boost::system::error_code&, const std::string&, + const std::string&, const std::string&, const std::string&, + const std::string&, const std::string&)>&& callback, + const std::string& service, const std::string& objpath, + const std::string& interface, const std::string& method, + const std::string& arg1, const std::string& arg2, + const std::string& arg3) { + boost::asio::post(io_context_main_thread_, + [this, callback(std::move(callback)), service, objpath, + interface, method, arg1, arg2, arg3]() mutable { + system_bus_->async_method_call( + std::move(callback), service, objpath, interface, + method, arg1, arg2, arg3); + }); + } + #endif };
diff --git a/http/http_response.cpp b/http/http_response.cpp index daac020..1c5be0a 100644 --- a/http/http_response.cpp +++ b/http/http_response.cpp
@@ -14,10 +14,6 @@ #include <nlohmann/json.hpp> #include "managed_store.hpp" -#ifdef UNIT_TEST_BUILD -#include "test/g3/mock_managed_store.hpp" // NOLINT -#endif - namespace crow { Response& Response::operator=(Response&& r) noexcept {
diff --git a/include/google/google_service_root.hpp b/include/google/google_service_root.hpp index 2033710..e26f6a0 100644 --- a/include/google/google_service_root.hpp +++ b/include/google/google_service_root.hpp
@@ -38,10 +38,6 @@ #include "sdbusplus/message/native_types.hpp" #include "sdbusplus/unpack_properties.hpp" #include <openssl/evp.h> -#ifdef UNIT_TEST_BUILD -#include "test/g3/mock_managed_store.hpp" // NOLINT -#endif - namespace crow { namespace google_api {
diff --git a/include/hostname_monitor.hpp b/include/hostname_monitor.hpp index 5650f86..dd4fb23 100644 --- a/include/hostname_monitor.hpp +++ b/include/hostname_monitor.hpp
@@ -23,10 +23,6 @@ #include "sdbusplus/bus/match.hpp" #include "sdbusplus/message.hpp" -#ifdef UNIT_TEST_BUILD -#include "test/g3/mock_managed_store.hpp" // NOLINT -#endif - namespace crow { namespace hostname_monitor { // NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
diff --git a/include/image_upload.hpp b/include/image_upload.hpp index 954cea3..f7a0de3 100644 --- a/include/image_upload.hpp +++ b/include/image_upload.hpp
@@ -21,10 +21,6 @@ #include "sdbusplus/message.hpp" #include "sdbusplus/message/native_types.hpp" -#ifdef UNIT_TEST_BUILD -#include "test/g3/mock_managed_store.hpp" // NOLINT -#endif - namespace crow { namespace image_upload {
diff --git a/include/openbmc_dbus_rest.hpp b/include/openbmc_dbus_rest.hpp index 9e901a3..e1f4573 100644 --- a/include/openbmc_dbus_rest.hpp +++ b/include/openbmc_dbus_rest.hpp
@@ -62,10 +62,6 @@ #include "sdbusplus/message.hpp" #include "sdbusplus/message/native_types.hpp" -#ifdef UNIT_TEST_BUILD -#include "test/g3/mock_managed_store.hpp" // NOLINT -#endif - // IWYU pragma: no_include <boost/algorithm/string/detail/classification.hpp> // IWYU pragma: no_include <boost/system/detail/error_code.hpp> // IWYU pragma: no_include <boost/system/detail/error_category.hpp>
diff --git a/include/user_monitor.hpp b/include/user_monitor.hpp index 06f020d..fd3afd8 100644 --- a/include/user_monitor.hpp +++ b/include/user_monitor.hpp
@@ -9,10 +9,6 @@ #include "sdbusplus/message.hpp" #include "sdbusplus/message/native_types.hpp" -#ifdef UNIT_TEST_BUILD -#include "test/g3/mock_managed_store.hpp" // NOLINT -#endif - namespace bmcweb { inline void onUserRemoved(sdbusplus::message_t& msg) {
diff --git a/redfish-core/include/query.cpp b/redfish-core/include/query.cpp index fcb685f..d4a12a9 100644 --- a/redfish-core/include/query.cpp +++ b/redfish-core/include/query.cpp
@@ -35,10 +35,6 @@ #include "redfish_aggregator.hpp" // NOLINT #include <nlohmann/json.hpp> -#ifdef UNIT_TEST_BUILD -#include "test/g3/mock_managed_store.hpp" // NOLINT -#endif - namespace redfish { namespace query_param {
diff --git a/redfish-core/include/redfish_aggregator.hpp b/redfish-core/include/redfish_aggregator.hpp index ba8bd08..5551422 100644 --- a/redfish-core/include/redfish_aggregator.hpp +++ b/redfish-core/include/redfish_aggregator.hpp
@@ -35,10 +35,6 @@ #include "managed_store.hpp" #include "managed_store_types.hpp" -#ifdef UNIT_TEST_BUILD -#include "test/g3/mock_managed_store.hpp" // NOLINT -#endif - namespace redfish { constexpr unsigned int aggregatorReadBodyLimit = 50 * 1024 * 1024; // 50MB
diff --git a/redfish-core/include/utils/fan_utils.hpp b/redfish-core/include/utils/fan_utils.hpp index 3113959..de1e4f8 100644 --- a/redfish-core/include/utils/fan_utils.hpp +++ b/redfish-core/include/utils/fan_utils.hpp
@@ -19,10 +19,6 @@ #include "managed_store_types.hpp" #include "sdbusplus/message/native_types.hpp" -#ifdef UNIT_TEST_BUILD -#include "test/g3/mock_managed_store.hpp" // NOLINT -#endif - namespace redfish { namespace fan_utils {
diff --git a/redfish-core/include/utils/nvme_metric_utils.hpp b/redfish-core/include/utils/nvme_metric_utils.hpp index 4ca08ba..e5c9176 100644 --- a/redfish-core/include/utils/nvme_metric_utils.hpp +++ b/redfish-core/include/utils/nvme_metric_utils.hpp
@@ -20,6 +20,7 @@ #include <vector> #include "absl/container/flat_hash_set.h" +#include "absl/functional/any_invocable.h" #include "absl/time/clock.h" #include "absl/time/time.h" #include "boost/asio/posix/stream_descriptor.hpp" // NOLINT @@ -344,19 +345,19 @@ } // read metric -#ifdef UNIT_TEST_BUILD - dynamic_cast<managedStore::MockSerializedManagedObjectStore*>( - managedStore::GetManagedObjectStore()) - ->PostDbusCallToIoContextThreadSafe( -#else managedStore::GetManagedObjectStore() ->PostDbusCallToIoContextThreadSafe( -#endif asyncResp->strand_, - [asyncResp, service, resourcePath, metricId, cb{std::move(cb)}]( - const boost::system::error_code ec, - const sdbusplus::message_t& msg, - const sdbusplus::message::unix_fd& fd) mutable { + absl::AnyInvocable<void( + const boost::system::error_code&, + const sdbusplus::message_t&, + const sdbusplus::message:: + unix_fd&)>([asyncResp, service, resourcePath, metricId, + cb{std::move(cb)}]( + const boost::system::error_code ec, + const sdbusplus::message_t& msg, + const sdbusplus::message::unix_fd& + fd) mutable { if (ec) { const sd_bus_error* dbusError = msg.get_error(); if (std::string_view( @@ -380,7 +381,7 @@ managedStore::GetManagedObjectStore()->GetIoContext(), dupFd), std::move(cb)); - }, + }), service, resourcePath, INFC, "GetMetric", metricId); }); }
diff --git a/redfish-core/include/utils/storage_utils.hpp b/redfish-core/include/utils/storage_utils.hpp index e5f0511..0da3525 100644 --- a/redfish-core/include/utils/storage_utils.hpp +++ b/redfish-core/include/utils/storage_utils.hpp
@@ -32,20 +32,22 @@ #include <variant> #include <vector> +#include "absl/functional/any_invocable.h" +#include "boost/system/errc.hpp" // NOLINT +#include "boost/system/error_code.hpp" // NOLINT #include "logging.hpp" #include "async_resp.hpp" #include "dbus_utility.hpp" #include "error_messages.hpp" +#ifdef UNIT_TEST_BUILD +#include "dbus_utils.hpp" +#endif #include "location_utils.hpp" #include <nlohmann/json.hpp> #include "managed_store.hpp" #include "managed_store_types.hpp" #include "sdbusplus/message/native_types.hpp" -#ifdef UNIT_TEST_BUILD -#include "test/g3/mock_managed_store.hpp" // NOLINT -#endif - namespace redfish { namespace storage_utils { @@ -190,23 +192,26 @@ #else managedStore::GetManagedObjectStore()->PostDbusCallToIoContextThreadSafe( context.GetStrand(), - [handler = std::move(callback)]( - boost::system::error_code ec, - std::variant<std::monostate, PropertyType>& ret) mutable { - if (ec) { - handler(ec, {}); - return; - } + absl::AnyInvocable<void(const boost::system::error_code&, + const dbus::utility::DbusVariantType&)>( + [handler = std::move(callback)]( + const boost::system::error_code& ec, + const dbus::utility::DbusVariantType& ret) mutable { + if (ec) { + handler(ec, {}); + return; + } - if (PropertyType* value = std::get_if<PropertyType>(&ret)) { - handler(ec, std::move(*value)); - return; - } + if (const PropertyType* value = std::get_if<PropertyType>(&ret)) { + handler(ec, *value); + return; + } - handler(boost::system::errc::make_error_code( - boost::system::errc::invalid_argument), - {}); - }, + handler(boost::system::errc::make_error_code( + boost::system::errc:: + invalid_argument), // NOLINT(misc-include-cleaner) + {}); + }), service, path.str, "org.freedesktop.DBus.Properties", "Get", interface, property); #endif @@ -218,21 +223,17 @@ const managedStore::ManagedObjectStoreContext& context, std::function<void(const boost::system::error_code&, const dbus::utility::DbusVariantType&)>&& callback) { -#ifdef UNIT_TEST_BUILD - dynamic_cast<managedStore::MockSerializedManagedObjectStore*>( - managedStore::GetManagedObjectStore()) - ->PostDbusCallToIoContextThreadSafe( -#else managedStore::GetManagedObjectStore()->PostDbusCallToIoContextThreadSafe( -#endif - context.GetStrand(), + context.GetStrand(), + absl::AnyInvocable<void(const boost::system::error_code&, + const dbus::utility::DbusVariantType&)>( [callback{std::move(callback)}]( const boost::system::error_code& ec, const dbus::utility::DbusVariantType& propertyValue) { callback(ec, propertyValue); - }, - service, path, "org.freedesktop.DBus.Properties", "Get", interface, - property); + }), + service, path.str, "org.freedesktop.DBus.Properties", "Get", interface, + property); } inline void getAllProperties(
diff --git a/redfish-core/include/utils/sw_utils.hpp b/redfish-core/include/utils/sw_utils.hpp index b3f323f..ca3064f 100644 --- a/redfish-core/include/utils/sw_utils.hpp +++ b/redfish-core/include/utils/sw_utils.hpp
@@ -25,10 +25,6 @@ #include "sdbusplus/message/native_types.hpp" #include "sdbusplus/unpack_properties.hpp" -#ifdef UNIT_TEST_BUILD -#include "test/g3/mock_managed_store.hpp" // NOLINT -#endif - namespace redfish { namespace sw_util { /* @brief String that indicates a bios software instance */
diff --git a/redfish-core/lib/assembly.hpp b/redfish-core/lib/assembly.hpp index cb204bc..18360f0 100644 --- a/redfish-core/lib/assembly.hpp +++ b/redfish-core/lib/assembly.hpp
@@ -24,10 +24,6 @@ #include "managed_store_types.hpp" #include "sdbusplus/message/native_types.hpp" -#ifdef UNIT_TEST_BUILD -#include "test/g3/mock_managed_store.hpp" // NOLINT -#endif - namespace redfish { inline void addAssemblyAssetProperties( const std::string& serviceName, const std::string& path,
diff --git a/redfish-core/lib/bios.hpp b/redfish-core/lib/bios.hpp index ae47592..8123fa2 100644 --- a/redfish-core/lib/bios.hpp +++ b/redfish-core/lib/bios.hpp
@@ -38,10 +38,6 @@ #include "managed_store.hpp" #include "managed_store_types.hpp" -#ifdef UNIT_TEST_BUILD -#include "test/g3/mock_managed_store.hpp" // NOLINT -#endif - namespace redfish { constexpr absl::string_view kPldmServiceName = "xyz.openbmc_project.pldm";
diff --git a/redfish-core/lib/cable.hpp b/redfish-core/lib/cable.hpp index 60bf796..1ba6493 100644 --- a/redfish-core/lib/cable.hpp +++ b/redfish-core/lib/cable.hpp
@@ -35,10 +35,6 @@ #include "sdbusplus/message/native_types.hpp" #include "sdbusplus/unpack_properties.hpp" -#ifdef UNIT_TEST_BUILD -#include "test/g3/mock_managed_store.hpp" // NOLINT -#endif - namespace redfish { /**
diff --git a/redfish-core/lib/certificate_service.hpp b/redfish-core/lib/certificate_service.hpp index dd5af6e..4407eec 100644 --- a/redfish-core/lib/certificate_service.hpp +++ b/redfish-core/lib/certificate_service.hpp
@@ -41,10 +41,6 @@ #include "sdbusplus/message/native_types.hpp" #include "sdbusplus/unpack_properties.hpp" -#ifdef UNIT_TEST_BUILD -#include "test/g3/mock_managed_store.hpp" // NOLINT -#endif - namespace redfish { namespace certs { constexpr char const* certInstallIntf = "xyz.openbmc_project.Certs.Install";
diff --git a/redfish-core/lib/chassis.hpp b/redfish-core/lib/chassis.hpp index 9b5a3a5..0d500cf 100644 --- a/redfish-core/lib/chassis.hpp +++ b/redfish-core/lib/chassis.hpp
@@ -31,6 +31,7 @@ #include <vector> #include "gbmc_settings/gbmc_settings.h" +#include "absl/functional/any_invocable.h" // IWYU pragma: keep #include "absl/strings/str_cat.h" #include "boost/system/error_code.hpp" // NOLINT #include "bmcweb_config.h" @@ -59,10 +60,6 @@ #include "sdbusplus/message/native_types.hpp" #include "sdbusplus/unpack_properties.hpp" -#ifdef UNIT_TEST_BUILD -#include "test/g3/mock_managed_store.hpp" // NOLINT -#endif - namespace redfish { constexpr int KMAX_RESET_DELAY_SEC = 3600; @@ -1300,9 +1297,9 @@ return; } - const char* processName = "xyz.openbmc_project.State.Chassis"; - const char* interfaceName = "xyz.openbmc_project.State.Chassis"; - const char* destProperty = "RequestedPowerTransition"; + const std::string processName = "xyz.openbmc_project.State.Chassis"; + const std::string interfaceName = "xyz.openbmc_project.State.Chassis"; + const std::string destProperty = "RequestedPowerTransition"; const std::string propertyValue = "xyz.openbmc_project.State.Chassis.Transition.PowerCycle"; std::string objectPath = "/xyz/openbmc_project/state/chassis_system0"; @@ -1328,26 +1325,21 @@ delayResetCN(asyncResp, delayTimeSecs.value()); return; } -#ifdef UNIT_TEST_BUILD - dynamic_cast<managedStore::MockSerializedManagedObjectStore*>( - managedStore::GetManagedObjectStore()) - ->PostDbusCallToIoContextThreadSafe( -#else managedStore::GetManagedObjectStore() ->PostDbusCallToIoContextThreadSafe( -#endif asyncResp->strand_, - [asyncResp](const boost::system::error_code& ec2) { - // Use "Set" method to set the property value. - if (ec2) { - BMCWEB_LOG_DEBUG << "[Set] Bad D-Bus request error: " - << ec2; - messages::internalError(asyncResp->res); - return; - } + absl::AnyInvocable<void(const boost::system::error_code&)>( + [asyncResp](const boost::system::error_code& ec2) { + // Use "Set" method to set the property value. + if (ec2) { + BMCWEB_LOG_DEBUG << "[Set] Bad D-Bus request error: " + << ec2; + messages::internalError(asyncResp->res); + return; + } - messages::success(asyncResp->res); - }, + messages::success(asyncResp->res); + }), processName, objectPath, "org.freedesktop.DBus.Properties", "Set", interfaceName, destProperty, dbus::utility::DbusVariantType{propertyValue});
diff --git a/redfish-core/lib/component_integrity.hpp b/redfish-core/lib/component_integrity.hpp index e986d58..1ce680a 100644 --- a/redfish-core/lib/component_integrity.hpp +++ b/redfish-core/lib/component_integrity.hpp
@@ -55,10 +55,6 @@ #include "sdbusplus/message/native_types.hpp" #include "sdbusplus/unpack_properties.hpp" -#ifdef UNIT_TEST_BUILD -#include "test/g3/mock_managed_store.hpp" // NOLINT -#endif - namespace redfish { // Interfaces which imply a D-Bus object represents a ComponentIntegrity constexpr std::array<std::string_view, 3> componentIntegrityInterfaces = {
diff --git a/redfish-core/lib/ethernet.hpp b/redfish-core/lib/ethernet.hpp index 17b883b..30130ab 100644 --- a/redfish-core/lib/ethernet.hpp +++ b/redfish-core/lib/ethernet.hpp
@@ -58,10 +58,6 @@ #include "health.hpp" // NOLINT #endif -#ifdef UNIT_TEST_BUILD -#include "test/g3/mock_managed_store.hpp" // NOLINT -#endif - namespace redfish { enum class LinkType : std::uint8_t { Local, Global };
diff --git a/redfish-core/lib/fabric_adapters.hpp b/redfish-core/lib/fabric_adapters.hpp index f3b6da7..e836552 100644 --- a/redfish-core/lib/fabric_adapters.hpp +++ b/redfish-core/lib/fabric_adapters.hpp
@@ -25,10 +25,6 @@ #include "sdbusplus/message/native_types.hpp" #include "sdbusplus/unpack_properties.hpp" -#ifdef UNIT_TEST_BUILD -#include "test/g3/mock_managed_store.hpp" // NOLINT -#endif - namespace redfish { inline void handleAdapterError(const boost::system::error_code& ec,
diff --git a/redfish-core/lib/fan.hpp b/redfish-core/lib/fan.hpp index 67e777a..cb4cf66 100644 --- a/redfish-core/lib/fan.hpp +++ b/redfish-core/lib/fan.hpp
@@ -34,10 +34,6 @@ #include "sdbusplus/message/native_types.hpp" #include "sdbusplus/unpack_properties.hpp" -#ifdef UNIT_TEST_BUILD -#include "test/g3/mock_managed_store.hpp" // NOLINT -#endif - namespace redfish { constexpr std::array<std::string_view, 1> fanInterfaces = {
diff --git a/redfish-core/lib/health.hpp b/redfish-core/lib/health.hpp index e7b7c1c..3721e86 100644 --- a/redfish-core/lib/health.hpp +++ b/redfish-core/lib/health.hpp
@@ -37,10 +37,6 @@ #include "managed_store.hpp" #include "managed_store_types.hpp" -#ifdef UNIT_TEST_BUILD -#include "test/g3/mock_managed_store.hpp" // NOLINT -#endif - namespace redfish { struct HealthAttributes {
diff --git a/redfish-core/lib/led.hpp b/redfish-core/lib/led.hpp index 29bd816..c2aeb6f 100644 --- a/redfish-core/lib/led.hpp +++ b/redfish-core/lib/led.hpp
@@ -27,10 +27,6 @@ #include "dbus_utils.hpp" #include "error_messages.hpp" -#ifdef UNIT_TEST_BUILD -#include "test/g3/mock_managed_store.hpp" // NOLINT -#endif - namespace redfish { /** * @brief Retrieves identify led group properties over dbus
diff --git a/redfish-core/lib/log_services.cpp b/redfish-core/lib/log_services.cpp index 29528c9..6f414a2 100644 --- a/redfish-core/lib/log_services.cpp +++ b/redfish-core/lib/log_services.cpp
@@ -81,10 +81,6 @@ #include "sdbusplus/message/native_types.hpp" #include "sdbusplus/unpack_properties.hpp" // NOLINT -#ifdef UNIT_TEST_BUILD -#include "test/g3/mock_managed_store.hpp" // NOLINT -#endif - namespace redfish { #ifdef BMCWEB_ENABLE_RASMANAGER_EVENT_LOG constexpr char const* rasManagerObject = "com.intel.RAS"; @@ -4997,14 +4993,10 @@ const std::shared_ptr<size_t>& specificIndex, const std::function<void(const nlohmann::json& logEntryArray)>& successCallback) { -#ifdef UNIT_TEST_BUILD - dynamic_cast<managedStore::MockSerializedManagedObjectStore*>( - managedStore::GetManagedObjectStore()) - ->PostDbusCallToIoContextThreadSafe( -#else managedStore::GetManagedObjectStore()->PostDbusCallToIoContextThreadSafe( -#endif - aResp->strand_, + aResp->strand_, + absl::AnyInvocable<void(const boost::system::error_code&, + const std::vector<BootTimeCheckpoint>&)>( [aResp, parentODataId, specificIndex, successCb{successCallback}]( const boost::system::error_code& ec, const std::vector<BootTimeCheckpoint>& checkpoints) { @@ -5054,10 +5046,10 @@ currentIndex++; } successCb(logEntryArray); - }, - "com.google.gbmc.boot_time_monitor", - "/xyz/openbmc_project/time/boot/" + host, - "xyz.openbmc_project.Time.Boot.Checkpoint", "GetCheckpointList"); + }), + "com.google.gbmc.boot_time_monitor", + "/xyz/openbmc_project/time/boot/" + host, + "xyz.openbmc_project.Time.Boot.Checkpoint", "GetCheckpointList"); } static void getBootTimeDurationLogEntries( @@ -5066,14 +5058,10 @@ const std::shared_ptr<size_t>& specificIndex, const std::function<void(const nlohmann::json& logEntryArray)>& successCallback) { -#ifdef UNIT_TEST_BUILD - dynamic_cast<managedStore::MockSerializedManagedObjectStore*>( - managedStore::GetManagedObjectStore()) - ->PostDbusCallToIoContextThreadSafe( -#else managedStore::GetManagedObjectStore()->PostDbusCallToIoContextThreadSafe( -#endif - aResp->strand_, + aResp->strand_, + absl::AnyInvocable<void(const boost::system::error_code&, + const std::vector<BootTimeDuration>&)>( [aResp, parentODataId, specificIndex, successCb{successCallback}]( const boost::system::error_code& ec, const std::vector<BootTimeDuration>& durations) { @@ -5121,10 +5109,10 @@ currentIndex++; } successCb(logEntryArray); - }, - "com.google.gbmc.boot_time_monitor", - "/xyz/openbmc_project/time/boot/" + host, - "xyz.openbmc_project.Time.Boot.Duration", "GetAdditionalDurations"); + }), + "com.google.gbmc.boot_time_monitor", + "/xyz/openbmc_project/time/boot/" + host, + "xyz.openbmc_project.Time.Boot.Duration", "GetAdditionalDurations"); } static void getBootTimeStatisticLogEntry(
diff --git a/redfish-core/lib/manager_diagnostic_data.hpp b/redfish-core/lib/manager_diagnostic_data.hpp index 4a984f8..dfae4e6 100644 --- a/redfish-core/lib/manager_diagnostic_data.hpp +++ b/redfish-core/lib/manager_diagnostic_data.hpp
@@ -34,10 +34,6 @@ #include "managed_store_types.hpp" #include "sdbusplus/unpack_properties.hpp" -#ifdef UNIT_TEST_BUILD -#include "test/g3/mock_managed_store.hpp" // NOLINT -#endif - namespace redfish { using SensorVariantType = dbus::utility::DbusVariantType;
diff --git a/redfish-core/lib/managers.hpp b/redfish-core/lib/managers.hpp index 7b8abc8..e182dcc 100644 --- a/redfish-core/lib/managers.hpp +++ b/redfish-core/lib/managers.hpp
@@ -36,7 +36,7 @@ #include "absl/strings/ascii.h" #include "absl/strings/str_cat.h" #include "boost/container/flat_set.hpp" // NOLINT -#include "boost/system/error_code.hpp" // NOLINT +#include "boost/system/error_code.hpp" // IWYU pragma: keep // NOLINT #include "boost/system/linux_error.hpp" // NOLINT #include "app.hpp" #include "http_request.hpp" @@ -67,10 +67,6 @@ #include "managed_store_types.hpp" #include "sdbusplus/unpack_properties.hpp" -#ifdef UNIT_TEST_BUILD -#include "test/g3/mock_managed_store.hpp" // NOLINT -#endif - namespace redfish { /** @@ -80,68 +76,60 @@ */ inline void doBMCGracefulRestart( const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) { - const char* processName = "xyz.openbmc_project.State.BMC"; - const char* objectPath = "/xyz/openbmc_project/state/bmc0"; - const char* interfaceName = "xyz.openbmc_project.State.BMC"; - const std::string& propertyValue = + const std::string processName = "xyz.openbmc_project.State.BMC"; + const std::string objectPath = "/xyz/openbmc_project/state/bmc0"; + const std::string interfaceName = "xyz.openbmc_project.State.BMC"; + const std::string propertyValue = "xyz.openbmc_project.State.BMC.Transition.Reboot"; - const char* destProperty = "RequestedBMCTransition"; + const std::string destProperty = "RequestedBMCTransition"; // Create the D-Bus variant for D-Bus call. dbus::utility::DbusVariantType dbusPropertyValue(propertyValue); -#ifdef UNIT_TEST_BUILD - dynamic_cast<managedStore::MockSerializedManagedObjectStore*>( - managedStore::GetManagedObjectStore()) - ->PostDbusCallToIoContextThreadSafe( -#else managedStore::GetManagedObjectStore()->PostDbusCallToIoContextThreadSafe( -#endif - asyncResp->strand_, - [asyncResp](const boost::system::error_code& ec) { - // Use "Set" method to set the property value. - if (ec) { - BMCWEB_LOG_DEBUG << "[Set] Bad D-Bus request error: " << ec; - messages::internalError(asyncResp->res); - return; - } + asyncResp->strand_, + absl::AnyInvocable<void( + const boost::system::error_code& // NOLINT(misc-include-cleaner) + )>([asyncResp](const boost::system::error_code& ec) { + // Use "Set" method to set the property value. + if (ec) { + BMCWEB_LOG_DEBUG << "[Set] Bad D-Bus request error: " << ec; + messages::internalError(asyncResp->res); + return; + } - messages::success(asyncResp->res); - }, - processName, objectPath, "org.freedesktop.DBus.Properties", "Set", - interfaceName, destProperty, std::move(dbusPropertyValue)); + messages::success(asyncResp->res); + }), + processName, objectPath, "org.freedesktop.DBus.Properties", "Set", + interfaceName, destProperty, std::move(dbusPropertyValue)); } inline void doBMCForceRestart( const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) { - const char* processName = "xyz.openbmc_project.State.BMC"; - const char* objectPath = "/xyz/openbmc_project/state/bmc0"; - const char* interfaceName = "xyz.openbmc_project.State.BMC"; - const std::string& propertyValue = + const std::string processName = "xyz.openbmc_project.State.BMC"; + const std::string objectPath = "/xyz/openbmc_project/state/bmc0"; + const std::string interfaceName = "xyz.openbmc_project.State.BMC"; + const std::string propertyValue = "xyz.openbmc_project.State.BMC.Transition.HardReboot"; - const char* destProperty = "RequestedBMCTransition"; + const std::string destProperty = "RequestedBMCTransition"; -#ifdef UNIT_TEST_BUILD - dynamic_cast<managedStore::MockSerializedManagedObjectStore*>( - managedStore::GetManagedObjectStore()) - ->PostDbusCallToIoContextThreadSafe( -#else managedStore::GetManagedObjectStore()->PostDbusCallToIoContextThreadSafe( -#endif - asyncResp->strand_, - [asyncResp](const boost::system::error_code& ec) { - // Use "Set" method to set the property value. - if (ec) { - BMCWEB_LOG_DEBUG << "[Set] Bad D-Bus request error: " << ec; - messages::internalError(asyncResp->res); - return; - } + asyncResp->strand_, + absl::AnyInvocable<void( + const boost::system::error_code& // NOLINT(misc-include-cleaner) + )>([asyncResp](const boost::system::error_code& ec) { + // Use "Set" method to set the property value. + if (ec) { + BMCWEB_LOG_DEBUG << "[Set] Bad D-Bus request error: " << ec; + messages::internalError(asyncResp->res); + return; + } - messages::success(asyncResp->res); - }, - processName, objectPath, "org.freedesktop.DBus.Properties", "Set", - interfaceName, destProperty, - dbus::utility::DbusVariantType{propertyValue}); + messages::success(asyncResp->res); + }), + processName, objectPath, "org.freedesktop.DBus.Properties", "Set", + interfaceName, destProperty, + dbus::utility::DbusVariantType{propertyValue}); } inline void handlePostManagerResetAction( @@ -225,14 +213,9 @@ return; } -#ifdef UNIT_TEST_BUILD - dynamic_cast<managedStore::MockSerializedManagedObjectStore*>( - managedStore::GetManagedObjectStore()) - ->PostDbusCallToIoContextThreadSafe( -#else managedStore::GetManagedObjectStore()->PostDbusCallToIoContextThreadSafe( -#endif - asyncResp->strand_, + asyncResp->strand_, + absl::AnyInvocable<void(const boost::system::error_code&)>( [asyncResp](const boost::system::error_code& ec) { if (ec) { BMCWEB_LOG_DEBUG << "Failed to ResetToDefaults: " << ec; @@ -242,10 +225,10 @@ // Factory Reset doesn't actually happen until a reboot // Can't erase what the BMC is running on doBMCGracefulRestart(asyncResp); - }, - "xyz.openbmc_project.Software.BMC.Updater", - "/xyz/openbmc_project/software", - "xyz.openbmc_project.Common.FactoryReset", "Reset"); + }), + "xyz.openbmc_project.Software.BMC.Updater", + "/xyz/openbmc_project/software", + "xyz.openbmc_project.Common.FactoryReset", "Reset"); } /** * ManagerResetToDefaultsAction class supports POST method for factory reset @@ -359,25 +342,20 @@ auto iter = object.first.rfind('/'); if ((iter != std::string::npos) && (iter < object.first.size())) { std::string objName = object.first.substr(iter + 1); -#ifdef UNIT_TEST_BUILD - dynamic_cast<managedStore::MockSerializedManagedObjectStore*>( - managedStore::GetManagedObjectStore()) - ->PostDbusCallToIoContextThreadSafe( -#else managedStore::GetManagedObjectStore() ->PostDbusCallToIoContextThreadSafe( -#endif asyncResp->strand_, - [asyncResp, objName, - munualMode](const boost::system::error_code ec2) { - if (ec2) { - BMCWEB_LOG_ERROR << "Updated the Mode failed " - << objName << ": " << munualMode - << " ec = ( " << ec2 << " )\n"; - messages::internalError(asyncResp->res); - return; - } - }, + absl::AnyInvocable<void(const boost::system::error_code&)>( + [asyncResp, objName, + munualMode](const boost::system::error_code& ec2) { + if (ec2) { + BMCWEB_LOG_ERROR << "Updated the Mode failed " + << objName << ": " << munualMode + << " ec = ( " << ec2 << " )\n"; + messages::internalError(asyncResp->res); + return; + } + }), "xyz.openbmc_project.State.FanCtrl", "/xyz/openbmc_project/settings/fanctrl/" + objName, "org.freedesktop.DBus.Properties", "Set", @@ -1073,14 +1051,9 @@ BMCWEB_LOG_DEBUG << "del " << path << " " << iface << "\n"; // delete interface -#ifdef UNIT_TEST_BUILD - dynamic_cast<managedStore::MockSerializedManagedObjectStore*>( - managedStore::GetManagedObjectStore()) - ->PostDbusCallToIoContextThreadSafe( -#else managedStore::GetManagedObjectStore()->PostDbusCallToIoContextThreadSafe( -#endif - response->strand_, + response->strand_, + absl::AnyInvocable<void(const boost::system::error_code&)>( [response, path](const boost::system::error_code& ec) { if (ec) { BMCWEB_LOG_ERROR << "Error patching " << path << ": " << ec; @@ -1088,8 +1061,8 @@ return; } messages::success(response->res); - }, - "xyz.openbmc_project.EntityManager", path, iface, "Delete"); + }), + "xyz.openbmc_project.EntityManager", path, iface, "Delete"); return CreatePIDRet::del; } @@ -1644,23 +1617,18 @@ return; } currentProfile = *profile; -#ifdef UNIT_TEST_BUILD - dynamic_cast<managedStore::MockSerializedManagedObjectStore*>( - managedStore::GetManagedObjectStore()) - ->PostDbusCallToIoContextThreadSafe( -#else managedStore::GetManagedObjectStore()->PostDbusCallToIoContextThreadSafe( -#endif - response->strand_, + response->strand_, + absl::AnyInvocable<void(const boost::system::error_code&)>( [response](const boost::system::error_code& ec) { if (ec) { BMCWEB_LOG_ERROR << "Error patching profile" << ec; messages::internalError(response->res); } - }, - profileConnection, profilePath, "org.freedesktop.DBus.Properties", - "Set", thermalModeIface, "Current", - dbus::utility::DbusVariantType(*profile)); + }), + profileConnection, profilePath, "org.freedesktop.DBus.Properties", + "Set", thermalModeIface, "Current", + dbus::utility::DbusVariantType(*profile)); } for (auto& containerPair : configuration) { @@ -1758,25 +1726,20 @@ if (!createNewObject) { for (const auto& property : output) { -#ifdef UNIT_TEST_BUILD - dynamic_cast<managedStore::MockSerializedManagedObjectStore*>( - managedStore::GetManagedObjectStore()) - ->PostDbusCallToIoContextThreadSafe( -#else managedStore::GetManagedObjectStore() ->PostDbusCallToIoContextThreadSafe( -#endif response->strand_, - [response, propertyName{std::string(property.first)}]( - const boost::system::error_code& ec) { - if (ec) { - BMCWEB_LOG_ERROR << "Error patching " << propertyName - << ": " << ec; - messages::internalError(response->res); - return; - } - messages::success(response->res); - }, + absl::AnyInvocable<void(const boost::system::error_code&)>( + [response, propertyName{std::string(property.first)}]( + const boost::system::error_code& ec) { + if (ec) { + BMCWEB_LOG_ERROR << "Error patching " + << propertyName << ": " << ec; + messages::internalError(response->res); + return; + } + messages::success(response->res); + }), "xyz.openbmc_project.EntityManager", path, "org.freedesktop.DBus.Properties", "Set", iface, property.first, @@ -1805,23 +1768,18 @@ return; } -#ifdef UNIT_TEST_BUILD - dynamic_cast<managedStore::MockSerializedManagedObjectStore*>( - managedStore::GetManagedObjectStore()) - ->PostDbusCallToIoContextThreadSafe( -#else managedStore::GetManagedObjectStore() ->PostDbusCallToIoContextThreadSafe( -#endif response->strand_, - [response](const boost::system::error_code& ec) { - if (ec) { - BMCWEB_LOG_ERROR << "Error Adding Pid Object " << ec; - messages::internalError(response->res); - return; - } - messages::success(response->res); - }, + absl::AnyInvocable<void(const boost::system::error_code&)>( + [response](const boost::system::error_code& ec) { + if (ec) { + BMCWEB_LOG_ERROR << "Error Adding Pid Object " << ec; + messages::internalError(response->res); + return; + } + messages::success(response->res); + }), "xyz.openbmc_project.EntityManager", chassis, "xyz.openbmc_project.AddObject", "AddObject", output); } @@ -1957,23 +1915,18 @@ // Only support Immediate // An addition could be a Redfish Setting like // ActiveSoftwareImageApplyTime and support OnReset -#ifdef UNIT_TEST_BUILD - dynamic_cast<managedStore::MockSerializedManagedObjectStore*>( - managedStore::GetManagedObjectStore()) - ->PostDbusCallToIoContextThreadSafe( -#else managedStore::GetManagedObjectStore() ->PostDbusCallToIoContextThreadSafe( -#endif aResp->strand_, - [aResp](const boost::system::error_code& ec2) { - if (ec2) { - BMCWEB_LOG_DEBUG << "D-Bus response error setting."; - messages::internalError(aResp->res); - return; - } - doBMCGracefulRestart(aResp); - }, + absl::AnyInvocable<void(const boost::system::error_code&)>( + [aResp](const boost::system::error_code& ec2) { + if (ec2) { + BMCWEB_LOG_DEBUG << "D-Bus response error setting."; + messages::internalError(aResp->res); + return; + } + doBMCGracefulRestart(aResp); + }), "xyz.openbmc_project.Software.BMC.Updater", "/xyz/openbmc_project/software/" + firmwareId, @@ -1993,14 +1946,9 @@ messages::propertyValueFormatError(aResp->res, datetime, "DateTime"); return; } -#ifdef UNIT_TEST_BUILD - dynamic_cast<managedStore::MockSerializedManagedObjectStore*>( - managedStore::GetManagedObjectStore()) - ->PostDbusCallToIoContextThreadSafe( -#else managedStore::GetManagedObjectStore()->PostDbusCallToIoContextThreadSafe( -#endif - aResp->strand_, + aResp->strand_, + absl::AnyInvocable<void(const boost::system::error_code&)>( [aResp, datetime{std::move(datetime)}](const boost::system::error_code& ec) { if (ec) { @@ -2011,11 +1959,11 @@ return; } aResp->res.jsonValue["DateTime"] = datetime; - }, - "xyz.openbmc_project.Time.Manager", "/xyz/openbmc_project/time/bmc", - "org.freedesktop.DBus.Properties", "Set", - "xyz.openbmc_project.Time.EpochTime", "Elapsed", - dbus::utility::DbusVariantType(us->count())); + }), + "xyz.openbmc_project.Time.Manager", "/xyz/openbmc_project/time/bmc", + "org.freedesktop.DBus.Properties", "Set", + "xyz.openbmc_project.Time.EpochTime", "Elapsed", + dbus::utility::DbusVariantType(us->count())); } inline void handleManagerGet(
diff --git a/redfish-core/lib/memory.hpp b/redfish-core/lib/memory.hpp index 6f92808..86579bb 100644 --- a/redfish-core/lib/memory.hpp +++ b/redfish-core/lib/memory.hpp
@@ -58,10 +58,6 @@ #include "sdbusplus/message/native_types.hpp" #include "sdbusplus/unpack_properties.hpp" -#ifdef UNIT_TEST_BUILD -#include "test/g3/mock_managed_store.hpp" // NOLINT -#endif - namespace redfish { inline std::string translateMemoryTypeToRedfish(const std::string& memoryType) {
diff --git a/redfish-core/lib/metric_report.hpp b/redfish-core/lib/metric_report.hpp index 4634b05..5d4c03f 100644 --- a/redfish-core/lib/metric_report.hpp +++ b/redfish-core/lib/metric_report.hpp
@@ -28,10 +28,6 @@ #include "managed_store.hpp" #include "managed_store_types.hpp" -#ifdef UNIT_TEST_BUILD -#include "test/g3/mock_managed_store.hpp" // NOLINT -#endif - namespace redfish { namespace telemetry {
diff --git a/redfish-core/lib/metric_report_definition.hpp b/redfish-core/lib/metric_report_definition.hpp index e68b727..9015fd2 100644 --- a/redfish-core/lib/metric_report_definition.hpp +++ b/redfish-core/lib/metric_report_definition.hpp
@@ -38,10 +38,6 @@ #include "sdbusplus/message/native_types.hpp" #include "sdbusplus/unpack_properties.hpp" -#ifdef UNIT_TEST_BUILD -#include "test/g3/mock_managed_store.hpp" // NOLINT -#endif - namespace redfish { namespace telemetry {
diff --git a/redfish-core/lib/network_adapter.hpp b/redfish-core/lib/network_adapter.hpp index 1227394..4556df8 100644 --- a/redfish-core/lib/network_adapter.hpp +++ b/redfish-core/lib/network_adapter.hpp
@@ -55,10 +55,6 @@ #include "sdbusplus/message/native_types.hpp" #include "sdbusplus/unpack_properties.hpp" -#ifdef UNIT_TEST_BUILD -#include "test/g3/mock_managed_store.hpp" // NOLINT -#endif - namespace redfish { constexpr char const* networkAdapterInventoryIntf =
diff --git a/redfish-core/lib/network_protocol.hpp b/redfish-core/lib/network_protocol.hpp index 6ef66e6..a7d05b5 100644 --- a/redfish-core/lib/network_protocol.hpp +++ b/redfish-core/lib/network_protocol.hpp
@@ -50,10 +50,6 @@ #include "managed_store_types.hpp" #include "sdbusplus/message/native_types.hpp" -#ifdef UNIT_TEST_BUILD -#include "test/g3/mock_managed_store.hpp" // NOLINT -#endif - namespace redfish { void getNTPProtocolEnabled(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp);
diff --git a/redfish-core/lib/other_software_service.hpp b/redfish-core/lib/other_software_service.hpp index 56b4a69..0c148d5 100644 --- a/redfish-core/lib/other_software_service.hpp +++ b/redfish-core/lib/other_software_service.hpp
@@ -19,10 +19,6 @@ #include "managed_store_types.hpp" #include "sdbusplus/message/native_types.hpp" -#ifdef UNIT_TEST_BUILD -#include "test/g3/mock_managed_store.hpp" // NOLINT -#endif - namespace redfish { inline static void getRelatedItemsDrive(
diff --git a/redfish-core/lib/pcie.hpp b/redfish-core/lib/pcie.hpp index c8b53b1..40d3718 100644 --- a/redfish-core/lib/pcie.hpp +++ b/redfish-core/lib/pcie.hpp
@@ -47,10 +47,6 @@ #include "sdbusplus/message/native_types.hpp" #include "sdbusplus/unpack_properties.hpp" -#ifdef UNIT_TEST_BUILD -#include "test/g3/mock_managed_store.hpp" // NOLINT -#endif - namespace redfish { static constexpr char const* pciePath = "/xyz/openbmc_project/inventory/pcie";
diff --git a/redfish-core/lib/pcie_slots.hpp b/redfish-core/lib/pcie_slots.hpp index f154a67..3048483 100644 --- a/redfish-core/lib/pcie_slots.hpp +++ b/redfish-core/lib/pcie_slots.hpp
@@ -33,10 +33,6 @@ #include "sdbusplus/unpack_properties.hpp" #include "sdbusplus/message/native_types.hpp" -#ifdef UNIT_TEST_BUILD -#include "test/g3/mock_managed_store.hpp" // NOLINT -#endif - namespace redfish { inline void addPresenceStatus(
diff --git a/redfish-core/lib/power.hpp b/redfish-core/lib/power.hpp index b0be258..1f73d80 100644 --- a/redfish-core/lib/power.hpp +++ b/redfish-core/lib/power.hpp
@@ -50,10 +50,6 @@ #include "managed_store_types.hpp" #include "sdbusplus/message/native_types.hpp" -#ifdef UNIT_TEST_BUILD -#include "test/g3/mock_managed_store.hpp" // NOLINT -#endif - namespace redfish { inline void afterGetPowerCapEnable(
diff --git a/redfish-core/lib/processor.hpp b/redfish-core/lib/processor.hpp index 42bf9ea..a67a588 100644 --- a/redfish-core/lib/processor.hpp +++ b/redfish-core/lib/processor.hpp
@@ -68,10 +68,6 @@ #include "sdbusplus/message/native_types.hpp" #include "sdbusplus/unpack_properties.hpp" -#ifdef UNIT_TEST_BUILD -#include "test/g3/mock_managed_store.hpp" // NOLINT -#endif - namespace redfish { using resourceIdToSubtreeRespMapType =
diff --git a/redfish-core/lib/sensors.hpp b/redfish-core/lib/sensors.hpp index 9bc5377..1c96296 100644 --- a/redfish-core/lib/sensors.hpp +++ b/redfish-core/lib/sensors.hpp
@@ -67,10 +67,6 @@ #include "sdbusplus/message/native_types.hpp" #include "sdbusplus/unpack_properties.hpp" -#ifdef UNIT_TEST_BUILD -#include "test/g3/mock_managed_store.hpp" // NOLINT -#endif - namespace redfish { namespace sensors {
diff --git a/redfish-core/lib/storage.hpp b/redfish-core/lib/storage.hpp index eb457dc..1a25c2e 100644 --- a/redfish-core/lib/storage.hpp +++ b/redfish-core/lib/storage.hpp
@@ -50,6 +50,7 @@ #include <variant> #include <vector> +#include "absl/functional/any_invocable.h" // IWYU pragma: keep #include "boost/system/error_code.hpp" // NOLINT #include "bmcweb_config.h" #include "app.hpp" @@ -71,6 +72,7 @@ #include "nvme_metric_utils.hpp" #include "storage_utils.hpp" #include "system_utils.hpp" // NOLINT +#include "system_utils.hpp" #include "health.hpp" #include "task.hpp" #include <nlohmann/json.hpp> @@ -79,7 +81,6 @@ #include "sdbusplus/message.hpp" #include "sdbusplus/message/native_types.hpp" #include "sdbusplus/unpack_properties.hpp" -#include "system_utils.hpp" namespace redfish { @@ -1401,16 +1402,12 @@ const std::string& connectionName, const std::string& drivePath, const EraseParams& params) { -#ifdef UNIT_TEST_BUILD - dynamic_cast<managedStore::MockSerializedManagedObjectStore*>( - managedStore::GetManagedObjectStore()) - ->PostDbusCallToIoContextThreadSafe( -#else managedStore::GetManagedObjectStore()->PostDbusCallToIoContextThreadSafe( -#endif - asyncResp->strand_, + asyncResp->strand_, + absl::AnyInvocable<void(const boost::system::error_code&, + const sdbusplus::message_t&)>( [req, asyncResp, connectionName, drivePath]( - const boost::system::error_code ec, + const boost::system::error_code& ec, const sdbusplus::message_t& msg) { // Failure returned from NVMe const ::sd_bus_error* sd_err = msg.get_error(); @@ -1471,10 +1468,10 @@ eraseTaskUpdate(inProgress, task, connectionName, drivePath); }); - }, - connectionName, drivePath, - "xyz.openbmc_project.Inventory.Item.DriveErase", "Erase", - params.actionName()); + }), + connectionName, drivePath, + "xyz.openbmc_project.Inventory.Item.DriveErase", "Erase", + params.actionName()); } inline void matchAndEraseDrive( @@ -1674,13 +1671,7 @@ return; } -#ifdef UNIT_TEST_BUILD - dynamic_cast<managedStore::MockSerializedManagedObjectStore*>( - managedStore::GetManagedObjectStore()) - ->setProperty( -#else managedStore::GetManagedObjectStore()->setProperty( -#endif connectionNames[0].first, path, "xyz.openbmc_project.State.Drive", "RequestedDriveTransition", action, [asyncResp, action](const boost::system::error_code ec) { @@ -2230,15 +2221,11 @@ return; } -#ifdef UNIT_TEST_BUILD - dynamic_cast<managedStore::MockSerializedManagedObjectStore*>( - managedStore::GetManagedObjectStore()) - ->PostDbusCallToIoContextThreadSafe( -#else managedStore::GetManagedObjectStore()->PostDbusCallToIoContextThreadSafe( -#endif - asyncResp->strand_, - [asyncResp](const boost::system::error_code ec, + asyncResp->strand_, + absl::AnyInvocable<void(const boost::system::error_code&, + const sdbusplus::message_t&)>( + [asyncResp](const boost::system::error_code& ec, const sdbusplus::message_t& msg) { // Failure returned from NVMe const ::sd_bus_error* sd_err = msg.get_error(); @@ -2261,10 +2248,10 @@ // success asyncResp->res.result(boost::beast::http::status::no_content); - }, - *service, path, - "xyz.openbmc_project.Inventory.Item.StorageControllerSecurity", - "SecuritySend", proto, protoSpecific, data); + }), + *service, path, + "xyz.openbmc_project.Inventory.Item.StorageControllerSecurity", + "SecuritySend", proto, protoSpecific, data); } inline void securityReceiveAction( @@ -2279,15 +2266,12 @@ return; } -#ifdef UNIT_TEST_BUILD - dynamic_cast<managedStore::MockSerializedManagedObjectStore*>( - managedStore::GetManagedObjectStore()) - ->PostDbusCallToIoContextThreadSafe( -#else managedStore::GetManagedObjectStore()->PostDbusCallToIoContextThreadSafe( -#endif - asyncResp->strand_, - [asyncResp](const boost::system::error_code ec, + asyncResp->strand_, + absl::AnyInvocable<void(const boost::system::error_code&, + const sdbusplus::message_t&, + const std::vector<uint8_t>&)>( + [asyncResp](const boost::system::error_code& ec, const sdbusplus::message_t& msg, const std::vector<uint8_t>& data) { // Failure returned from NVMe @@ -2313,10 +2297,10 @@ asyncResp->res.jsonValue["Data"] = crow::utility::base64encode( std::string_view(reinterpret_cast<const char*>(data.data()), data.size())); // NOLINT - }, - *service, path, - "xyz.openbmc_project.Inventory.Item.StorageControllerSecurity", - "SecurityReceive", proto, protoSpecific, transferLength); + }), + *service, path, + "xyz.openbmc_project.Inventory.Item.StorageControllerSecurity", + "SecurityReceive", proto, protoSpecific, transferLength); } inline static void setCustomSSDOemGpio( @@ -2326,13 +2310,7 @@ "com.google.gbmc.ssd." + boost::algorithm::to_lower_copy(std::string(customSSD)); -#ifdef UNIT_TEST_BUILD - dynamic_cast<managedStore::MockSerializedManagedObjectStore*>( - managedStore::GetManagedObjectStore()) - ->setProperty( -#else managedStore::GetManagedObjectStore()->setProperty( -#endif "com.google.gbmc.ssd", path, customSSDDbusInterface, property, value, [asyncResp](const boost::system::error_code ec) { if (ec) { @@ -2353,13 +2331,7 @@ "com.google.gbmc.ssd." + boost::algorithm::to_lower_copy(std::string(customSSD)); -#ifdef UNIT_TEST_BUILD - dynamic_cast<managedStore::MockSerializedManagedObjectStore*>( - managedStore::GetManagedObjectStore()) - ->setProperty( -#else managedStore::GetManagedObjectStore()->setProperty( -#endif "com.google.gbmc.ssd", path, customSSDDbusInterface, property, value, [asyncResp](const boost::system::error_code ec) { if (ec) { @@ -2420,16 +2392,12 @@ detaches->pop_back(); BMCWEB_LOG_DEBUG << "detaching " << v.str << " from " << controllerPath << "\n"; -#ifdef UNIT_TEST_BUILD - dynamic_cast<managedStore::MockSerializedManagedObjectStore*>( - managedStore::GetManagedObjectStore()) - ->PostDbusCallToIoContextThreadSafe( -#else managedStore::GetManagedObjectStore()->PostDbusCallToIoContextThreadSafe( -#endif - asyncResp->strand_, + asyncResp->strand_, + absl::AnyInvocable<void(const boost::system::error_code&, + const sdbusplus::message_t&)>( [asyncResp, connectionName, controllerPath, attaches, detaches]( - const boost::system::error_code ec, + const boost::system::error_code& ec, const sdbusplus::message_t& msg) { // Failure returned from NVMe const ::sd_bus_error* sd_err = msg.get_error(); @@ -2449,10 +2417,10 @@ // "recurse" storageApplyAttachDetach(asyncResp, connectionName, controllerPath, attaches, detaches); - }, - connectionName, controllerPath, - "xyz.openbmc_project.Inventory.Item.StorageController", - "DetachVolume", v); + }), + connectionName, controllerPath, + "xyz.openbmc_project.Inventory.Item.StorageController", "DetachVolume", + v); return; } @@ -2461,16 +2429,12 @@ attaches->pop_back(); BMCWEB_LOG_DEBUG << "attaching " << v.str << " to " << controllerPath << "\n"; -#ifdef UNIT_TEST_BUILD - dynamic_cast<managedStore::MockSerializedManagedObjectStore*>( - managedStore::GetManagedObjectStore()) - ->PostDbusCallToIoContextThreadSafe( -#else managedStore::GetManagedObjectStore()->PostDbusCallToIoContextThreadSafe( -#endif - asyncResp->strand_, + asyncResp->strand_, + absl::AnyInvocable<void(const boost::system::error_code&, + const sdbusplus::message_t&)>( [asyncResp, connectionName, controllerPath, attaches, detaches]( - const boost::system::error_code ec, + const boost::system::error_code& ec, const sdbusplus::message_t& msg) { // Failure returned from NVMe const ::sd_bus_error* sd_err = msg.get_error(); @@ -2490,10 +2454,10 @@ // "recurse" storageApplyAttachDetach(asyncResp, connectionName, controllerPath, attaches, detaches); - }, - connectionName, controllerPath, - "xyz.openbmc_project.Inventory.Item.StorageController", - "AttachVolume", v); + }), + connectionName, controllerPath, + "xyz.openbmc_project.Inventory.Item.StorageController", "AttachVolume", + v); return; } @@ -3006,15 +2970,11 @@ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, const std::string& storageId, const std::string& connectionName, const std::string& path) { -#ifdef UNIT_TEST_BUILD - dynamic_cast<managedStore::MockSerializedManagedObjectStore*>( - managedStore::GetManagedObjectStore()) - ->PostDbusCallToIoContextThreadSafe( -#else managedStore::GetManagedObjectStore()->PostDbusCallToIoContextThreadSafe( -#endif - asyncResp->strand_, - [asyncResp, storageId](const boost::system::error_code ec, + asyncResp->strand_, + absl::AnyInvocable<void(const boost::system::error_code&, + const sdbusplus::message_t&)>( + [asyncResp, storageId](const boost::system::error_code& ec, const sdbusplus::message_t& msg) { // Failure returned from NVMe const ::sd_bus_error* sd_err = msg.get_error(); @@ -3032,8 +2992,8 @@ // success asyncResp->res.result(boost::beast::http::status::no_content); - }, - connectionName, path, "xyz.openbmc_project.Object.Delete", "Delete"); + }), + connectionName, path, "xyz.openbmc_project.Object.Delete", "Delete"); } inline void findStorageVolume( @@ -3266,16 +3226,13 @@ const std::string& storagePath, const std::string& storageService, uint64_t size, size_t lbaIndex, bool metadataAtEnd) { auto storageId = sdbusplus::message::object_path(storagePath).filename(); -#ifdef UNIT_TEST_BUILD - dynamic_cast<managedStore::MockSerializedManagedObjectStore*>( - managedStore::GetManagedObjectStore()) - ->PostDbusCallToIoContextThreadSafe( -#else managedStore::GetManagedObjectStore()->PostDbusCallToIoContextThreadSafe( -#endif - asyncResp->strand_, + asyncResp->strand_, + absl::AnyInvocable<void(const boost::system::error_code&, + const sdbusplus::message_t&, + const sdbusplus::message::object_path&)>( [req, asyncResp, storageId, storageService]( - const boost::system::error_code ec, + const boost::system::error_code& ec, const sdbusplus::message_t& msg, const sdbusplus::message::object_path& progressPath) { const ::sd_bus_error* sd_err = msg.get_error(); @@ -3339,9 +3296,9 @@ createVolumeTaskUpdate(status, task, storageService, storageId, progressPath); }); - }, - storageService, storagePath, "xyz.openbmc_project.Nvme.Storage", - "CreateVolume", size, lbaIndex, metadataAtEnd); + }), + storageService, storagePath, "xyz.openbmc_project.Nvme.Storage", + "CreateVolume", size, lbaIndex, metadataAtEnd); } inline void populateStorageVolumeCollection(
diff --git a/redfish-core/lib/systems.hpp b/redfish-core/lib/systems.hpp index 4ddfa9f..349ddf4 100644 --- a/redfish-core/lib/systems.hpp +++ b/redfish-core/lib/systems.hpp
@@ -74,10 +74,6 @@ #include "sdbusplus/message/native_types.hpp" #include "sdbusplus/unpack_properties.hpp" -#ifdef UNIT_TEST_BUILD -#include "test/g3/mock_managed_store.hpp" // NOLINT -#endif - namespace redfish { static const std::array<std::pair<std::string_view, std::string_view>, 2>
diff --git a/redfish-core/lib/task.hpp b/redfish-core/lib/task.hpp index 7f6a6bb..3a7be4a 100644 --- a/redfish-core/lib/task.hpp +++ b/redfish-core/lib/task.hpp
@@ -51,10 +51,6 @@ #include "sdbusplus/bus/match.hpp" #include "sdbusplus/message.hpp" -#ifdef UNIT_TEST_BUILD -#include "test/g3/mock_managed_store.hpp" // NOLINT -#endif - namespace redfish { namespace task {
diff --git a/redfish-core/lib/telemetry_service.hpp b/redfish-core/lib/telemetry_service.hpp index 4478fa2..6b3b4d2 100644 --- a/redfish-core/lib/telemetry_service.hpp +++ b/redfish-core/lib/telemetry_service.hpp
@@ -24,10 +24,6 @@ #include "managed_store_types.hpp" #include "sdbusplus/unpack_properties.hpp" -#ifdef UNIT_TEST_BUILD -#include "test/g3/mock_managed_store.hpp" // NOLINT -#endif - namespace redfish { inline void handleTelemetryServiceGet(
diff --git a/redfish-core/lib/trusted_component.hpp b/redfish-core/lib/trusted_component.hpp index ffe5026..494dd06 100644 --- a/redfish-core/lib/trusted_component.hpp +++ b/redfish-core/lib/trusted_component.hpp
@@ -51,10 +51,6 @@ #include "sdbusplus/message/native_types.hpp" #include "sdbusplus/unpack_properties.hpp" -#ifdef UNIT_TEST_BUILD -#include "test/g3/mock_managed_store.hpp" // NOLINT -#endif - namespace redfish { // Interfaces which imply a D-Bus object represents a TrustedComponent constexpr std::array<std::string_view, 1> trustedComponentInterfaces = {
diff --git a/redfish-core/lib/update_service.hpp b/redfish-core/lib/update_service.hpp index 2ac0f9b..7cce844 100644 --- a/redfish-core/lib/update_service.hpp +++ b/redfish-core/lib/update_service.hpp
@@ -65,10 +65,6 @@ #include "sdbusplus/message/native_types.hpp" #include "sdbusplus/unpack_properties.hpp" -#ifdef UNIT_TEST_BUILD -#include "test/g3/mock_managed_store.hpp" // NOLINT -#endif - namespace redfish { // Match signals added on software path
diff --git a/redfish-core/src/utils/subprocess_utils.cpp b/redfish-core/src/utils/subprocess_utils.cpp index e5a46df..576607b 100644 --- a/redfish-core/src/utils/subprocess_utils.cpp +++ b/redfish-core/src/utils/subprocess_utils.cpp
@@ -12,10 +12,6 @@ #include "async_resp.hpp" #include "error_messages.hpp" #include "managed_store.hpp" -#ifdef UNIT_TEST_BUILD -#include "test/g3/mock_managed_store.hpp" -#endif - namespace redfish { class SubprocessUtils : public SubprocessUtilsBase {
diff --git a/src/managed_store_http.cpp b/src/managed_store_http.cpp index 7dcca3d..45c18ff 100644 --- a/src/managed_store_http.cpp +++ b/src/managed_store_http.cpp
@@ -21,10 +21,6 @@ #include "managed_store_clock.hpp" #include "managed_store_types.hpp" -#ifdef UNIT_TEST_BUILD -#include "test/g3/mock_managed_store.hpp" // NOLINT -#endif - namespace managedStore { void ManagedObjectStoreHttp::requestRoutesManagedStoreDebug(
diff --git a/test/g3/mock_managed_store.hpp b/test/g3/mock_managed_store.hpp index 1f5de5d..4803e04 100644 --- a/test/g3/mock_managed_store.hpp +++ b/test/g3/mock_managed_store.hpp
@@ -21,6 +21,7 @@ #include "absl/strings/str_format.h" #include "absl/synchronization/mutex.h" #include "boost/asio/post.hpp" // NOLINT +#include "boost/callable_traits/args.hpp" // NOLINT #include "boost/container/flat_map.hpp" // NOLINT #include "boost/system/errc.hpp" // NOLINT #include "subscription.h" @@ -273,13 +274,33 @@ MOCK_METHOD(void, setProperty, (const std::string& service, const std::string& path, const std::string& interface, const std::string& propertyName, - const std::string& propertyValue, SetPropertyCb&& callback)); + const std::string& propertyValue, SetPropertyCb&& callback), + (override)); + + MOCK_METHOD(void, setProperty, + (const std::string& service, const std::string& path, + const std::string& interface, const std::string& propertyName, + bool propertyValue, SetPropertyCb&& callback), + (override)); + + MOCK_METHOD(void, setProperty, + (const std::string& service, const std::string& path, + const std::string& interface, const std::string& propertyName, + uint32_t propertyValue, SetPropertyCb&& callback), + (override)); + + MOCK_METHOD(void, setProperty, + (const std::string& service, const std::string& path, + const std::string& interface, const std::string& propertyName, + double propertyValue, SetPropertyCb&& callback), + (override)); MOCK_METHOD(void, setProperty, (const std::string& service, const std::string& path, const std::string& interface, const std::string& propertyName, dbus::utility::DbusVariantType&& propertyValue, - SetPropertyCb&& callback)); + SetPropertyCb&& callback), + (override)); using GetAncestorsResponseType = std::array<const char*, 1>; @@ -320,8 +341,8 @@ const boost::system::error_code&, const std::vector<std::pair<std::string, TriggerGetParamsVariant>>&)>; - // This is one specific type of Dbus Call that can be made - // Every dbus call with different arguments will need its own mock method + // Generic D-Bus call with no arguments (e.g., doNMI in systems.h, + // resetChassis in chassis.h) MOCK_METHOD(void, PostDbusCallToIoContextThreadSafe, (const std::shared_ptr<boost::asio::io_context::strand>&, absl::AnyInvocable<void(const boost::system::error_code&)>&&, @@ -329,15 +350,16 @@ const std::string& interf, const std::string& method), (override)); - // This is one specific type of Dbus Call that can be made - // This is an introspect command + // Introspect in openbmc_dbus_rest.h, log_services.cc MOCK_METHOD(void, PostDbusCallToIoContextThreadSafe, (const std::shared_ptr<boost::asio::io_context::strand>&, absl::AnyInvocable<void(const boost::system::error_code&, const std::string&)>&&, const std::string& service, const std::string& objpath, - const std::string& interface, const std::string& method)); + const std::string& interface, const std::string& method), + (override)); + // Introspect with interfaces in openbmc_dbus_rest.h MOCK_METHOD(void, PostDbusCallToIoContextThreadSafe, (const std::shared_ptr<boost::asio::io_context::strand>&, absl::AnyInvocable<void(const boost::system::error_code&, @@ -345,17 +367,19 @@ const std::string& service, const std::string& objpath, const std::string& interface, const std::string& method, const std::string& object, - const std::vector<std::string>& interfaces)); + const std::vector<std::string>& interfaces), + (override)); - // This is one specific type of Dbus Call that can be made - // This is ListNames command + // ListNames in openbmc_dbus_rest.h MOCK_METHOD(void, PostDbusCallToIoContextThreadSafe, (const std::shared_ptr<boost::asio::io_context::strand>&, absl::AnyInvocable<void(const boost::system::error_code&, std::vector<std::string>&)>&&, const std::string& service, const std::string& objpath, - const std::string& interface, const std::string& method)); + const std::string& interface, const std::string& method), + (override)); + // ListNames with interfaces in openbmc_dbus_rest.h MOCK_METHOD(void, PostDbusCallToIoContextThreadSafe, (const std::shared_ptr<boost::asio::io_context::strand>&, absl::AnyInvocable<void(const boost::system::error_code&, @@ -363,10 +387,47 @@ const std::string& service, const std::string& objpath, const std::string& interface, const std::string& method, const std::string& object, - const std::vector<std::string>& interfaces)); + const std::vector<std::string>& interfaces), + (override)); - // This is one specific type of Dbus Call that can be made - // This is an GetAncestors command from ObjectMapper + // GetObject in storage_utils.h, certificate_service.h + MOCK_METHOD( + void, PostDbusCallToIoContextThreadSafe, + (const std::shared_ptr<boost::asio::io_context::strand>&, + absl::AnyInvocable<void(const boost::system::error_code&, + const dbus::utility::MapperGetObject&)>&&, + const std::string& service, const std::string& objpath, + const std::string& interface, const std::string& method, + const std::string& path, const std::vector<std::string>& interfaces), + (override)); + + // GetAssociatedSubTree in storage_utils.h + MOCK_METHOD(void, PostDbusCallToIoContextThreadSafe, + (const std::shared_ptr<boost::asio::io_context::strand>&, + absl::AnyInvocable< + void(const boost::system::error_code&, + const dbus::utility::MapperGetSubTreeResponse&)>&&, + const std::string& service, const std::string& objpath, + const std::string& interface, const std::string& method, + const sdbusplus::message::object_path& associatedPath, + const sdbusplus::message::object_path& path, int32_t depth, + const std::vector<std::string>& interfaces), + (override)); + + // GetAssociatedSubTreePaths in storage_utils.h + MOCK_METHOD(void, PostDbusCallToIoContextThreadSafe, + (const std::shared_ptr<boost::asio::io_context::strand>&, + absl::AnyInvocable< + void(const boost::system::error_code&, + const dbus::utility::MapperGetSubTreePathsResponse&)>&&, + const std::string& service, const std::string& objpath, + const std::string& interface, const std::string& method, + const sdbusplus::message::object_path& associatedPath, + const sdbusplus::message::object_path& path, int32_t depth, + const std::vector<std::string>& interfaces), + (override)); + + // GetAncestors in log_services.cc, storage_utils.h MOCK_METHOD(void, PostDbusCallToIoContextThreadSafe, (const std::shared_ptr<boost::asio::io_context::strand>&, absl::AnyInvocable< @@ -375,20 +436,20 @@ const std::string& service, const std::string& objpath, const std::string& interface, const std::string& method, const std::string& obj_name, - const GetAncestorsResponseType& interfaces)); + const GetAncestorsResponseType& interfaces), + (override)); - // This is one specific type of Dbus Call that can be made - // This is an RestartUnit command from systemd + // RestartUnit / StartUnit / StopUnit from systemd in log_services.cc, + // network_protocol.h MOCK_METHOD(void, PostDbusCallToIoContextThreadSafe, (const std::shared_ptr<boost::asio::io_context::strand>&, absl::AnyInvocable<void(const boost::system::error_code&)>&&, const std::string& service, const std::string& objpath, const std::string& interface, const std::string& method, - const std::string& service_name, const std::string& command)); + const std::string& service_name, const std::string& command), + (override)); - // This is one specific type of Dbus Call that can be made - // This overload is used for Get requests that have to be made outside - // managedStore + // getProperty (org.freedesktop.DBus.Properties.Get) in storage_utils.h MOCK_METHOD( void, PostDbusCallToIoContextThreadSafe, (const std::shared_ptr<boost::asio::io_context::strand>&, @@ -396,11 +457,11 @@ const dbus::utility::DbusVariantType&)>&&, const std::string& service, const std::string& objpath, const std::string& interface, const std::string& get, - const std::string& get_interf, const std::string& property)); + const std::string& get_interf, const std::string& property), + (override)); - // This is one specific type of Dbus Call that can be made - // This overload is used for Set requests that have to be made outside - // managedStore + // setProperty (org.freedesktop.DBus.Properties.Set) in systems.h (e.g., + // setBootType, sendPowerSystemCommand) MOCK_METHOD(void, PostDbusCallToIoContextThreadSafe, (const std::shared_ptr<boost::asio::io_context::strand>&, absl::AnyInvocable<void(const boost::system::error_code&)>&&, @@ -410,8 +471,7 @@ dbus::utility::DbusVariantType&& property), (override)); - // This is one specific type of Dbus Call that can be made - // This overload is used for Set requests with a special callback + // setProperty returning sdbusplus::message_t in power.h, sensors.h MOCK_METHOD(void, PostDbusCallToIoContextThreadSafe, (const std::shared_ptr<boost::asio::io_context::strand>&, absl::AnyInvocable<void(const boost::system::error_code&, @@ -419,46 +479,48 @@ const std::string& service, const std::string& objpath, const std::string& interface, const std::string& set, const std::string& set_interf, const std::string& property_name, - dbus::utility::DbusVariantType property)); + dbus::utility::DbusVariantType property), + (override)); - // This is one specific type of Dbus Call that can be made - // This overload is used for ResolveHostname in asyncResolve.hpp + // asyncResolve in async_resolve.h MOCK_METHOD(void, PostDbusCallToIoContextThreadSafe, (const std::shared_ptr<boost::asio::io_context::strand>&, ResolveHostnameCb&&, const std::string& service, const std::string& objpath, const std::string& interface, const std::string& method, int param1, const std::string& param2, - int param3, uint64_t param4)); + int param3, uint64_t param4), + (override)); - // This is one specific type of Dbus Call that can be made - // This overload is used for Create VLAN ethernet.hpp + // createVLAN in ethernet.h MOCK_METHOD(void, PostDbusCallToIoContextThreadSafe, (const std::shared_ptr<boost::asio::io_context::strand>&, absl::AnyInvocable<void(const boost::system::error_code&)>&&, const std::string& service, const std::string& objpath, const std::string& interface, const std::string& method, - const std::string& param1, uint32_t param2)); + const std::string& param1, uint32_t param2), + (override)); - // This overload is used for Create IP ethernet.hpp + // createIPv4 / createIPv6 in ethernet.h MOCK_METHOD(void, PostDbusCallToIoContextThreadSafe, (const std::shared_ptr<boost::asio::io_context::strand>&, absl::AnyInvocable<void(const boost::system::error_code&)>&&, const std::string& service, const std::string& objpath, const std::string& interface, const std::string& create_ip, const std::string& protocol, const std::string& address, - uint8_t prefix_length, const std::string& param4)); + uint8_t prefix_length, const std::string& param4), + (override)); - // This is one specific type of Dbus Call that can be made - // This overload is used for GetPostCodes log_services.hpp + // getPostCodeData (GetPostCodes) in log_services.cc MOCK_METHOD(void, PostDbusCallToIoContextThreadSafe, (const std::shared_ptr<boost::asio::io_context::strand>&, absl::AnyInvocable<void(const boost::system::error_code&, const std::vector<PostCodeEntry>&)>&&, const std::string& service, const std::string& objpath, const std::string& interface, const std::string& get_postcodes, - uint16_t param1)); + uint16_t param1), + (override)); - // getPostPackageRepairStatus in log_service.cpp + // getPostPackageRepairStatus in log_services.cc using PostPackageRepairStatusParam = std::vector<std::tuple<uint16_t, uint16_t, uint16_t, uint16_t, std::vector<uint16_t>>>; @@ -467,15 +529,19 @@ absl::AnyInvocable<void(const boost::system::error_code&, const PostPackageRepairStatusParam&)>&&, const std::string& service, const std::string& objpath, - const std::string& interface, const std::string& method)); - // getPostPackageRepairConfig + const std::string& interface, const std::string& method), + (override)); + + // getPostPackageRepairConfig in log_services.cc MOCK_METHOD(void, PostDbusCallToIoContextThreadSafe, (const std::shared_ptr<boost::asio::io_context::strand>&, absl::AnyInvocable<void(const boost::system::error_code&, const std::vector<uint16_t>&)>&&, const std::string& service, const std::string& objpath, - const std::string& interface, const std::string& method)); + const std::string& interface, const std::string& method), + (override)); + // getPostCodeData (GetPostCodesTS returning flat_map) in log_services.cc MOCK_METHOD( void, PostDbusCallToIoContextThreadSafe, (const std::shared_ptr<boost::asio::io_context::strand>&, @@ -484,25 +550,28 @@ const boost::container::flat_map<uint64_t, PostCodeEntry>&)>&&, const std::string& service, const std::string& objpath, const std::string& interface, const std::string& get_postcodes, - uint16_t param1)); + uint16_t param1), + (override)); - // This is used for delete in log_services.hpp + // deleteLogEntry in log_services.cc, certificate_service.h MOCK_METHOD(void, PostDbusCallToIoContextThreadSafe, (const std::shared_ptr<boost::asio::io_context::strand>&, absl::AnyInvocable<void(const boost::system::error_code&, const sdbusplus::message_t&)>&&, const std::string& service, const std::string& objpath, - const std::string& interface, const std::string& method)); + const std::string& interface, const std::string& method), + (override)); - // This is used for GetEntry in log_services.hpp + // getLogEntry in log_services.cc MOCK_METHOD(void, PostDbusCallToIoContextThreadSafe, (const std::shared_ptr<boost::asio::io_context::strand>&, absl::AnyInvocable<void(const boost::system::error_code&, const sdbusplus::message::unix_fd&)>&&, const std::string& service, const std::string& objpath, - const std::string& interface, const std::string& get_entry)); + const std::string& interface, const std::string& get_entry), + (override)); - // This is used for CreateDump in log_services.hpp + // createDump in log_services.cc MOCK_METHOD( void, PostDbusCallToIoContextThreadSafe, (const std::shared_ptr<boost::asio::io_context::strand>&, @@ -511,9 +580,10 @@ const sdbusplus::message::object_path&)>&&, const std::string& service, const std::string& objpath, const std::string& interface, const std::string& create_dump, - const CreateDumpParamVec& create_dump_param_vec)); + const CreateDumpParamVec& create_dump_param_vec), + (override)); - // GetUserInfo in routing.hpp + // getUserInfo in user_monitor.h, openbmc_dbus_rest.h MOCK_METHOD( void, PostDbusCallToIoContextThreadSafe, (const std::shared_ptr<boost::asio::io_context::strand>&, @@ -521,8 +591,10 @@ const dbus::utility::DBusPropertiesMap&)>&&, const std::string& service, const std::string& objpath, const std::string& interface, const std::string& get_user_info, - const std::string& username)); + const std::string& username), + (override)); + // readFruData in managers.h MOCK_METHOD(void, PostDbusCallToIoContextThreadSafe, (const std::shared_ptr<boost::asio::io_context::strand>&, absl::AnyInvocable<void(const boost::system::error_code&, @@ -531,7 +603,8 @@ const std::string& interface, const std::string& method, uint16_t bus, uint8_t address), (override)); - // SendHostCommand in google_service_root.hpp + + // SendHostCommand in google_service_root.h MOCK_METHOD(void, PostDbusCallToIoContextThreadSafe, (const std::shared_ptr<boost::asio::io_context::strand>&, absl::AnyInvocable<void(const boost::system::error_code&, @@ -539,18 +612,20 @@ const std::string& service, const std::string& objpath, const std::string& interface, const std::string& send_host_command, - const std::vector<unsigned char>& payload)); + const std::vector<unsigned char>& payload), + (override)); - // GetLogPage in google_service_nvme.hpp + // GetLogPage in google_service_nvme.h MOCK_METHOD(void, PostDbusCallToIoContextThreadSafe, (const std::shared_ptr<boost::asio::io_context::strand>&, absl::AnyInvocable<void(const boost::system::error_code&, const sdbusplus::message::unix_fd&)>&&, const std::string& service, const std::string& objpath, const std::string& interface, const std::string& get_log_page, - uint8_t lid, uint32_t nsid, uint8_t lsp, uint16_t lsi)); + uint8_t lid, uint32_t nsid, uint8_t lsp, uint16_t lsi), + (override)); - // LockdownInband in google_service_nvme.hpp + // LockdownInband in google_service_nvme.h MOCK_METHOD( void, PostDbusCallToIoContextThreadSafe, (const std::shared_ptr<boost::asio::io_context::strand>&, @@ -581,16 +656,17 @@ // uint32_t cdw10, uint32_t cdw11, uint32_t cdw12, uint32_t cdw13, // uint32_t cdw14, uint32_t cdw15)); - // Identify in google_service_nvme.hpp + // Identify in google_service_nvme.h MOCK_METHOD(void, PostDbusCallToIoContextThreadSafe, (const std::shared_ptr<boost::asio::io_context::strand>&, absl::AnyInvocable<void(const boost::system::error_code&, const sdbusplus::message::unix_fd&)>&&, const std::string& service, const std::string& objpath, const std::string& interface, const std::string& identify, - uint8_t cns, uint32_t nsid, uint16_t cntid)); + uint8_t cns, uint32_t nsid, uint16_t cntid), + (override)); - // ExecuteRde in redfish_aggregator.hpp + // executeRde in redfish_aggregator.h MOCK_METHOD(void, PostDbusCallToIoContextThreadSafe, (const std::shared_ptr<boost::asio::io_context::strand>&, absl::AnyInvocable<void(const boost::system::error_code&, @@ -598,9 +674,10 @@ const std::string& service, const std::string& objpath, const std::string& interface, const std::string& execute_rde, int random, uint8_t id, const std::string& uri, - const std::string& udev_id, const std::string& payload)); + const std::string& udev_id, const std::string& payload), + (override)); - // CreateVolume in storage.hpp + // createStorageVolume in storage.h MOCK_METHOD( void, PostDbusCallToIoContextThreadSafe, (const std::shared_ptr<boost::asio::io_context::strand>&, @@ -609,18 +686,20 @@ const sdbusplus::message::object_path&)>&&, const std::string& service, const std::string& objpath, const std::string& interface, const std::string& create_volume, - uint64_t size, size_t lba_index, bool metadata_at_end)); + uint64_t size, size_t lba_index, bool metadata_at_end), + (override)); - // AttachVolume in storage.hpp + // storageApplyAttachDetach (AttachVolume/DetachVolume) in storage.h MOCK_METHOD(void, PostDbusCallToIoContextThreadSafe, (const std::shared_ptr<boost::asio::io_context::strand>&, absl::AnyInvocable<void(const boost::system::error_code&, const sdbusplus::message_t&)>&&, const std::string& service, const std::string& objpath, const std::string& interface, const std::string& attach_volume, - const sdbusplus::message::object_path& v)); + const sdbusplus::message::object_path& v), + (override)); - // SecuritySend in storage.hpp + // securitySendAction in storage.h MOCK_METHOD(void, PostDbusCallToIoContextThreadSafe, (const std::shared_ptr<boost::asio::io_context::strand>&, absl::AnyInvocable<void(const boost::system::error_code&, @@ -628,9 +707,10 @@ const std::string& service, const std::string& objpath, const std::string& interface, const std::string& security_send, uint8_t proto, uint16_t proto_specific, - const std::vector<uint8_t>& data)); + const std::vector<uint8_t>& data), + (override)); - // SecurityRecieve in storage.hpp + // securityReceiveAction in storage.h MOCK_METHOD(void, PostDbusCallToIoContextThreadSafe, (const std::shared_ptr<boost::asio::io_context::strand>&, absl::AnyInvocable<void(const boost::system::error_code&, @@ -639,52 +719,58 @@ const std::string& service, const std::string& objpath, const std::string& interface, const std::string& security_recieve, uint8_t proto, - uint16_t proto_specific, uint32_t transfer_length)); + uint16_t proto_specific, uint32_t transfer_length), + (override)); - // DriveErase in storage.hpp + // eraseDrive in storage.h MOCK_METHOD(void, PostDbusCallToIoContextThreadSafe, (const std::shared_ptr<boost::asio::io_context::strand>&, absl::AnyInvocable<void(const boost::system::error_code&, const sdbusplus::message_t&)>&&, const std::string& service, const std::string& objpath, const std::string& interface, const std::string& drive_erase, - const std::string& action_name)); + const std::string& action_name), + (override)); - // AddObject in managers.hpp + // addObject in managers.h MOCK_METHOD(void, PostDbusCallToIoContextThreadSafe, (const std::shared_ptr<boost::asio::io_context::strand>&, absl::AnyInvocable<void(const boost::system::error_code&)>&&, const std::string& service, const std::string& objpath, const std::string& interface, const std::string& add_object, - const dbus::utility::DBusPropertiesMap& output)); + const dbus::utility::DBusPropertiesMap& output), + (override)); - // Install in certificate_service.hpp + // installCertificate in certificate_service.h MOCK_METHOD(void, PostDbusCallToIoContextThreadSafe, (const std::shared_ptr<boost::asio::io_context::strand>&, absl::AnyInvocable<void(const boost::system::error_code&, const std::string&)>&&, const std::string& service, const std::string& objpath, const std::string& interface, const std::string& install, - const std::string& file_path)); + const std::string& file_path), + (override)); - // Replace in certificate_service.hpp + // replaceCertificate in certificate_service.h MOCK_METHOD(void, PostDbusCallToIoContextThreadSafe, (const std::shared_ptr<boost::asio::io_context::strand>&, absl::AnyInvocable<void(const boost::system::error_code&)>&&, const std::string& service, const std::string& objpath, const std::string& interface, const std::string& replace, - const std::string& file_path)); + const std::string& file_path), + (override)); - // SPDMGetSignedMeasurments in component_integrity.hpp + // getSignedMeasurements (SPDMGetSignedMeasurements) in component_integrity.h MOCK_METHOD(void, PostDbusCallToIoContextThreadSafe, (const std::shared_ptr<boost::asio::io_context::strand>&, SPDMGetSignedMeasurmentsCb&&, const std::string& service, const std::string& objpath, const std::string& interface, const std::string& replace, const std::vector<size_t>& opt_measurement_indexes, - const std::string& opt_nonce, size_t opt_slot_id)); + const std::string& opt_nonce, size_t opt_slot_id), + (override)); - // boot time checkpoints in log_service.cpp + // getBootTimeCheckpointLogEntries in log_services.cc MOCK_METHOD( void, PostDbusCallToIoContextThreadSafe, (const std::shared_ptr<boost::asio::io_context::strand>&, @@ -692,17 +778,20 @@ const boost::system::error_code&, const std::vector<std::tuple<std::string, int64_t, int64_t>>&)>&&, const std::string& service, const std::string& objpath, - const std::string& interface, const std::string& method)); - // boot time durations in log_service.cpp + const std::string& interface, const std::string& method), + (override)); + + // getBootTimeDurationLogEntries in log_services.cc MOCK_METHOD(void, PostDbusCallToIoContextThreadSafe, (const std::shared_ptr<boost::asio::io_context::strand>&, absl::AnyInvocable<void( const boost::system::error_code&, const std::vector<std::tuple<std::string, int64_t>>&)>&&, const std::string& service, const std::string& objpath, - const std::string& interface, const std::string& method)); + const std::string& interface, const std::string& method), + (override)); - // PLDMd reload file and sync cache for VMTPPR in bios.hpp + // PLDMd reload file and sync cache for VMTPPR in bios.h MOCK_METHOD(void, PostDbusCallToIoContextThreadSafe, (const std::shared_ptr<boost::asio::io_context::strand>&, absl::AnyInvocable<void(const boost::system::error_code&)>&&, @@ -711,24 +800,25 @@ uint16_t file_handle), (override)); - // Trigger has a special case for GetAll + // GetAll in trigger.h, telemetry_service.h MOCK_METHOD(void, PostDbusCallToIoContextThreadSafe, (const std::shared_ptr<boost::asio::io_context::strand>&, TriggerGetAllCb&&, const std::string& service, const std::string& objpath, const std::string& interface, - const std::string& get_all, - const std::string& target_interface)); + const std::string& get_all, const std::string& target_interface), + (override)); - // setPostPackageRepairConfig in log_service.cpp + // setPostPackageRepairConfig in log_services.cc MOCK_METHOD(void, PostDbusCallToIoContextThreadSafe, (const std::shared_ptr<boost::asio::io_context::strand>&, absl::AnyInvocable<void(const boost::system::error_code&, const bool&)>&&, const std::string& service, const std::string& objpath, const std::string& interface, const std::string& method, - const std::uint16_t& flag, const bool& data)); + const std::uint16_t& flag, const bool& data), + (override)); - // setPostPackageRepairData in log_service.cpp + // setPostPackageRepairData in log_services.cc MOCK_METHOD(void, PostDbusCallToIoContextThreadSafe, (const std::shared_ptr<boost::asio::io_context::strand>&, absl::AnyInvocable<void(const boost::system::error_code&, @@ -736,26 +826,30 @@ const std::string& service, const std::string& objpath, const std::string& interface, const std::string& method, const uint16_t repairEntryNum, const uint16_t repairType, - const uint16_t socNum, const std::vector<uint16_t>& payload)); + const uint16_t socNum, const std::vector<uint16_t>& payload), + (override)); + // startRuntimeRepair in log_services.cc MOCK_METHOD(void, PostDbusCallToIoContextThreadSafe, (const std::shared_ptr<boost::asio::io_context::strand>&, absl::AnyInvocable<void(const boost::system::error_code&, const uint32_t&)>&&, const std::string& service, const std::string& objpath, const std::string& interface, const std::string& method, - const uint16_t Index)); + const uint16_t Index), + (override)); - // nvmeMetricFetcher in nvme_metric_utils.hpp + // nvmeMetricFetcher returning unix_fd in nvme_metric_utils.h MOCK_METHOD(void, PostDbusCallToIoContextThreadSafe, (const std::shared_ptr<boost::asio::io_context::strand>&, absl::AnyInvocable<void(const boost::system::error_code&, const sdbusplus::message::unix_fd&)>&&, const std::string& service, const std::string& objpath, const std::string& interface, const std::string& method, - const std::string& arg)); + const std::string& arg), + (override)); - // nvmeMetricFetcher in nvme_metric_utils.hpp + // nvmeMetricFetcher returning message_t and unix_fd in nvme_metric_utils.h MOCK_METHOD(void, PostDbusCallToIoContextThreadSafe, (const std::shared_ptr<boost::asio::io_context::strand>&, absl::AnyInvocable<void(const boost::system::error_code&, @@ -763,7 +857,8 @@ const sdbusplus::message::unix_fd&)>&&, const std::string& service, const std::string& objpath, const std::string& interface, const std::string& method, - const std::string& arg)); + const std::string& arg), + (override)); // GetFeature in nvme_features.h MOCK_METHOD(void, PostDbusCallToIoContextThreadSafe, @@ -773,8 +868,44 @@ const std::vector<uint8_t>&)>&&, const std::string& service, const std::string& objpath, const std::string& interface, const std::string& method, - const std::string& arg)); + const std::string& arg), + (override)); + // SetFeature in nvme_features.h + MOCK_METHOD(void, PostDbusCallToIoContextThreadSafe, + (const std::shared_ptr<boost::asio::io_context::strand>&, + absl::AnyInvocable<void(const boost::system::error_code&, + const sdbusplus::message_t&)>&&, + const std::string& service, const std::string& objpath, + const std::string& interface, const std::string& method, + const std::string& feature_name, + const std::vector<uint8_t>& payload), + (override)); + + // AddReport in metric_report_definition.h + MOCK_METHOD(void, PostDbusCallToIoContextThreadSafe, + (const std::shared_ptr<boost::asio::io_context::strand>&, + absl::AnyInvocable<void(const boost::system::error_code&, + const std::string&)>&&, + const std::string&, const std::string&, const std::string&, + const std::string&, const std::string&, const std::string&, bool, + bool, uint64_t, const ReadingParameters&), + (override)); + + // SignCSR in google_service_root.h + MOCK_METHOD(void, PostDbusCallToIoContextThreadSafe, + (const std::shared_ptr<boost::asio::io_context::strand>&, + absl::AnyInvocable<void( + const boost::system::error_code&, const std::string&, + const std::string&, const std::string&, const std::string&, + const std::string&, const std::string&)>&&, + const std::string& service, const std::string& objpath, + const std::string& interface, const std::string& method, + const std::string& arg1, const std::string& arg2, + const std::string& arg3), + (override)); + + // nvmeMetricFetcher returning unix_fd in nvme_metric_utils.h MOCK_METHOD(void, PostDbusCallWithStringRetMsgAndFd, (const std::shared_ptr<boost::asio::io_context::strand>&, absl::AnyInvocable<void(const boost::system::error_code&, @@ -784,6 +915,8 @@ const std::string& interface, const std::string& method, const std::string& arg), (override)); + + // SignCSR in google_service_root.h MOCK_METHOD(void, PostDbusCallWithObjectPathAndTwoStrings, (const std::shared_ptr<boost::asio::io_context::strand>&, absl::AnyInvocable<void(const boost::system::error_code&, @@ -794,6 +927,7 @@ const std::string& arg2, const std::string& arg3), (override)); + // executeRootOfTrustCommand in google_service_root.h MOCK_METHOD(void, PostDbusCallWithObjectPath, (const std::shared_ptr<boost::asio::io_context::strand>&, absl::AnyInvocable<void(const boost::system::error_code&, @@ -831,13 +965,16 @@ template <typename Result, typename ArgumentTuple> Result Perform(const ArgumentTuple& args) const { // In SetProperty, callback is the 5th parameter (0 indexed) - boost::asio::post(managedStore::GetManagedObjectStore()->GetIoContext(), - [callback{std::move(std::get<5>(args))}]() mutable { - std::move(callback)(boost::system::error_code()); - }); + boost::asio::post( + managedStore::GetManagedObjectStore()->GetIoContext(), + [callback{std::move( + const_cast<std::decay_t<std::tuple_element_t<5, ArgumentTuple>>&>( + std::get<5>(args)))}]() mutable { + std::move(callback)(boost::system::error_code()); + }); } - inline static testing::PolymorphicAction< + static testing::PolymorphicAction< SimulateSuccessfulAsyncSetPropertyDbusCallAction> SimulateSuccessfulAsyncSetPropertyDbusCall() { return testing::MakePolymorphicAction( @@ -858,12 +995,15 @@ template <typename Result, typename ArgumentTuple> Result Perform(const ArgumentTuple& args) const { // In SetProperty, callback is the 5th parameter (0 indexed) - boost::asio::post(managedStore::GetManagedObjectStore()->GetIoContext(), - [callback{std::move(std::get<5>(args))}, - ec = this->ec_]() mutable { std::move(callback)(ec); }); + boost::asio::post( + managedStore::GetManagedObjectStore()->GetIoContext(), + [callback{std::move( + const_cast<std::decay_t<std::tuple_element_t<5, ArgumentTuple>>&>( + std::get<5>(args)))}, + ec = this->ec_]() mutable { std::move(callback)(ec); }); } - inline static testing::PolymorphicAction< + static testing::PolymorphicAction< SimulateFailedAsyncSetPropertyDbusCallAction> SimulateFailedAsyncSetPropertyDbusCall( std::optional<boost::system::error_code> ec = std::nullopt) { @@ -878,14 +1018,17 @@ public: template <typename Result, typename ArgumentTuple> Result Perform(const ArgumentTuple& args) const { - // In postDbusCallToIoContext, callback is the 0th parameter - boost::asio::post(managedStore::GetManagedObjectStore()->GetIoContext(), - [callback{std::move(std::get<1>(args))}]() mutable { - std::move(callback)(boost::system::error_code()); - }); + // In postDbusCallToIoContext, callback is the 1st parameter + boost::asio::post( + managedStore::GetManagedObjectStore()->GetIoContext(), + [callback{std::move( + const_cast<std::decay_t<std::tuple_element_t<1, ArgumentTuple>>&>( + std::get<1>(args)))}]() mutable { + std::move(callback)(boost::system::error_code()); + }); } - inline static testing::PolymorphicAction< + static testing::PolymorphicAction< SimulateSuccessfulAsyncPostDbusCallThreadSafeAction> SimulateSuccessfulAsyncPostDbusCall() { return testing::MakePolymorphicAction( @@ -904,15 +1047,17 @@ template <typename Result, typename ArgumentTuple> Result Perform(const ArgumentTuple& args) const { // In postDbusCallToIoContext, callback is the 0th parameter - boost::asio::post(managedStore::GetManagedObjectStore()->GetIoContext(), - [callback{std::move(std::get<1>(args))}, - dbus_object = this->dbus_object_]() mutable { - std::move(callback)(boost::system::error_code(), - *dbus_object); - }); + boost::asio::post( + managedStore::GetManagedObjectStore()->GetIoContext(), + [callback{std::move( + const_cast<std::decay_t<std::tuple_element_t<1, ArgumentTuple>>&>( + std::get<1>(args)))}, + dbus_object = this->dbus_object_]() mutable { + std::move(callback)(boost::system::error_code(), *dbus_object); + }); } - inline static testing::PolymorphicAction< + static testing::PolymorphicAction< SimulateSuccessfulAsyncPostDbusCallThreadSafeWithValueAction> SimulateSuccessfulAsyncPostDbusCallWithValue( const std::shared_ptr<DbusObjectType> dbusObject) { @@ -933,12 +1078,15 @@ template <typename Result, typename ArgumentTuple> Result Perform(const ArgumentTuple& args) const { // In postDbusCallToIoContext, callback is the 0th parameter - boost::asio::post(managedStore::GetManagedObjectStore()->GetIoContext(), - [callback{std::move(std::get<1>(args))}, - ec = this->ec_]() mutable { std::move(callback)(ec); }); + boost::asio::post( + managedStore::GetManagedObjectStore()->GetIoContext(), + [callback{std::move( + const_cast<std::decay_t<std::tuple_element_t<1, ArgumentTuple>>&>( + std::get<1>(args)))}, + ec = this->ec_]() mutable { std::move(callback)(ec); }); } - inline static testing::PolymorphicAction< + static testing::PolymorphicAction< SimulateFailedAsyncPostDbusCallThreadSafeAction> SimulateFailedAsyncPostDbusCall( std::optional<boost::system::error_code> ec = std::nullopt) { @@ -962,12 +1110,13 @@ // In postDbusCallToIoContext, callback is the 0th parameter boost::asio::post( managedStore::GetManagedObjectStore()->GetIoContext(), - [callback{std::move(std::get<1>(args))}, ec = this->ec_]() mutable { - std::move(callback)(ec, {}); - }); + [callback{std::move( + const_cast<std::decay_t<std::tuple_element_t<1, ArgumentTuple>>&>( + std::get<1>(args)))}, + ec = this->ec_]() mutable { std::move(callback)(ec, {}); }); } - inline static testing::PolymorphicAction< + static testing::PolymorphicAction< SimulateFailedAsyncPostDbusCallThreadSafeWithEmptyValueAction> SimulateFailedAsyncPostDbusCallWithEmptyValue( std::optional<boost::system::error_code> ec = std::nullopt) { @@ -992,11 +1141,14 @@ // In postDbusCallToIoContext, callback is the 0th parameter boost::asio::post( managedStore::GetManagedObjectStore()->GetIoContext(), - [callback{std::move(std::get<1>(args))}, ec = this->ec_, + [callback{std::move( + const_cast<std::decay_t<std::tuple_element_t<1, ArgumentTuple>>&>( + std::get<1>(args)))}, + ec = this->ec_, msg = this->msg_]() mutable { std::move(callback)(ec, msg, {}); }); } - inline static testing::PolymorphicAction< + static testing::PolymorphicAction< SimulateFailedAsyncPostDbusCallThreadSafeWithMsgAndEmptyValueAction> SimulateFailedAsyncPostDbusCallWithMsgAndEmptyValue( const sdbusplus::message_t& msg,
diff --git a/test/redfish-core/lib/manager_test.cpp b/test/redfish-core/lib/manager_test.cpp index 368dcff..c93dd77 100644 --- a/test/redfish-core/lib/manager_test.cpp +++ b/test/redfish-core/lib/manager_test.cpp
@@ -192,12 +192,10 @@ testing::_, testing::An< absl::AnyInvocable<void(const boost::system::error_code&)>&&>(), - "xyz.openbmc_project.State.Chassis", - testing::An<const std::string&>(), + "xyz.openbmc_project.State.Chassis", testing::_, "org.freedesktop.DBus.Properties", "Set", "xyz.openbmc_project.State.Chassis", "RequestedPowerTransition", - dbus::utility::DbusVariantType( - "xyz.openbmc_project.State.Chassis.Transition.PowerCycle"))) + testing::_)) .WillOnce( managedStore::SimulateSuccessfulAsyncPostDbusCallThreadSafeAction:: SimulateSuccessfulAsyncPostDbusCall());