diff options
author | David Robillard <d@drobilla.net> | 2022-08-18 13:18:52 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2022-08-18 14:33:37 -0400 |
commit | f65912600fc301cbdbb613f1df0dc29820f1da35 (patch) | |
tree | 43db69627433fbb8f5acd13c6cf0ef8a3c3b829d /test/sem_test.c | |
parent | c4b8ca3dc222b06c40ebcb416d653e17e88de858 (diff) | |
download | zix-f65912600fc301cbdbb613f1df0dc29820f1da35.tar.gz zix-f65912600fc301cbdbb613f1df0dc29820f1da35.tar.bz2 zix-f65912600fc301cbdbb613f1df0dc29820f1da35.zip |
Use conventional test executable names
Diffstat (limited to 'test/sem_test.c')
-rw-r--r-- | test/sem_test.c | 70 |
1 files changed, 0 insertions, 70 deletions
diff --git a/test/sem_test.c b/test/sem_test.c deleted file mode 100644 index 33859f1..0000000 --- a/test/sem_test.c +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2012-2021 David Robillard <d@drobilla.net> -// SPDX-License-Identifier: ISC - -#undef NDEBUG - -#include "zix/attributes.h" -#include "zix/sem.h" -#include "zix/thread.h" - -#include <assert.h> -#include <stdio.h> -#include <stdlib.h> - -static ZixSem sem; -static unsigned n_signals = 1024; - -static void* -reader(void* ZIX_UNUSED(arg)) -{ - printf("Reader starting\n"); - - for (unsigned i = 0; i < n_signals; ++i) { - zix_sem_wait(&sem); - } - - printf("Reader finished\n"); - return NULL; -} - -static void* -writer(void* ZIX_UNUSED(arg)) -{ - printf("Writer starting\n"); - - for (unsigned i = 0; i < n_signals; ++i) { - zix_sem_post(&sem); - } - - printf("Writer finished\n"); - return NULL; -} - -int -main(int argc, char** argv) -{ - if (argc > 2) { - printf("Usage: %s N_SIGNALS\n", argv[0]); - return 1; - } - - if (argc > 1) { - n_signals = (unsigned)strtol(argv[1], NULL, 10); - } - - printf("Testing %u signals...\n", n_signals); - - assert(!zix_sem_init(&sem, 0)); - - ZixThread reader_thread; // NOLINT - assert(!zix_thread_create(&reader_thread, 128, reader, NULL)); - - ZixThread writer_thread; // NOLINT - assert(!zix_thread_create(&writer_thread, 128, writer, NULL)); - - zix_thread_join(reader_thread, NULL); - zix_thread_join(writer_thread, NULL); - - zix_sem_destroy(&sem); - return 0; -} |