From: Nick Mathewson Date: Wed, 31 Aug 2016 15:35:12 +0000 (-0400) Subject: Another log testing helper helper, for matching partial strings. X-Git-Tag: tor-0.2.9.3-alpha~106 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=14c07f3f2199053e92c6bea90da332efbb3811e4;p=thirdparty%2Ftor.git Another log testing helper helper, for matching partial strings. --- diff --git a/src/test/log_test_helpers.c b/src/test/log_test_helpers.c index 166a777747..1828689d1d 100644 --- a/src/test/log_test_helpers.c +++ b/src/test/log_test_helpers.c @@ -59,6 +59,23 @@ mock_saved_log_has_message(const char *msg) return has_msg; } +int +mock_saved_log_has_message_containing(const char *msg) +{ + if (saved_logs) { + SMARTLIST_FOREACH(saved_logs, mock_saved_log_entry_t *, m, + { + if (msg && m->generated_msg && + strstr(m->generated_msg, msg)) { + return 1; + } + }); + } + + return 0; +} + + /* Do the saved logs have any messages with severity? */ int mock_saved_log_has_severity(int severity) diff --git a/src/test/log_test_helpers.h b/src/test/log_test_helpers.h index 1966f170fb..d767453a6e 100644 --- a/src/test/log_test_helpers.h +++ b/src/test/log_test_helpers.h @@ -25,6 +25,7 @@ int setup_capture_of_logs(int new_level); void teardown_capture_of_logs(int prev); int mock_saved_log_has_message(const char *msg); +int mock_saved_log_has_message_containing(const char *msg); int mock_saved_log_has_severity(int severity); int mock_saved_log_has_entry(void);