X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=test%2Fstress%2Fmisc%2Fbarrier_driver.cpp;h=438d033a88798b1949ebe1d4f9525ffa4de4093c;hb=197419a18f00be2e7478e07ab03025856cd5bf34;hp=e21f9f7acaab8993ac162ef03b554e218ed82a70;hpb=df58fae11f80f03ca5b50c800f2978b1ff08efea;p=libcds.git diff --git a/test/stress/misc/barrier_driver.cpp b/test/stress/misc/barrier_driver.cpp index e21f9f7a..438d033a 100644 --- a/test/stress/misc/barrier_driver.cpp +++ b/test/stress/misc/barrier_driver.cpp @@ -1,3 +1,4 @@ +#include "common.h" #include #include #include @@ -12,25 +13,30 @@ namespace { typedef cds_others::SpinBarrier Barrier; +static size_t s_nBarrierThreadCount = 6; +static size_t s_nBarrierPassCount = 100000000; + class BarrierTest : public cds_test::stress_fixture { protected: static Barrier *barrier; static int count; - static const int kThreads = 6; - static const int kPassCount = 10000; - static void SetUpTestCase() {} + static void SetUpTestCase() { + cds_test::config const &cfg = get_config("Misc"); + GetConfig(BarrierPassCount); + GetConfig(BarrierThreadCount); + } static void TearDownTestCase() { - assert (count == kPassCount*kPassCount); + if (count != s_nBarrierPassCount) { + cout << "Incorrect" << endl; + } } static void Thread() { - for (int i = 0; i < kPassCount; i++) { - for (int j = 0; j < kPassCount; j++) { - if (barrier->wait()) { - count++; - } + for (ullong i = 0; i < s_nBarrierPassCount; i++) { + if (barrier->wait()) { + count++; } } } @@ -38,17 +44,15 @@ protected: Barrier *BarrierTest::barrier; int BarrierTest::count; -const int BarrierTest::kThreads; TEST_F(BarrierTest, Wait) { - barrier = new Barrier(kThreads); - int num_threads = kThreads; - std::thread *threads = new std::thread[num_threads]; - for (int i = 0; i < num_threads; i++) { + barrier = new Barrier(s_nBarrierThreadCount); + std::thread *threads = new std::thread[s_nBarrierThreadCount]; + for (int i = 0; i < s_nBarrierThreadCount; i++) { threads[i] = std::thread(Thread); } - for (int i = 0; i < num_threads; i++) { + for (int i = 0; i < s_nBarrierThreadCount; i++) { threads[i].join(); } }