Skip to content

Commit

Permalink
Refactor: rename macro try to try_to
Browse files Browse the repository at this point in the history
To mute the warning from the compiler that it hides the
try keyword.

Change-Id: If061aa0ab95e74bd788c4f06d1ae5c91315ee78f
Reviewed-on: http://review.couchbase.org/75787
Tested-by: Build Bot <build@couchbase.com>
Reviewed-by: David Haikney <david.haikney@couchbase.com>
  • Loading branch information
trondn committed Mar 28, 2017
1 parent c113cd2 commit ba65396
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 19 deletions.
25 changes: 13 additions & 12 deletions tests/btree_purge/purge.cc
Expand Up @@ -565,7 +565,7 @@ void test_no_purge_items()
ctx[0] = N;
ctx[1] = 1;
remove(testpurgefile);
try(couchstore_open_db(testpurgefile, COUCHSTORE_OPEN_FLAG_CREATE, &db));
try_to(couchstore_open_db(testpurgefile, COUCHSTORE_OPEN_FLAG_CREATE, &db));
root = insert_items(&db->file, NULL, count_reduce, count_rereduce, N);
cb_assert(root != NULL);

Expand All @@ -584,7 +584,7 @@ void test_no_purge_items()
cb_assert(redval == N);
fprintf(stderr, "Reduce value after guided purge equals N\n");

try(iter_btree(&db->file, newroot, &ctx, check_vals_callback));
try_to(iter_btree(&db->file, newroot, &ctx, check_vals_callback));
fprintf(stderr, "Btree has same values after guided purge\n");

cleanup:
Expand All @@ -610,7 +610,7 @@ void test_all_purge_items()

N = 211341;
remove(testpurgefile);
try(couchstore_open_db(testpurgefile, COUCHSTORE_OPEN_FLAG_CREATE, &db));
try_to(couchstore_open_db(testpurgefile, COUCHSTORE_OPEN_FLAG_CREATE, &db));
root = insert_items(&db->file, NULL, count_reduce, count_rereduce, N);
cb_assert(root != NULL);

Expand Down Expand Up @@ -657,7 +657,7 @@ void test_partial_purge_items()
exp_evenodd[1] = N / 2 + N % 2;

remove(testpurgefile);
try(couchstore_open_db(testpurgefile, COUCHSTORE_OPEN_FLAG_CREATE, &db));
try_to(couchstore_open_db(testpurgefile, COUCHSTORE_OPEN_FLAG_CREATE, &db));
root = insert_items(&db->file, NULL, evenodd_reduce, evenodd_rereduce, N);
cb_assert(root != NULL);

Expand All @@ -674,7 +674,7 @@ void test_partial_purge_items()
cb_assert(red_intval(newroot, 0) == exp_evenodd[0] && red_intval(newroot, 1) == 0);
fprintf(stderr, "Reduce value after guided purge equals {NumEven, 0}\n");

try(iter_btree(&db->file, newroot, NULL, check_odd_callback));
try_to(iter_btree(&db->file, newroot, NULL, check_odd_callback));
fprintf(stderr, "Btree has no odd values after guided purge\n");

cleanup:
Expand All @@ -698,7 +698,7 @@ void test_partial_purge_items2()

N = 320000;
remove(testpurgefile);
try(couchstore_open_db(testpurgefile, COUCHSTORE_OPEN_FLAG_CREATE, &db));
try_to(couchstore_open_db(testpurgefile, COUCHSTORE_OPEN_FLAG_CREATE, &db));
root = insert_items(&db->file, NULL, uniq_reduce, uniq_rereduce, N);
cb_assert(root != NULL);

Expand All @@ -722,7 +722,8 @@ void test_partial_purge_items2()
cb_assert(red_intval(newroot, 0) == N / 2 && range_start == 0 && range_end == 31);
fprintf(stderr, "Reduce value after guided purge equals {0, 31}\n");

