From cb116a189f04943562e7e464088ba421be7f4088 Mon Sep 17 00:00:00 2001 From: Mitya Selivanov Date: Sat, 8 Jun 2024 21:14:45 +0200 Subject: Remove LICENSE; Cleanup --- source/tests/mutex.test.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'source/tests/mutex.test.c') diff --git a/source/tests/mutex.test.c b/source/tests/mutex.test.c index 61c1caa..9261fb1 100644 --- a/source/tests/mutex.test.c +++ b/source/tests/mutex.test.c @@ -3,7 +3,11 @@ #define KIT_TEST_FILE mutex #include "../kit/test.h" -enum { SLEEP = 400000000, TICK_COUNT = 200, THREAD_COUNT = 100 }; +enum { + TEST_MUTEX_SLEEP = 400000000, + TEST_MUTEX_TICK_COUNT = 200, + TEST_MUTEX_THREAD_COUNT = 100, +}; typedef struct { mtx_t lock; @@ -13,7 +17,7 @@ typedef struct { static int mtx_test_run(void *data) { int i; mtx_test_data_t *x = (mtx_test_data_t *) data; - for (i = 0; i < TICK_COUNT; i++) { + for (i = 0; i < TEST_MUTEX_TICK_COUNT; i++) { mtx_lock(&x->lock); x->value += i; @@ -33,13 +37,13 @@ TEST("mutex lock") { ptrdiff_t i; mtx_test_data_t data; - thrd_t pool[THREAD_COUNT]; + thrd_t pool[TEST_MUTEX_THREAD_COUNT]; data.value = 42; REQUIRE(mtx_init(&data.lock, mtx_plain) == thrd_success); - for (i = 0; i < THREAD_COUNT; i++) + for (i = 0; i < TEST_MUTEX_THREAD_COUNT; i++) thrd_create(pool + i, mtx_test_run, &data); - for (i = 0; i < THREAD_COUNT; i++) thrd_join(pool[i], NULL); + for (i = 0; i < TEST_MUTEX_THREAD_COUNT; i++) thrd_join(pool[i], NULL); mtx_destroy(&data.lock); REQUIRE(data.value == 42); @@ -49,7 +53,7 @@ static int test_lock(void *data) { mtx_t *m = (mtx_t *) data; mtx_lock(m); - struct timespec sec = { .tv_sec = 0, .tv_nsec = SLEEP }; + struct timespec sec = { .tv_sec = 0, .tv_nsec = TEST_MUTEX_SLEEP }; thrd_sleep(&sec, NULL); mtx_unlock(m); @@ -64,7 +68,7 @@ TEST("mutex try lock") { thrd_t t; REQUIRE(thrd_create(&t, test_lock, &m) == thrd_success); - struct timespec sec = { .tv_sec = 0, .tv_nsec = SLEEP / 2 }; + struct timespec sec = { .tv_sec = 0, .tv_nsec = TEST_MUTEX_SLEEP / 2 }; REQUIRE(thrd_sleep(&sec, NULL) == thrd_success); REQUIRE(mtx_trylock(&m) == thrd_busy); -- cgit v1.2.3