diff options
author | Andrew Geissler <geissonator@yahoo.com> | 2019-02-11 19:56:57 -0600 |
---|---|---|
committer | Matt Spinler <spinler@us.ibm.com> | 2019-04-05 15:05:32 +0000 |
commit | 5b2e72765e4f547dd74a139f703c957c41a9078a (patch) | |
tree | 5fd0d8e7a866a1736db949f9e646518b34599aff | |
parent | bb7b592eb7818554f27fc99dbe3fe76cb4a116a5 (diff) | |
download | phosphor-objmgr-5b2e72765e4f547dd74a139f703c957c41a9078a.tar.gz phosphor-objmgr-5b2e72765e4f547dd74a139f703c957c41a9078a.zip |
unit-test: Request distinct name per test app
gtest will run test suites in parallel, need to ensure each test suite
(application) requests a distinct well-known name on Dbus.
Change-Id: Ib59211ada5ef6404e70747b7377912384cc8c60e
Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
-rw-r--r-- | src/test/util/asio_server_class.hpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/test/util/asio_server_class.hpp b/src/test/util/asio_server_class.hpp index 34b2095..43afa87 100644 --- a/src/test/util/asio_server_class.hpp +++ b/src/test/util/asio_server_class.hpp @@ -3,6 +3,9 @@ #include <sdbusplus/asio/connection.hpp> #include <sdbusplus/asio/object_server.hpp> +/* @brief Will contain path and name of test application */ +const char* appname = program_invocation_name; + #include <gtest/gtest.h> /** @class AsioServerClassTest * @@ -19,7 +22,13 @@ class AsioServerClassTest : public testing::Test boost::asio::io_context io; auto conn = std::make_shared<sdbusplus::asio::connection>(io); - conn->request_name("xyz.openbmc_project.ObjMgr.Test"); + // Need a distinct name for the bus since multiple test applications + // will be running at same time + std::string dbusName = {"xyz.openbmc_project.ObjMgr.Test."}; + std::string fullAppPath = {appname}; + std::size_t fileNameLoc = fullAppPath.find_last_of("/\\"); + dbusName += fullAppPath.substr(fileNameLoc + 1); + conn->request_name(dbusName.c_str()); server = new sdbusplus::asio::object_server(conn); } |