X-Git-Url: https://pd.if.org/git/?p=nbds;a=blobdiff_plain;f=test%2Fht_test.c;h=6d4a53b4821f7d20b7aba3bd2a851562eaeb62b5;hp=fd7652446706cd55a2a59dab1db106184a017f18;hb=177b35371e1918cb8d00211824acccca47688a4b;hpb=010e49988a8b12f78053c387b3798763b4e8df18 diff --git a/test/ht_test.c b/test/ht_test.c index fd76524..6d4a53b 100644 --- a/test/ht_test.c +++ b/test/ht_test.c @@ -7,8 +7,9 @@ #include "runtime.h" #include "CuTest.h" #include "common.h" -#include "ht.h" +#include "struct.h" #include "mem.h" +#include "lwt.h" #define ASSERT_EQUAL(x, y) CuAssertIntEquals(tc, x, y) @@ -98,17 +99,18 @@ void *simple_worker (void *arg) { SYNC_ADD(wd->wait, -1); do { } while (*((volatile worker_data_t *)wd)->wait); // wait for all workers to be ready - int i, j; - for (j = 0; j < 10; ++j) { - for (i = d; i < iters; i+=2) { - char key[8]; + for (int j = 0; j < 10; ++j) { + for (int i = d; i < iters; i+=2) { + char key[10]; sprintf(key, "k%u", i); - ASSERT_EQUAL( DOES_NOT_EXIST, ht_add(ht, key, strlen(key)+1, d+1) ); + TRACE("t0", "test ht_add() iteration (%llu, %llu)", j, i); + CuAssertIntEquals_Msg(tc, key, DOES_NOT_EXIST, ht_add(ht, key, strlen(key)+1, d+1) ); } - for (i = d; i < iters; i+=2) { - char key[8]; + for (int i = d; i < iters; i+=2) { + char key[10]; sprintf(key, "k%u", i); - ASSERT_EQUAL( d+1, ht_remove(ht, key, strlen(key)+1) ); + TRACE("t0", "test ht_remove() iteration (%llu, %llu)", j, i); + CuAssertIntEquals_Msg(tc, key, d+1, ht_remove(ht, key, strlen(key)+1) ); } rcu_update(); } @@ -159,7 +161,7 @@ void concurrent_insert (CuTest* tc) { int main (void) { nbd_init(); - //lwt_set_trace_level("h4"); + //lwt_set_trace_level("h0"); // Create and run test suite CuString *output = CuStringNew();