Timer fixes & tests added
This commit is contained in:
committed by
GitHub
parent
47377439dd
commit
4f89918e91
@@ -0,0 +1,34 @@
|
||||
#include "doctest.h"
|
||||
#include "tactility_core.h"
|
||||
#include "mutex.h"
|
||||
|
||||
static int thread_with_mutex_parameter(void* parameter) {
|
||||
Mutex mutex = (Mutex)parameter;
|
||||
tt_mutex_acquire(mutex, TtWaitForever);
|
||||
return 0;
|
||||
}
|
||||
|
||||
TEST_CASE("a mutex can block a thread") {
|
||||
Mutex mutex = tt_mutex_alloc(MutexTypeNormal);
|
||||
tt_mutex_acquire(mutex, TtWaitForever);
|
||||
|
||||
Thread* thread = tt_thread_alloc_ex(
|
||||
"thread",
|
||||
1024,
|
||||
&thread_with_mutex_parameter,
|
||||
mutex
|
||||
);
|
||||
tt_thread_start(thread);
|
||||
|
||||
tt_delay_ms(5);
|
||||
CHECK_EQ(tt_thread_get_state(thread), ThreadStateRunning);
|
||||
|
||||
tt_mutex_release(mutex);
|
||||
|
||||
tt_delay_ms(5);
|
||||
CHECK_EQ(tt_thread_get_state(thread), ThreadStateStopped);
|
||||
|
||||
tt_thread_join(thread);
|
||||
tt_thread_free(thread);
|
||||
tt_mutex_free(mutex);
|
||||
}
|
||||
Reference in New Issue
Block a user