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/test_compat_libevent.c | |
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/test_compat_libevent.c')
-rw-r--r-- | src/test/test_compat_libevent.c | 48 |
1 files changed, 17 insertions, 31 deletions
diff --git a/src/test/test_compat_libevent.c b/src/test/test_compat_libevent.c index 96502df308..f3fe113012 100644 --- a/src/test/test_compat_libevent.c +++ b/src/test/test_compat_libevent.c @@ -30,38 +30,28 @@ test_compat_libevent_logging_callback(void *ignored) int previous_log = setup_capture_of_logs(LOG_DEBUG); libevent_logging_callback(_EVENT_LOG_DEBUG, "hello world"); - tt_int_op(mock_saved_log_number(), OP_EQ, 1); - tt_str_op(mock_saved_log_at(0), OP_EQ, - "Message from libevent: hello world\n"); - tt_int_op(mock_saved_severity_at(0), OP_EQ, LOG_DEBUG); + expect_log_msg("Message from libevent: hello world\n"); + expect_log_severity(LOG_DEBUG); mock_clean_saved_logs(); libevent_logging_callback(_EVENT_LOG_MSG, "hello world another time"); - tt_int_op(mock_saved_log_number(), OP_EQ, 1); - tt_str_op(mock_saved_log_at(0), OP_EQ, - "Message from libevent: hello world another time\n"); - tt_int_op(mock_saved_severity_at(0), OP_EQ, LOG_INFO); + expect_log_msg("Message from libevent: hello world another time\n"); + expect_log_severity(LOG_INFO); mock_clean_saved_logs(); libevent_logging_callback(_EVENT_LOG_WARN, "hello world a third time"); - tt_int_op(mock_saved_log_number(), OP_EQ, 1); - tt_str_op(mock_saved_log_at(0), OP_EQ, - "Warning from libevent: hello world a third time\n"); - tt_int_op(mock_saved_severity_at(0), OP_EQ, LOG_WARN); + expect_log_msg("Warning from libevent: hello world a third time\n"); + expect_log_severity(LOG_WARN); mock_clean_saved_logs(); libevent_logging_callback(_EVENT_LOG_ERR, "hello world a fourth time"); - tt_int_op(mock_saved_log_number(), OP_EQ, 1); - tt_str_op(mock_saved_log_at(0), OP_EQ, - "Error from libevent: hello world a fourth time\n"); - tt_int_op(mock_saved_severity_at(0), OP_EQ, LOG_ERR); + expect_log_msg("Error from libevent: hello world a fourth time\n"); + expect_log_severity(LOG_ERR); mock_clean_saved_logs(); libevent_logging_callback(42, "hello world a fifth time"); - tt_int_op(mock_saved_log_number(), OP_EQ, 1); - tt_str_op(mock_saved_log_at(0), OP_EQ, - "Message [42] from libevent: hello world a fifth time\n"); - tt_int_op(mock_saved_severity_at(0), OP_EQ, LOG_WARN); + expect_log_msg("Message [42] from libevent: hello world a fifth time\n"); + expect_log_severity(LOG_WARN); mock_clean_saved_logs(); libevent_logging_callback(_EVENT_LOG_DEBUG, @@ -78,8 +68,7 @@ test_compat_libevent_logging_callback(void *ignored) "012345678901234567890123456789" "012345678901234567890123456789" ); - tt_int_op(mock_saved_log_number(), OP_EQ, 1); - tt_str_op(mock_saved_log_at(0), OP_EQ, "Message from libevent: " + expect_log_msg("Message from libevent: " "012345678901234567890123456789" "012345678901234567890123456789" "012345678901234567890123456789" @@ -92,25 +81,22 @@ test_compat_libevent_logging_callback(void *ignored) "012345678901234567890123456789" "012345678901234567890123456789" "012345678901234567890123456789\n"); - tt_int_op(mock_saved_severity_at(0), OP_EQ, LOG_DEBUG); + expect_log_severity(LOG_DEBUG); mock_clean_saved_logs(); libevent_logging_callback(42, "xxx\n"); - tt_int_op(mock_saved_log_number(), OP_EQ, 1); - tt_str_op(mock_saved_log_at(0), OP_EQ, "Message [42] from libevent: xxx\n"); - tt_int_op(mock_saved_severity_at(0), OP_EQ, LOG_WARN); + expect_log_msg("Message [42] from libevent: xxx\n"); + expect_log_severity(LOG_WARN); suppress_libevent_log_msg("something"); mock_clean_saved_logs(); libevent_logging_callback(_EVENT_LOG_MSG, "hello there"); - tt_int_op(mock_saved_log_number(), OP_EQ, 1); - tt_str_op(mock_saved_log_at(0), OP_EQ, - "Message from libevent: hello there\n"); - tt_int_op(mock_saved_severity_at(0), OP_EQ, LOG_INFO); + expect_log_msg("Message from libevent: hello there\n"); + expect_log_severity(LOG_INFO); mock_clean_saved_logs(); libevent_logging_callback(_EVENT_LOG_MSG, "hello there something else"); - tt_int_op(mock_saved_log_number(), OP_EQ, 0); + expect_no_log_msg("hello there something else"); // No way of verifying the result of this, it seems =/ configure_libevent_logging(); |