diff options
Diffstat (limited to 'test/unit/mtx.c')
-rw-r--r-- | test/unit/mtx.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/test/unit/mtx.c b/test/unit/mtx.c index 2eccc98..0813a69 100644 --- a/test/unit/mtx.c +++ b/test/unit/mtx.c @@ -3,8 +3,7 @@ #define NTHREADS 2 #define NINCRS 2000000 -TEST_BEGIN(test_mtx_basic) -{ +TEST_BEGIN(test_mtx_basic) { mtx_t mtx; assert_false(mtx_init(&mtx), "Unexpected mtx_init() failure"); @@ -20,8 +19,7 @@ typedef struct { } thd_start_arg_t; static void * -thd_start(void *varg) -{ +thd_start(void *varg) { thd_start_arg_t *arg = (thd_start_arg_t *)varg; unsigned i; @@ -33,26 +31,26 @@ thd_start(void *varg) return (NULL); } -TEST_BEGIN(test_mtx_race) -{ +TEST_BEGIN(test_mtx_race) { thd_start_arg_t arg; thd_t thds[NTHREADS]; unsigned i; assert_false(mtx_init(&arg.mtx), "Unexpected mtx_init() failure"); arg.x = 0; - for (i = 0; i < NTHREADS; i++) + for (i = 0; i < NTHREADS; i++) { thd_create(&thds[i], thd_start, (void *)&arg); - for (i = 0; i < NTHREADS; i++) + } + for (i = 0; i < NTHREADS; i++) { thd_join(thds[i], NULL); + } assert_u_eq(arg.x, NTHREADS * NINCRS, "Race-related counter corruption"); } TEST_END int -main(void) -{ +main(void) { return (test( test_mtx_basic, test_mtx_race)); |