diff options
| author | Andrew Geissler <geissonator@yahoo.com> | 2019-02-08 14:07:56 -0600 |
|---|---|---|
| committer | Matt Spinler <spinler@us.ibm.com> | 2019-04-05 15:05:32 +0000 |
| commit | b04f0335379773c87ed0f8cb259ea37cef80981b (patch) | |
| tree | 3ff42b768f01ba0914c57eed3e689bf7550f127c /src/test/util/asio_server_class.hpp | |
| parent | 271b7dd00648c8a0d004e57b2c53ca642a6d3a42 (diff) | |
| download | phosphor-objmgr-b04f0335379773c87ed0f8cb259ea37cef80981b.tar.gz phosphor-objmgr-b04f0335379773c87ed0f8cb259ea37cef80981b.zip | |
unit-test: Move asio server to its own class
Other test suites will need this object so move to a utility directory
and inherit from.
Change-Id: Ia34c8149fc0df02c510717a6efd21f51086e97e6
Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
Diffstat (limited to 'src/test/util/asio_server_class.hpp')
| -rw-r--r-- | src/test/util/asio_server_class.hpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/test/util/asio_server_class.hpp b/src/test/util/asio_server_class.hpp new file mode 100644 index 0000000..34b2095 --- /dev/null +++ b/src/test/util/asio_server_class.hpp @@ -0,0 +1,34 @@ +#include "src/associations.hpp" + +#include <sdbusplus/asio/connection.hpp> +#include <sdbusplus/asio/object_server.hpp> + +#include <gtest/gtest.h> +/** @class AsioServerClassTest + * + * @brief Provide wrapper for creating asio::object_server for test suite + */ +class AsioServerClassTest : public testing::Test +{ + protected: + // Make this global to the whole test suite since we want to share + // the asio::object_server accross the test cases + // NOTE - latest googltest changed to SetUpTestSuite() + static void SetUpTestCase() + { + boost::asio::io_context io; + auto conn = std::make_shared<sdbusplus::asio::connection>(io); + + conn->request_name("xyz.openbmc_project.ObjMgr.Test"); + server = new sdbusplus::asio::object_server(conn); + } + + // NOTE - latest googltest changed to TearDownTestSuite() + static void TearDownTestCase() + { + delete server; + server = nullptr; + } + + static sdbusplus::asio::object_server* server; +}; |

