diff options
author | Nick Mathewson <nickm@torproject.org> | 2016-09-07 13:49:18 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2016-09-07 13:49:18 -0400 |
commit | 9d933bbacf4cde4b20d00495cc40d1fe62a5cd10 (patch) | |
tree | 54564870c1fe45a7c8132fcd5cdb5ecbf44278ae /src/test/test_dir.c | |
parent | 075c52084dbcf09cc73efbc2bbf34c7148314329 (diff) | |
download | tor-9d933bbacf4cde4b20d00495cc40d1fe62a5cd10.tar.gz tor-9d933bbacf4cde4b20d00495cc40d1fe62a5cd10.zip |
Capture and enforce BUG warnings in dir/param_voting_lookup
Diffstat (limited to 'src/test/test_dir.c')
-rw-r--r-- | src/test/test_dir.c | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/src/test/test_dir.c b/src/test/test_dir.c index 09c3e053b2..65b04af779 100644 --- a/src/test/test_dir.c +++ b/src/test/test_dir.c @@ -1587,23 +1587,46 @@ test_dir_param_voting_lookup(void *arg) tt_int_op(99, OP_EQ, dirvote_get_intermediate_param_value(lst, "abcd", 1000)); - /* moomin appears twice. */ + /* moomin appears twice. That's a bug. */ + tor_capture_bugs_(1); tt_int_op(-100, OP_EQ, dirvote_get_intermediate_param_value(lst, "moomin", -100)); - /* fred and jack are truncated */ + tt_int_op(smartlist_len(tor_get_captured_bug_log_()), OP_EQ, 1); + tt_str_op(smartlist_get(tor_get_captured_bug_log_(), 0), OP_EQ, + "!(n_found > 1)"); + tor_end_capture_bugs_(); + /* There is no 'fred=', so that is treated as not existing. */ tt_int_op(-100, OP_EQ, dirvote_get_intermediate_param_value(lst, "fred", -100)); + /* jack is truncated */ + tor_capture_bugs_(1); tt_int_op(-100, OP_EQ, dirvote_get_intermediate_param_value(lst, "jack", -100)); + tt_int_op(smartlist_len(tor_get_captured_bug_log_()), OP_EQ, 1); + tt_str_op(smartlist_get(tor_get_captured_bug_log_(), 0), OP_EQ, + "!(! ok)"); + tor_end_capture_bugs_(); /* electricity and opa aren't integers. */ + tor_capture_bugs_(1); tt_int_op(-100, OP_EQ, dirvote_get_intermediate_param_value(lst, "electricity", -100)); + tt_int_op(smartlist_len(tor_get_captured_bug_log_()), OP_EQ, 1); + tt_str_op(smartlist_get(tor_get_captured_bug_log_(), 0), OP_EQ, + "!(! ok)"); + tor_end_capture_bugs_(); + + tor_capture_bugs_(1); tt_int_op(-100, OP_EQ, dirvote_get_intermediate_param_value(lst, "opa", -100)); + tt_int_op(smartlist_len(tor_get_captured_bug_log_()), OP_EQ, 1); + tt_str_op(smartlist_get(tor_get_captured_bug_log_(), 0), OP_EQ, + "!(! ok)"); + tor_end_capture_bugs_(); done: SMARTLIST_FOREACH(lst, char *, cp, tor_free(cp)); smartlist_free(lst); + tor_end_capture_bugs_(); } #undef dirvote_compute_params |