diff options
author | teor (Tim Wilson-Brown) <teor2345@gmail.com> | 2016-02-01 10:02:04 +1100 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2016-02-01 09:50:43 -0500 |
commit | f7b2ae91e9e6c9d4c3d5c993cd146829d3f1f3d7 (patch) | |
tree | 868a192841930239a9c598590fe01cc8d5cf34d2 /src/test/log_test_helpers.h | |
parent | dbb5819e96e6f31a9ed5c46cda7d7ba1265a362c (diff) | |
download | tor-f7b2ae91e9e6c9d4c3d5c993cd146829d3f1f3d7.tar.gz tor-f7b2ae91e9e6c9d4c3d5c993cd146829d3f1f3d7.zip |
Make all unit tests independent of log message order and count
Diffstat (limited to 'src/test/log_test_helpers.h')
-rw-r--r-- | src/test/log_test_helpers.h | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/src/test/log_test_helpers.h b/src/test/log_test_helpers.h index 3a565c67c5..298237dddb 100644 --- a/src/test/log_test_helpers.h +++ b/src/test/log_test_helpers.h @@ -23,10 +23,33 @@ void mock_clean_saved_logs(void); const smartlist_t *mock_saved_logs(void); int setup_capture_of_logs(int new_level); void teardown_capture_of_logs(int prev); -const char *mock_saved_log_at(int ix); -int mock_saved_severity_at(int ix); -int mock_saved_log_number(void); int mock_saved_log_has_message(const char *msg); +int mock_saved_log_has_severity(int severity); +int mock_saved_log_has_entry(void); + +#define expect_log_msg(str) \ + tt_assert_msg(mock_saved_log_has_message(str), \ + "expected log to contain " # str); + +#define expect_no_log_msg(str) \ + tt_assert_msg(!mock_saved_log_has_message(str), \ + "expected log to not contain " # str); + +#define expect_log_severity(severity) \ + tt_assert_msg(mock_saved_log_has_severity(severity), \ + "expected log to contain severity " # severity); + +#define expect_no_log_severity(severity) \ + tt_assert_msg(!mock_saved_log_has_severity(severity), \ + "expected log to not contain severity " # severity); + +#define expect_log_entry() \ + tt_assert_msg(mock_saved_log_has_entry(), \ + "expected log to contain entries"); + +#define expect_no_log_entry() \ + tt_assert_msg(!mock_saved_log_has_entry(), \ + "expected log to not contain entries"); #endif |