diff options
author | Yang Gao <yangg@google.com> | 2016-01-19 23:56:40 -0800 |
---|---|---|
committer | Yang Gao <yangg@google.com> | 2016-01-19 23:56:40 -0800 |
commit | a5a5cab3604ed2aafb71df1019cfdf74d22fb1ba (patch) | |
tree | a6e67f205fc2a32fa833fbd3503def56742a3b7b /test | |
parent | f54ae7048fd14b1742165c2f1a713b8f4fedbe6f (diff) | |
parent | b8958ef88af132039ea17b0009688fc848b84d5f (diff) |
Merge pull request #4774 from ctiller/avl-simplify
Simplify AVL stress test
Diffstat (limited to 'test')
-rw-r--r-- | test/core/support/avl_test.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/test/core/support/avl_test.c b/test/core/support/avl_test.c index 6530fe4269..83cc263c69 100644 --- a/test/core/support/avl_test.c +++ b/test/core/support/avl_test.c @@ -3611,32 +3611,33 @@ static void test_badcase3(void) { gpr_avl_unref(avl); } -static void test_stress(void) { +static void test_stress(int amount_of_stress) { int added[1024]; int i, j; int deletions = 0; gpr_avl avl; - gpr_log(GPR_DEBUG, "test_stress"); + unsigned seed = (unsigned)time(NULL); + + gpr_log(GPR_DEBUG, "test_stress amount=%d seed=%u", amount_of_stress, seed); srand((unsigned)time(NULL)); avl = gpr_avl_create(&int_int_vtable); memset(added, 0, sizeof(added)); - for (i = 1; deletions < 1000; i++) { + for (i = 1; deletions < amount_of_stress; i++) { int idx = rand() % (int)GPR_ARRAY_SIZE(added); GPR_ASSERT(i); if (rand() < RAND_MAX / 2) { added[idx] = i; - fprintf(stderr, "avl = gpr_avl_add(avl, box(%d), box(%d)); /* d=%d */\n", - idx, i, deletions); + printf("avl = gpr_avl_add(avl, box(%d), box(%d)); /* d=%d */\n", idx, i, + deletions); avl = gpr_avl_add(avl, box(idx), box(i)); } else { deletions += (added[idx] != 0); added[idx] = 0; - fprintf(stderr, "avl = remove_int(avl, %d); /* d=%d */\n", idx, - deletions); + printf("avl = remove_int(avl, %d); /* d=%d */\n", idx, deletions); avl = remove_int(avl, idx); } for (j = 0; j < (int)GPR_ARRAY_SIZE(added); j++) { @@ -3665,7 +3666,7 @@ int main(int argc, char *argv[]) { test_badcase1(); test_badcase2(); test_badcase3(); - test_stress(); + test_stress(10); return 0; } |