diff options
| author | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2017-01-13 16:35:53 -0500 |
|---|---|---|
| committer | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2017-01-16 00:08:58 -0500 |
| commit | 21621437eed2e3a89b53bbd8db12b0bff021839b (patch) | |
| tree | de563b8901b21fcd234e63f220686191ae34447f /test | |
| parent | b9b929b670329583a2e564fcc5341deb641b3159 (diff) | |
| download | phosphor-inventory-manager-21621437eed2e3a89b53bbd8db12b0bff021839b.tar.gz phosphor-inventory-manager-21621437eed2e3a89b53bbd8db12b0bff021839b.zip | |
Use std::thread in favor of direct pthread access
Change-Id: I7f2927deee84701f3ed7bec86ec97171a5daabb8
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Diffstat (limited to 'test')
| -rw-r--r-- | test/Makefile.am | 2 | ||||
| -rw-r--r-- | test/test.cpp | 20 |
2 files changed, 7 insertions, 15 deletions
diff --git a/test/Makefile.am b/test/Makefile.am index 538d826..1f6470d 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -3,6 +3,6 @@ noinst_PROGRAMS = phosphor-inventory-test phosphor_inventory_test_SOURCES = \ test.cpp -phosphor_inventory_test_LDFLAGS = $(SYSTEMD_LIBS) +phosphor_inventory_test_LDFLAGS = $(SYSTEMD_LIBS) $(PTHREAD_CFLAGS) phosphor_inventory_test_CFLAGS = $(SYSTEMD_CFLAGS) phosphor_inventory_test_LDADD = ${top_builddir}/libmanager.la diff --git a/test/test.cpp b/test/test.cpp index 550e83f..a35a03b 100644 --- a/test/test.cpp +++ b/test/test.cpp @@ -18,20 +18,12 @@ #include <cassert> #include <iostream> #include <algorithm> +#include <thread> constexpr auto SERVICE = "phosphor.inventory.test"; constexpr auto INTERFACE = IFACE; constexpr auto ROOT = "/testing/inventory"; -auto server_thread(void* data) -{ - auto mgr = static_cast<phosphor::inventory::manager::Manager*>(data); - - mgr->run(); - - return static_cast<void*>(nullptr); -} - /** @class SignalQueue * @brief Store DBus signals in a queue. */ @@ -323,15 +315,15 @@ int main() sdbusplus::bus::new_default(), SERVICE, ROOT, INTERFACE); - pthread_t t; + auto f = [](auto mgr) { - pthread_create(&t, nullptr, server_thread, &mgr); - } - + mgr->run(); + }; + auto t = std::thread(f, &mgr); runTests(mgr); // Wait for server thread to exit. - pthread_join(t, nullptr); + t.join(); return 0; } |