try(iter_btree(&db->file, newroot, &iter_context, check_skiprange_callback));
try_to(iter_btree(
&db->file, newroot, &iter_context, check_skiprange_callback));
fprintf(stderr, "Btree has only values within the range {0, 31} and keys are sorted\n");

cleanup:
Expand All @@ -749,7 +750,7 @@ void test_partial_purge_with_stop()
exp_evenodd[1] = N / 2 + N % 2;

remove(testpurgefile);
try(couchstore_open_db(testpurgefile, COUCHSTORE_OPEN_FLAG_CREATE, &db));
try_to(couchstore_open_db(testpurgefile, COUCHSTORE_OPEN_FLAG_CREATE, &db));
root = insert_items(&db->file, NULL, evenodd_reduce, evenodd_rereduce, N);
cb_assert(root != NULL);

Expand All @@ -767,7 +768,7 @@ void test_partial_purge_with_stop()
cb_assert(red_intval(newroot, 1) == (exp_evenodd[1] - 4));
fprintf(stderr, "Reduce value after guided purge equals {NumEven, NumOdd-4}\n");

try(iter_btree(&db->file, newroot, NULL, check_odd_stop_callback));
try_to(iter_btree(&db->file, newroot, NULL, check_odd_stop_callback));
fprintf(stderr, "Btree does not contain first 4 odd values after guided purge\n");

cleanup:
Expand Down Expand Up @@ -797,7 +798,7 @@ void test_add_remove_purge()
exp_evenodd[1] = N / 2 + N % 2;

remove(testpurgefile);
try(couchstore_open_db(testpurgefile, COUCHSTORE_OPEN_FLAG_CREATE, &db));
try_to(couchstore_open_db(testpurgefile, COUCHSTORE_OPEN_FLAG_CREATE, &db));
root = insert_items(&db->file, NULL, evenodd_reduce, evenodd_rereduce, N);
cb_assert(root != NULL);

Expand Down Expand Up @@ -846,7 +847,7 @@ void test_add_remove_purge()
cb_assert(red_intval(newroot, 0) == (exp_evenodd[0] - 2) && red_intval(newroot, 1) == 0);
fprintf(stderr, "Btree reduce value equals - {NumEven-2, 0}\n");

try(iter_btree(&db->file, newroot, NULL, check_odd2_callback));
try_to(iter_btree(&db->file, newroot, NULL, check_odd2_callback));
fprintf(stderr, "Btree has no odd values after guided purge\n");
fprintf(stderr, "Keys 4,10,200000 are not in tree after guided purge\n");

Expand Down Expand Up @@ -874,7 +875,7 @@ void test_only_single_leafnode()
fprintf(stderr, "\nExecuting test_only_single_leafnode...\n");
N = 2;
remove(testpurgefile);
try(couchstore_open_db(testpurgefile, COUCHSTORE_OPEN_FLAG_CREATE, &db));
try_to(couchstore_open_db(testpurgefile, COUCHSTORE_OPEN_FLAG_CREATE, &db));
root = insert_items(&db->file, NULL, count_reduce, count_rereduce, N);
cb_assert(root != NULL);

Expand Down
17 changes: 10 additions & 7 deletions tests/macros.h
Expand Up @@ -24,13 +24,16 @@
} \
} while (0)

#define try(C) \
do { \
if((errcode = (C)) < 0) { \
fprintf(stderr, "Couchstore error `%s' at %s:%d\r\n", \
couchstore_strerror((couchstore_error_t)errcode), __FILE__, __LINE__); \
goto cleanup; \
} \
#define try_to(C) \
do { \
if ((errcode = (C)) < 0) { \
fprintf(stderr, \
"Couchstore error `%s' at %s:%d\r\n", \
couchstore_strerror((couchstore_error_t)errcode), \
__FILE__, \
__LINE__); \
goto cleanup; \
} \
} while (0)

#define error_unless(C, E) \
Expand Down

0 comments on commit ba65396

Please sign in to comment.