summaryrefslogtreecommitdiff
path: root/project-base/tests/test_threads.c
diff options
context:
space:
mode:
Diffstat (limited to 'project-base/tests/test_threads.c')
-rw-r--r--project-base/tests/test_threads.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/project-base/tests/test_threads.c b/project-base/tests/test_threads.c
new file mode 100644
index 0000000..869afdf
--- /dev/null
+++ b/project-base/tests/test_threads.c
@@ -0,0 +1,32 @@
+
+volatile s32 val = 0;
+
+static void* test_t(void *args) {
+ thread_sleep(2000);
+ val = 50;
+}
+
+s32 test_detached_thread(int argc, char** argv) {
+ platform_init(argc, argv, CONFIG_DIRECTORY);
+
+ val = 0;
+ thread t = thread_start(test_t, 0);
+ thread_detach(&t);
+ error_if(val == 50);
+ thread_stop(&t);
+
+ platform_destroy();
+ success;
+}
+
+s32 test_joined_thread(int argc, char** argv) {
+ platform_init(argc, argv, CONFIG_DIRECTORY);
+
+ val = 0;
+ thread t = thread_start(test_t, 0);
+ thread_join(&t);
+ error_if(val != 50);
+
+ platform_destroy();
+ success;
+} \ No newline at end of file