From: Mathieu Desnoyers Date: Wed, 5 Dec 2012 11:12:42 +0000 (-0500) Subject: test wfcqueue: enforce external mutex if needed by default X-Git-Tag: v0.8.0~135 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=372b9ad7acc40810bbcec6a796c71b54901b3ca7;p=urcu.git test wfcqueue: enforce external mutex if needed by default Signed-off-by: Mathieu Desnoyers --- diff --git a/tests/test_urcu_wfcq.c b/tests/test_urcu_wfcq.c index ccd5cf1..939bf7a 100644 --- a/tests/test_urcu_wfcq.c +++ b/tests/test_urcu_wfcq.c @@ -69,12 +69,14 @@ static inline pid_t gettid(void) #include enum test_sync { - TEST_SYNC_MUTEX = 0, - TEST_SYNC_NONE, + TEST_SYNC_NONE = 0, + TEST_SYNC_MUTEX, }; static enum test_sync test_sync; +static int test_force_sync; + static volatile int test_go, test_stop_enqueue, test_stop_dequeue; static unsigned long rduration; @@ -349,8 +351,8 @@ static void show_usage(int argc, char **argv) printf(" [-q] (test dequeue)"); printf(" [-s] (test splice, enabled by default)"); printf(" [-M] (use mutex external synchronization)"); - printf(" [-0] (use no external synchronization)"); - printf(" Note: default: mutex external synchronization used."); + printf(" Note: default: no external synchronization used."); + printf(" [-f] (force user-provided synchronization)"); printf(" [-w] Wait for dequeuer to empty queue"); printf("\n"); } @@ -432,12 +434,12 @@ int main(int argc, char **argv) case 'M': test_sync = TEST_SYNC_MUTEX; break; - case '0': - test_sync = TEST_SYNC_NONE; - break; case 'w': test_wait_empty = 1; break; + case 'f': + test_force_sync = 1; + break; } } @@ -445,6 +447,17 @@ int main(int argc, char **argv) if (!test_dequeue && !test_splice) test_splice = 1; + if (test_sync == TEST_SYNC_NONE && nr_dequeuers > 1 && test_dequeue) { + if (test_force_sync) { + fprintf(stderr, "[WARNING] Using dequeue concurrently " + "with other dequeue or splice without external " + "synchronization. Expect run-time failure.\n"); + } else { + printf("Enforcing mutex synchronization\n"); + test_sync = TEST_SYNC_MUTEX; + } + } + printf_verbose("running test for %lu seconds, %u enqueuers, " "%u dequeuers.\n", duration, nr_enqueuers, nr_dequeuers);