From c845efcb0a60a73266df3fde50c33e00152cff2c Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Mon, 28 Dec 2015 05:47:07 -0500 Subject: [PATCH] regressions/epoch: Various clean-up including fixes for Windows. --- .../ck_epoch/validate/ck_epoch_section.c | 21 ++++++------------- .../ck_epoch/validate/ck_epoch_section_2.c | 2 +- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/regressions/ck_epoch/validate/ck_epoch_section.c b/regressions/ck_epoch/validate/ck_epoch_section.c index 590258b..12bcca1 100644 --- a/regressions/ck_epoch/validate/ck_epoch_section.c +++ b/regressions/ck_epoch/validate/ck_epoch_section.c @@ -35,6 +35,8 @@ #include +#include "../../common.h" + static ck_epoch_t epc; static ck_epoch_record_t record, record2; static unsigned int cleanup_calls; @@ -91,9 +93,6 @@ test_simple_read_section(void) assert(cleanup_calls == 1); teardown_test(); - - printf("%s passed\n", __FUNCTION__); - return; } @@ -125,9 +124,6 @@ test_nested_read_section(void) assert(cleanup_calls == 2); teardown_test(); - - printf("%s passed\n", __FUNCTION__); - return; } @@ -171,7 +167,7 @@ reader_work(void *arg) * thread. */ ck_epoch_begin(&local_record, §ion); - usleep((rand() % 100) * 1000); + usleep((common_rand() % 100) * 1000); assert(ck_pr_load_uint(&o->destroyed) == 0); ck_epoch_end(&local_record, §ion); @@ -203,7 +199,7 @@ test_single_reader_with_barrier_thread(void) run = 1; memset(&o, 0, sizeof(struct obj)); - srand(time(NULL)); + common_srand(time(NULL)); setup_test(); if (pthread_create(&thread, NULL, barrier_work, &run) != 0) { @@ -221,7 +217,7 @@ test_single_reader_with_barrier_thread(void) /* Generate a shuffle. */ for (int i = num_sections - 1; i >= 0; i--) { - int k = rand() % (i + 1); + int k = common_rand() % (i + 1); int tmp = shuffled[k]; shuffled[k] = shuffled[i]; shuffled[i] = tmp; @@ -248,8 +244,6 @@ test_single_reader_with_barrier_thread(void) teardown_test(); - printf("%s passed\n", __FUNCTION__); - return; } @@ -265,7 +259,7 @@ test_multiple_readers_with_barrier_thread(void) run = 1; memset(&o, 0, sizeof(struct obj)); memset(§ion, 0, sizeof(ck_epoch_section_t)); - srand(time(NULL)); + common_srand(time(NULL)); setup_test(); /* Create a thread to call barrier() while we create reader threads. @@ -301,9 +295,6 @@ test_multiple_readers_with_barrier_thread(void) } teardown_test(); - - printf("%s passed\n", __FUNCTION__); - return; } diff --git a/regressions/ck_epoch/validate/ck_epoch_section_2.c b/regressions/ck_epoch/validate/ck_epoch_section_2.c index b9c2c1d..6a697b8 100644 --- a/regressions/ck_epoch/validate/ck_epoch_section_2.c +++ b/regressions/ck_epoch/validate/ck_epoch_section_2.c @@ -179,7 +179,7 @@ main(int argc, char *argv[]) pthread_create(threads + i, NULL, write_thread, NULL); } while (++i < n_wr + n_rd); - sleep(10); + common_sleep(10); ck_pr_store_uint(&leave, 1); for (i = 0; i < n_threads; i++)