diff --git a/src/test/log_test_helpers.c b/src/test/log_test_helpers.c index 88d28e1cc0..bcf73a8437 100644 --- a/src/test/log_test_helpers.c +++ b/src/test/log_test_helpers.c @@ -35,48 +35,6 @@ mock_clean_saved_logs(void) saved_logs = NULL; } -static mock_saved_log_entry_t * -mock_get_log_entry(int ix) -{ - int saved_log_count = mock_saved_log_number(); - if (ix < 0) { - ix = saved_log_count + ix; - } - - if (saved_log_count <= ix) - return NULL; - - return smartlist_get(saved_logs, ix); -} - -const char * -mock_saved_log_at(int ix) -{ - mock_saved_log_entry_t *ent = mock_get_log_entry(ix); - if (ent) - return ent->generated_msg; - else - return ""; -} - -int -mock_saved_severity_at(int ix) -{ - mock_saved_log_entry_t *ent = mock_get_log_entry(ix); - if (ent) - return ent->severity; - else - return -1; -} - -int -mock_saved_log_number(void) -{ - if (!saved_logs) - return 0; - return smartlist_len(saved_logs); -} - const smartlist_t * mock_saved_logs(void) { @@ -100,6 +58,33 @@ mock_saved_log_has_message(const char *msg) return has_msg; } +/* Do the saved logs have any messages with severity? */ +int +mock_saved_log_has_severity(int severity) +{ + int has_sev = 0; + if (saved_logs) { + SMARTLIST_FOREACH(saved_logs, mock_saved_log_entry_t *, m, + { + if (m->severity == severity) { + has_sev = 1; + } + }); + } + + return has_sev; +} + +/* Do the saved logs have any messages? */ +int +mock_saved_log_has_entry(void) +{ + if (saved_logs) { + return smartlist_len(saved_logs) > 0; + } + return 0; +} + void mock_saving_logv(int severity, log_domain_mask_t domain, const char *funcname, const char *suffix, 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 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(); diff --git a/src/test/test_options.c b/src/test/test_options.c index ea5f29e216..2d48cd17f5 100644 --- a/src/test/test_options.c +++ b/src/test/test_options.c @@ -392,14 +392,6 @@ free_options_test_data(options_test_data_t *td) tor_free(td); } -#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); - static void test_options_validate__uname_for_server(void *ignored) { @@ -436,7 +428,7 @@ test_options_validate__uname_for_server(void *ignored) fixed_get_uname_result = "Windows 2000"; mock_clean_saved_logs(); options_validate(tdata->old_opt, tdata->opt, tdata->def_opt, 0, &msg); - tt_int_op(mock_saved_log_number(), OP_EQ, 1); + expect_log_entry(); tor_free(msg); done: @@ -992,9 +984,9 @@ test_options_validate__relay_with_hidden_services(void *ignored) /* options_test_data_t *tdata = get_options_test_data(""); */ /* ret = options_validate(tdata->old_opt, tdata->opt, */ /* tdata->def_opt, 0, &msg); */ -/* tt_str_op(mock_saved_log_at(0), OP_EQ, */ -/* "SocksPort, TransPort, NATDPort, DNSPort, and ORPort are all " */ -/* "undefined, and there aren't any hidden services configured. " */ +/* expect_log_msg("SocksPort, TransPort, NATDPort, DNSPort, and ORPort " */ +/* "are all undefined, and there aren't any hidden services " */ +/* "configured. " */ /* " Tor will still run, but probably won't do anything.\n"); */ /* done: */ /* teardown_capture_of_logs(previous_log); */ @@ -1230,8 +1222,7 @@ test_options_validate__scheduler(void *ignored) /* ret = options_validate(tdata->old_opt, tdata->opt, */ /* tdata->def_opt, 0, &msg); */ /* tt_int_op(ret, OP_EQ, -1); */ - /* tt_str_op(mock_saved_log_at(1), OP_EQ, */ - /* "Bad SchedulerLowWaterMark__ option\n"); */ + /* expect_log_msg("Bad SchedulerLowWaterMark__ option\n"); */ free_options_test_data(tdata); tdata = get_options_test_data("SchedulerLowWaterMark__ 42\n" @@ -1513,7 +1504,7 @@ test_options_validate__paths_needed(void *ignored) tt_int_op(ret, OP_EQ, -1); tt_assert(tdata->opt->PathsNeededToBuildCircuits > 0.90 && tdata->opt->PathsNeededToBuildCircuits < 0.92); - tt_int_op(mock_saved_log_number(), OP_EQ, 0); + expect_no_log_entry(); tor_free(msg); done: @@ -1684,7 +1675,7 @@ test_options_validate__reachable_addresses(void *ignored) tdata->opt->FirewallPorts = smartlist_new(); ret = options_validate(tdata->old_opt, tdata->opt, tdata->def_opt, 0, &msg); tt_int_op(ret, OP_EQ, -1); - tt_int_op(mock_saved_log_number(), OP_EQ, 4); + expect_log_entry(); tt_str_op(tdata->opt->ReachableDirAddresses->value, OP_EQ, "*:81"); tt_str_op(tdata->opt->ReachableORAddresses->value, OP_EQ, "*:444"); tor_free(msg); @@ -1719,7 +1710,7 @@ test_options_validate__reachable_addresses(void *ignored) ret = options_validate(tdata->old_opt, tdata->opt, tdata->def_opt, 0, &msg); tt_int_op(ret, OP_EQ, -1); - tt_int_op(mock_saved_log_number(), OP_EQ, 4); + expect_log_entry(); tt_str_op(tdata->opt->ReachableAddresses->value, OP_EQ, "*:82"); tor_free(msg); diff --git a/src/test/test_tortls.c b/src/test/test_tortls.c index add020e9f4..cbbd7dd3f3 100644 --- a/src/test/test_tortls.c +++ b/src/test/test_tortls.c @@ -344,79 +344,67 @@ test_tortls_log_one_error(void *ignored) int previous_log = setup_capture_of_logs(LOG_INFO); tor_tls_log_one_error(NULL, 0, LOG_WARN, 0, "something"); - tt_int_op(mock_saved_log_number(), OP_EQ, 1); - tt_str_op(mock_saved_log_at(0), OP_EQ, "TLS error while something: " + expect_log_msg("TLS error while something: " "(null) (in (null):(null):---)\n"); mock_clean_saved_logs(); tor_tls_log_one_error(tls, 0, LOG_WARN, 0, NULL); - tt_int_op(mock_saved_log_number(), OP_EQ, 1); - tt_str_op(mock_saved_log_at(0), OP_EQ, "TLS error: (null) " + expect_log_msg("TLS error: (null) " "(in (null):(null):---)\n"); mock_clean_saved_logs(); tls->address = tor_strdup("127.hello"); tor_tls_log_one_error(tls, 0, LOG_WARN, 0, NULL); - tt_int_op(mock_saved_log_number(), OP_EQ, 1); - tt_str_op(mock_saved_log_at(0), OP_EQ, "TLS error with 127.hello: (null) " - "(in (null):(null):---)\n"); + expect_log_msg("TLS error with 127.hello: " + "(null) (in (null):(null):---)\n"); tor_free(tls->address); mock_clean_saved_logs(); tls->address = tor_strdup("127.hello"); tor_tls_log_one_error(tls, 0, LOG_WARN, 0, "blarg"); - tt_int_op(mock_saved_log_number(), OP_EQ, 1); - tt_str_op(mock_saved_log_at(0), OP_EQ, "TLS error while blarg with " + expect_log_msg("TLS error while blarg with " "127.hello: (null) (in (null):(null):---)\n"); mock_clean_saved_logs(); tor_tls_log_one_error(tls, ERR_PACK(1, 2, 3), LOG_WARN, 0, NULL); - tt_int_op(mock_saved_log_number(), OP_EQ, 1); - tt_str_op(mock_saved_log_at(0), OP_EQ, "TLS error with 127.hello: " + expect_log_msg("TLS error with 127.hello: " "BN lib (in unknown library:(null):---)\n"); mock_clean_saved_logs(); tor_tls_log_one_error(tls, ERR_PACK(1, 2, SSL_R_HTTP_REQUEST), LOG_WARN, 0, NULL); - tt_int_op(mock_saved_log_number(), OP_EQ, 1); - tt_int_op(mock_saved_severity_at(0), OP_EQ, LOG_INFO); + expect_log_severity(LOG_INFO); mock_clean_saved_logs(); tor_tls_log_one_error(tls, ERR_PACK(1, 2, SSL_R_HTTPS_PROXY_REQUEST), LOG_WARN, 0, NULL); - tt_int_op(mock_saved_log_number(), OP_EQ, 1); - tt_int_op(mock_saved_severity_at(0), OP_EQ, LOG_INFO); + expect_log_severity(LOG_INFO); mock_clean_saved_logs(); tor_tls_log_one_error(tls, ERR_PACK(1, 2, SSL_R_RECORD_LENGTH_MISMATCH), LOG_WARN, 0, NULL); - tt_int_op(mock_saved_log_number(), OP_EQ, 1); - tt_int_op(mock_saved_severity_at(0), OP_EQ, LOG_INFO); + expect_log_severity(LOG_INFO); mock_clean_saved_logs(); tor_tls_log_one_error(tls, ERR_PACK(1, 2, SSL_R_RECORD_TOO_LARGE), LOG_WARN, 0, NULL); - tt_int_op(mock_saved_log_number(), OP_EQ, 1); - tt_int_op(mock_saved_severity_at(0), OP_EQ, LOG_INFO); + expect_log_severity(LOG_INFO); mock_clean_saved_logs(); tor_tls_log_one_error(tls, ERR_PACK(1, 2, SSL_R_UNKNOWN_PROTOCOL), LOG_WARN, 0, NULL); - tt_int_op(mock_saved_log_number(), OP_EQ, 1); - tt_int_op(mock_saved_severity_at(0), OP_EQ, LOG_INFO); + expect_log_severity(LOG_INFO); mock_clean_saved_logs(); tor_tls_log_one_error(tls, ERR_PACK(1, 2, SSL_R_UNSUPPORTED_PROTOCOL), LOG_WARN, 0, NULL); - tt_int_op(mock_saved_log_number(), OP_EQ, 1); - tt_int_op(mock_saved_severity_at(0), OP_EQ, LOG_INFO); + expect_log_severity(LOG_INFO); tls->ssl = SSL_new(ctx); mock_clean_saved_logs(); tor_tls_log_one_error(tls, 0, LOG_WARN, 0, NULL); - tt_int_op(mock_saved_log_number(), OP_EQ, 1); - tt_str_op(mock_saved_log_at(0), OP_EQ, "TLS error with 127.hello: (null)" + expect_log_msg("TLS error with 127.hello: (null)" " (in (null):(null):" SSL_STATE_STR ")\n"); done: @@ -450,27 +438,25 @@ test_tortls_get_error(void *ignored) ret = tor_tls_get_error(tls, 0, 0, "something", LOG_WARN, 0); tt_int_op(ret, OP_EQ, TOR_TLS_ERROR_IO); - tt_int_op(mock_saved_log_number(), OP_EQ, 1); - tt_str_op(mock_saved_log_at(0), OP_EQ, "TLS error: unexpected close while" + expect_log_msg("TLS error: unexpected close while" " something (before/accept initialization)\n"); mock_clean_saved_logs(); ret = tor_tls_get_error(tls, 2, 0, "something", LOG_WARN, 0); tt_int_op(ret, OP_EQ, 0); - tt_int_op(mock_saved_log_number(), OP_EQ, 0); + expect_no_log_entry(); mock_clean_saved_logs(); ret = tor_tls_get_error(tls, 0, 1, "something", LOG_WARN, 0); tt_int_op(ret, OP_EQ, -11); - tt_int_op(mock_saved_log_number(), OP_EQ, 0); + expect_no_log_entry(); mock_clean_saved_logs(); ERR_clear_error(); ERR_put_error(ERR_LIB_BN, 2, -1, "somewhere.c", 99); ret = tor_tls_get_error(tls, 0, 0, "something", LOG_WARN, 0); tt_int_op(ret, OP_EQ, TOR_TLS_ERROR_MISC); - tt_int_op(mock_saved_log_number(), OP_EQ, 1); - tt_str_op(mock_saved_log_at(0), OP_EQ, "TLS error while something: (null)" + expect_log_msg("TLS error while something: (null)" " (in bignum routines:(null):before/accept initialization)\n"); mock_clean_saved_logs(); @@ -479,7 +465,7 @@ test_tortls_get_error(void *ignored) SSL_get_rbio(tls->ssl)->flags = BIO_FLAGS_READ; ret = tor_tls_get_error(tls, -1, 0, "something", LOG_WARN, 0); tt_int_op(ret, OP_EQ, TOR_TLS_WANTREAD); - tt_int_op(mock_saved_log_number(), OP_EQ, 0); + expect_no_log_entry(); mock_clean_saved_logs(); ERR_clear_error(); @@ -487,7 +473,7 @@ test_tortls_get_error(void *ignored) SSL_get_rbio(tls->ssl)->flags = BIO_FLAGS_WRITE; ret = tor_tls_get_error(tls, -1, 0, "something", LOG_WARN, 0); tt_int_op(ret, OP_EQ, TOR_TLS_WANTWRITE); - tt_int_op(mock_saved_log_number(), OP_EQ, 0); + expect_no_log_entry(); mock_clean_saved_logs(); ERR_clear_error(); @@ -496,20 +482,18 @@ test_tortls_get_error(void *ignored) tls->ssl->s3->warn_alert =SSL_AD_CLOSE_NOTIFY; ret = tor_tls_get_error(tls, 0, 0, "something", LOG_WARN, 0); tt_int_op(ret, OP_EQ, TOR_TLS_CLOSE); - tt_int_op(mock_saved_log_number(), OP_EQ, 1); + expect_log_entry(); mock_clean_saved_logs(); ret = tor_tls_get_error(tls, 0, 2, "something", LOG_WARN, 0); tt_int_op(ret, OP_EQ, -10); - tt_int_op(mock_saved_log_number(), OP_EQ, 0); + expect_no_log_entry(); mock_clean_saved_logs(); ERR_put_error(ERR_LIB_SYS, 2, -1, "somewhere.c", 99); ret = tor_tls_get_error(tls, -1, 0, "something", LOG_WARN, 0); tt_int_op(ret, OP_EQ, -9); - tt_int_op(mock_saved_log_number(), OP_EQ, 2); - tt_str_op(mock_saved_log_at(1), OP_EQ, - "TLS error while something: (null) (in system library:" + expect_log_msg("TLS error while something: (null) (in system library:" "connect:before/accept initialization)\n"); done: @@ -1823,12 +1807,11 @@ test_tortls_debug_state_callback(void *ignored) ssl = tor_malloc_zero(sizeof(SSL)); tor_tls_debug_state_callback(ssl, 32, 45); - tt_int_op(mock_saved_log_number(), OP_EQ, 1); + n = snprintf(buf, 1000, "SSL %p is now in state unknown" " state [type=32,val=45].\n", ssl); buf[n]='\0'; - if (strcasecmp(mock_saved_log_at(0), buf)) - tt_str_op(mock_saved_log_at(0), OP_EQ, buf); + expect_log_msg(buf); done: teardown_capture_of_logs(previous_log); @@ -1864,21 +1847,17 @@ test_tortls_server_info_callback(void *ignored) SSL_set_state(ssl, SSL3_ST_SW_SRVR_HELLO_A); mock_clean_saved_logs(); tor_tls_server_info_callback(ssl, SSL_CB_ACCEPT_LOOP, 0); - tt_int_op(mock_saved_log_number(), OP_EQ, 1); - tt_str_op(mock_saved_log_at(0), OP_EQ, - "Couldn't look up the tls for an SSL*. How odd!\n"); + expect_log_msg("Couldn't look up the tls for an SSL*. How odd!\n"); SSL_set_state(ssl, SSL3_ST_SW_SRVR_HELLO_B); mock_clean_saved_logs(); tor_tls_server_info_callback(ssl, SSL_CB_ACCEPT_LOOP, 0); - tt_int_op(mock_saved_log_number(), OP_EQ, 1); - tt_str_op(mock_saved_log_at(0), OP_EQ, - "Couldn't look up the tls for an SSL*. How odd!\n"); + expect_log_msg("Couldn't look up the tls for an SSL*. How odd!\n"); SSL_set_state(ssl, 99); mock_clean_saved_logs(); tor_tls_server_info_callback(ssl, SSL_CB_ACCEPT_LOOP, 0); - tt_int_op(mock_saved_log_number(), OP_EQ, 0); + expect_no_log_entry(); SSL_set_ex_data(tls->ssl, tor_tls_object_ex_data_index, tls); SSL_set_state(ssl, SSL3_ST_SW_SRVR_HELLO_B); @@ -2255,18 +2234,15 @@ test_tortls_handshake(void *ignored) tls->state = TOR_TLS_ST_HANDSHAKE; ret = tor_tls_handshake(tls); tt_int_op(ret, OP_EQ, TOR_TLS_ERROR_MISC); - tt_int_op(mock_saved_log_number(), OP_EQ, 2); + expect_log_entry(); /* This fails on jessie. Investigate why! */ #if 0 - tt_str_op(mock_saved_log_at(0), OP_EQ, - "TLS error while handshaking: (null) (in bignum routines:" + expect_log_msg("TLS error while handshaking: (null) (in bignum routines:" "(null):SSLv3 write client hello B)\n"); - tt_str_op(mock_saved_log_at(1), OP_EQ, - "TLS error while handshaking: (null) (in system library:" + expect_log_msg("TLS error while handshaking: (null) (in system library:" "connect:SSLv3 write client hello B)\n"); #endif - tt_int_op(mock_saved_severity_at(0), OP_EQ, LOG_INFO); - tt_int_op(mock_saved_severity_at(1), OP_EQ, LOG_INFO); + expect_log_severity(LOG_INFO); tls->isServer = 0; method->ssl_connect = setting_error_ssl_connect; @@ -2276,16 +2252,15 @@ test_tortls_handshake(void *ignored) tls->state = TOR_TLS_ST_HANDSHAKE; ret = tor_tls_handshake(tls); tt_int_op(ret, OP_EQ, TOR_TLS_ERROR_MISC); - tt_int_op(mock_saved_log_number(), OP_EQ, 2); + expect_log_entry(); #if 0 /* See above */ - tt_str_op(mock_saved_log_at(0), OP_EQ, "TLS error while handshaking: " + expect_log_msg("TLS error while handshaking: " "(null) (in bignum routines:(null):SSLv3 write client hello B)\n"); - tt_str_op(mock_saved_log_at(1), OP_EQ, "TLS error while handshaking: " + expect_log_msg("TLS error while handshaking: " "(null) (in system library:connect:SSLv3 write client hello B)\n"); #endif - tt_int_op(mock_saved_severity_at(0), OP_EQ, LOG_WARN); - tt_int_op(mock_saved_severity_at(1), OP_EQ, LOG_WARN); + expect_log_severity(LOG_WARN); done: teardown_capture_of_logs(previous_log); diff --git a/src/test/test_util_process.c b/src/test/test_util_process.c index cb1d5b2ebb..0a4354c043 100644 --- a/src/test/test_util_process.c +++ b/src/test/test_util_process.c @@ -34,8 +34,7 @@ test_util_process_set_waitpid_callback(void *ignored) res2 = set_waitpid_callback(pid, temp_callback, NULL); tt_assert(res2); - tt_str_op(mock_saved_log_at(0), OP_EQ, - "Replaced a waitpid monitor on pid 42. That should be " + expect_log_msg("Replaced a waitpid monitor on pid 42. That should be " "impossible.\n"); done: @@ -56,13 +55,12 @@ test_util_process_clear_waitpid_callback(void *ignored) res = set_waitpid_callback(pid, temp_callback, NULL); clear_waitpid_callback(res); - tt_int_op(mock_saved_log_number(), OP_EQ, 0); + expect_no_log_entry(); #if 0 /* No. This is use-after-free. We don't _do_ that. XXXX */ clear_waitpid_callback(res); - tt_str_op(mock_saved_log_at(0), OP_EQ, - "Couldn't remove waitpid monitor for pid 43.\n"); + expect_log_msg("Couldn't remove waitpid monitor for pid 43.\n"); #endif done: