diff options
author | Mark Janes <mark.a.janes@intel.com> | 2016-07-12 15:00:24 -0700 |
---|---|---|
committer | Mark Janes <mark.a.janes@intel.com> | 2017-06-19 14:04:46 -0700 |
commit | d9748fd514b830b8c37bbc6e3bbb9ccfdc861fad (patch) | |
tree | b1aa36e006081dd160ca006d88a944bed7c3ebd4 /retrace/daemon/test | |
parent | e75de4f823c032551d022cee102454a91d47fd2d (diff) |
Add thread test
Diffstat (limited to 'retrace/daemon/test')
-rw-r--r-- | retrace/daemon/test/CMakeLists.txt | 3 | ||||
-rw-r--r-- | retrace/daemon/test/retrace_thread_test.cpp | 62 |
2 files changed, 64 insertions, 1 deletions
diff --git a/retrace/daemon/test/CMakeLists.txt b/retrace/daemon/test/CMakeLists.txt index ca20885e..71c54f48 100644 --- a/retrace/daemon/test/CMakeLists.txt +++ b/retrace/daemon/test/CMakeLists.txt @@ -9,6 +9,7 @@ set (DAEMON_TEST_SRC retrace_daemon_test.cpp retrace_log_test.cpp retrace_metrics_test.cpp + retrace_thread_test.cpp main_test.cpp ) @@ -35,4 +36,4 @@ target_link_libraries(retrace_daemon_test add_test (NAME daemon_test COMMAND $<TARGET_FILE:retrace_daemon_test>) -Lint(DAEMON_TEST_SRC)
\ No newline at end of file +Lint(DAEMON_TEST_SRC) diff --git a/retrace/daemon/test/retrace_thread_test.cpp b/retrace/daemon/test/retrace_thread_test.cpp new file mode 100644 index 00000000..4b5f7234 --- /dev/null +++ b/retrace/daemon/test/retrace_thread_test.cpp @@ -0,0 +1,62 @@ +/************************************************************************** + * + * Copyright 2015 Intel Corporation + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + **************************************************************************/ + +#include <gtest/gtest.h> + +#include <string> +#include <vector> + +#include "glframe_thread.hpp" + +using glretrace::Thread; +class TestThread : public Thread { + public: + TestThread() : Thread("gtest thread") {} + ~TestThread() {} + void Run() { +#ifdef WIN32 + Sleep(20); +#else + usleep(20 * 1000); +#endif + } +}; + +TEST(Thread, StartStop) { + std::vector<Thread*> threads; + for (int i = 0; i < 10; ++i) { + threads.push_back(new TestThread()); + } + for (auto i : threads) { + i->Start(); + } + for (auto i : threads) { + i->Join(); + } + for (auto i : threads) { + delete i; + } +} + |