commit | c3d27e0a010fef2a36ceed7d0098789407e53b4c | [log] [tgz] |
---|---|---|
author | Andrew Jeffery <andrew@aj.id.au> | Fri Apr 28 12:44:29 2023 +0930 |
committer | Andrew Jeffery <andrew@aj.id.au> | Fri Apr 28 16:26:18 2023 +0930 |
tree | 25a454835688cf4cb07a4f82abdab5a085054b38 | |
parent | 9e64bb7987b6ec1b8744f1815eca884dbdddcfbc [diff] |
host-bmc: test: Avoid -Werror=overloaded-virtual Drop the const qualifier for the createHostEffecterMatch() mock to resolve the following error: ``` In file included from ../host-bmc/test/dbus_to_host_effecter_test.cpp:3: ../host-bmc/dbus_to_host_effecters.hpp:169:18: error: ‘virtual void pldm::host_effecters::HostEffecterParser::createHostEffecterMatch(const std::string&, const std::string&, size_t, size_t, uint16_t)’ was hidden [-Werror=overloaded-virtual=] 169 | virtual void createHostEffecterMatch(const std::string& objectPath, | ^~~~~~~~~~~~~~~~~~~~~~~ In file included from ../subprojects/googletest/googlemock/include/gmock/gmock-actions.h:147, from ../subprojects/googletest/googlemock/include/gmock/gmock.h:56, from ../common/test/mocked_utils.hpp:3, from ../host-bmc/test/dbus_to_host_effecter_test.cpp:1: ../host-bmc/test/dbus_to_host_effecter_test.cpp:28:23: note: by ‘testing::internal::Function<void(const std::__cxx11::basic_string<char>&, const std::__cxx11::basic_string<char>&, long unsigned int, long unsigned int, short unsigned int)>::Result MockHostEffecterParser::createHostEffecterMatch(testing::internal::ElemFromList<0, const std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, const std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, long unsigned int, long unsigned int, short unsigned int>::type, testing::internal::ElemFromList<1, const std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, const std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, long unsigned int, long unsigned int, short unsigned int>::type, testing::internal::ElemFromList<2, const std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, const std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, long unsigned int, long unsigned int, short unsigned int>::type, testing::internal::ElemFromList<3, const std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, const std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, long unsigned int, long unsigned int, short unsigned int>::type, testing::internal::ElemFromList<4, const std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, const std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, long unsigned int, long unsigned int, short unsigned int>::type) const’ 28 | MOCK_METHOD(void, createHostEffecterMatch, | ^~~~~~~~~~~~~~~~~~~~~~~ ../subprojects/googletest/googlemock/include/gmock/internal/gmock-pp.h:17:31: note: in definition of macro ‘GMOCK_PP_IDENTITY’ 17 | #define GMOCK_PP_IDENTITY(_1) _1 | ^~ ../subprojects/googletest/googlemock/include/gmock/gmock-function-mocker.h:132:3: note: in expansion of macro ‘GMOCK_INTERNAL_MOCK_METHOD_IMPL’ 132 | GMOCK_INTERNAL_MOCK_METHOD_IMPL( \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../subprojects/googletest/googlemock/include/gmock/internal/gmock-pp.h:152:39: note: in expansion of macro ‘GMOCK_INTERNAL_MOCK_METHOD_ARG_4’ 152 | #define GMOCK_PP_INTERNAL_CAT(_1, _2) _1##_2 | ^~ ../subprojects/googletest/googlemock/include/gmock/gmock-function-mocker.h:114:3: note: in expansion of macro ‘GMOCK_PP_VARIADIC_CALL’ 114 | GMOCK_PP_VARIADIC_CALL(GMOCK_INTERNAL_MOCK_METHOD_ARG_, __VA_ARGS__) \ | ^~~~~~~~~~~~~~~~~~~~~~ ../host-bmc/test/dbus_to_host_effecter_test.cpp:28:5: note: in expansion of macro ‘MOCK_METHOD’ 28 | MOCK_METHOD(void, createHostEffecterMatch, | ^~~~~~~~~~~ ../host-bmc/dbus_to_host_effecters.hpp:145:9: error: ‘virtual int pldm::host_effecters::HostEffecterParser::setHostStateEffecter(size_t, std::vector<state_field_for_state_effecter_set>&, uint16_t)’ was hidden [-Werror=overloaded-virtual=] 145 | setHostStateEffecter(size_t effecterInfoIndex, | ^~~~~~~~~~~~~~~~~~~~ ../host-bmc/test/dbus_to_host_effecter_test.cpp:24:23: note: by ‘testing::internal::Function<void(long unsigned int, std::vector<state_field_for_state_effecter_set>&, short unsigned int)>::Result MockHostEffecterParser::setHostStateEffecter(testing::internal::ElemFromList<0, long unsigned int, std::vector<state_field_for_state_effecter_set, std::allocator<state_field_for_state_effecter_set> >&, short unsigned int>::type, testing::internal::ElemFromList<1, long unsigned int, std::vector<state_field_for_state_effecter_set, std::allocator<state_field_for_state_effecter_set> >&, short unsigned int>::type, testing::internal::ElemFromList<2, long unsigned int, std::vector<state_field_for_state_effecter_set, std::allocator<state_field_for_state_effecter_set> >&, short unsigned int>::type) const’ 24 | MOCK_METHOD(void, setHostStateEffecter, | ^~~~~~~~~~~~~~~~~~~~ ../subprojects/googletest/googlemock/include/gmock/internal/gmock-pp.h:17:31: note: in definition of macro ‘GMOCK_PP_IDENTITY’ 17 | #define GMOCK_PP_IDENTITY(_1) _1 | ^~ ../subprojects/googletest/googlemock/include/gmock/gmock-function-mocker.h:132:3: note: in expansion of macro ‘GMOCK_INTERNAL_MOCK_METHOD_IMPL’ 132 | GMOCK_INTERNAL_MOCK_METHOD_IMPL( \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../subprojects/googletest/googlemock/include/gmock/internal/gmock-pp.h:152:39: note: in expansion of macro ‘GMOCK_INTERNAL_MOCK_METHOD_ARG_4’ 152 | #define GMOCK_PP_INTERNAL_CAT(_1, _2) _1##_2 | ^~ ../subprojects/googletest/googlemock/include/gmock/gmock-function-mocker.h:114:3: note: in expansion of macro ‘GMOCK_PP_VARIADIC_CALL’ 114 | GMOCK_PP_VARIADIC_CALL(GMOCK_INTERNAL_MOCK_METHOD_ARG_, __VA_ARGS__) \ | ^~~~~~~~~~~~~~~~~~~~~~ ../host-bmc/test/dbus_to_host_effecter_test.cpp:24:5: note: in expansion of macro ‘MOCK_METHOD’ 24 | MOCK_METHOD(void, setHostStateEffecter, | ^~~~~~~~~~~ ``` The warning was triggered by g++ on Fedora 38: ``` $ ( . /etc/os-release && echo $PRETTY_NAME ) Fedora Linux 38 (Server Edition) $ g++ --version g++ (GCC) 13.0.1 20230401 (Red Hat 13.0.1-0) Copyright (C) 2023 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ``` Signed-off-by: Andrew Jeffery <andrew@aj.id.au> Change-Id: I138e73d733f9c220e62534815b5a2d1ddcb85b8a
Need meson
and ninja
. Alternatively, source an OpenBMC ARM/x86 SDK.
meson build && ninja -C build
The simplest way of running the tests is as described by the meson man page:
meson builddir && meson test -C builddir
Alternatively, tests can be run in the OpenBMC CI docker container, or with an OpenBMC x86 sdk(see below for x86 steps).
meson -Doe-sdk=enabled build ninja -C build test
pldm daemon accepts a command line argument --verbose
or --v
or -v
to enable the daemon to run in verbose mode. It can be done via adding this option to the environment file that pldm service consumes.
echo 'PLDMD_ARGS="--verbose"' > /etc/default/pldmd systemctl restart pldmd
rm /etc/default/pldmd systemctl restart pldmd
At a high-level, code in this repository belongs to one of the following three components.
This library provides handlers for incoming PLDM request messages. It provides for a registration as well as a plug-in mechanism. The library is implemented in modern C++, and handles OpenBMC's platform specifics.
The handlers are of the form
Response handler(Request payload, size_t payloadLen)
Source files are named according to the PLDM Type, for eg base.[hpp/cpp], fru.[hpp/cpp], etc.
This will support OEM or vendor-specific functions and semantic information. Following directory structure has to be used:
pldm repo |---- oem |----<oem_name> |----libpldmresponder |---<oem based handler files>
<oem_name> - This folder must be created with the name of the OEM/vendor in lower case. Folders named libpldm and libpldmresponder must be created under the folder <oem_name>
Files having the oem functionality for the libpldmresponder library should be placed under the folder oem/<oem_name>/libpldmresponder. They must be adhering to the rules mentioned under the libpldmresponder section above.
Once the above is done a meson option has to be created in pldm/meson_options.txt
with its mapped compiler flag to enable conditional compilation.
For consistency would recommend using "oem-<oem_name>".
The pldm/meson.build
and the corresponding source file(s) will need to incorporate the logic of adding its mapped compiler flag to allow conditional compilation of the code.
pldm daemon links against the libpldm library during compilation, For more information on libpldm please refer to libpldm
For more information on pldmtool please refer to plmdtool/README.md.
This section documents important code flow paths.
a) PLDM daemon receives PLDM request message from underlying transport (MCTP).
b) PLDM daemon routes message to message handler, based on the PLDM command.
c) Message handler decodes request payload into various field(s) of the request message. It can make use of a decode_foo_req() API, and doesn't have to perform deserialization of the request payload by itself.
d) Message handler works with the request field(s) and generates response field(s).
e) Message handler prepares a response message. It can make use of an encode_foo_resp() API, and doesn't have to perform the serialization of the response field(s) by itself.
f) The PLDM daemon sends the response message prepared at step e) to the remote PLDM device.
a) A BMC PLDM requester app prepares a PLDM request message. There would be several requester apps (based on functionality/PLDM remote device). Each of them needn't bother with the serialization of request field(s), and can instead make use of an encode_foo_req() API.
b) BMC requester app requests PLDM daemon to send the request message to remote PLDM device.
c) Once the PLDM daemon receives a corresponding response message, it notifies the requester app.
d) The requester app has to work with the response field(s). It can make use of a decode_foo_resp() API to deserialize the response message.
While PLDM Platform Descriptor Records (PDRs) are mostly static information, they can vary across platforms and systems. For this reason, platform specific PDR information is encoded in platform specific JSON files. JSON files must be named based on the PDR type number. For example a state effecter PDR JSON file will be named 11.json. The JSON files may also include information to enable additional processing (apart from PDR creation) for specific PDR types, for eg mapping an effecter id to a D-Bus object.
The PLDM responder implementation finds and parses PDR JSON files to create the PDR repository. Platform specific PDR modifications would likely just result in JSON updates. New PDR type support would require JSON updates as well as PDR generation code. The PDR generator is a map of PDR Type -> C++ lambda to create PDR entries for that type based on the JSON, and to update the central PDR repo.