diff options
Diffstat (limited to '3rdparty/bx/tests/thread_test.cpp')
-rw-r--r-- | 3rdparty/bx/tests/thread_test.cpp | 41 |
1 files changed, 36 insertions, 5 deletions
diff --git a/3rdparty/bx/tests/thread_test.cpp b/3rdparty/bx/tests/thread_test.cpp index 8d099311835..713781956fb 100644 --- a/3rdparty/bx/tests/thread_test.cpp +++ b/3rdparty/bx/tests/thread_test.cpp @@ -6,17 +6,37 @@ #include "test.h" #include <bx/thread.h> -int32_t threadExit0(void*) +bx::DefaultAllocator s_allocator; +bx::MpScUnboundedBlockingQueue<void> s_mpsc(&s_allocator); + +int32_t threadExit0(bx::Thread* _thread, void*) { - return 0; + _thread->pop(); + + s_mpsc.push(reinterpret_cast<void*>(uintptr_t(0x1300) ) ); + + return bx::kExitSuccess; +} + +int32_t threadExit1(bx::Thread* _thread, void*) +{ + BX_UNUSED(_thread); + + s_mpsc.push(reinterpret_cast<void*>(uintptr_t(0x89) ) ); + + return bx::kExitFailure; } -int32_t threadExit1(void*) +TEST_CASE("Semaphore", "") { - return 1; + bx::Semaphore sem; + REQUIRE(!sem.wait(10) ); + + sem.post(1); + REQUIRE(sem.wait() ); } -TEST_CASE("thread", "") +TEST_CASE("Thread", "") { bx::Thread th; @@ -24,6 +44,7 @@ TEST_CASE("thread", "") th.init(threadExit0); REQUIRE(th.isRunning() ); + th.push(NULL); th.shutdown(); REQUIRE(!th.isRunning() ); @@ -36,3 +57,13 @@ TEST_CASE("thread", "") REQUIRE(!th.isRunning() ); REQUIRE(th.getExitCode() == 1); } + +TEST_CASE("MpScUnboundedBlockingQueue", "") +{ + void* p0 = s_mpsc.pop(); + void* p1 = s_mpsc.pop(); + + uintptr_t result = uintptr_t(p0) | uintptr_t(p1); + + REQUIRE(result == 0x1389); +} |