[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/release-0.3.3] Add test log helpers for msgs not containing str



commit 842b18ab26ac12da7e63c38413d193905b8fbed5
Author: juga0 <juga@xxxxxxxxxx>
Date:   Sat Jun 9 10:34:17 2018 +0000

    Add test log helpers for msgs not containing str
---
 src/test/log_test_helpers.c | 22 +++++++++++++++++++++-
 src/test/log_test_helpers.h |  7 ++++++-
 2 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/src/test/log_test_helpers.c b/src/test/log_test_helpers.c
index c788a33c1..c5368b6cb 100644
--- a/src/test/log_test_helpers.c
+++ b/src/test/log_test_helpers.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015-2016, The Tor Project, Inc. */
+/* Copyright (c) 2015-2018, The Tor Project, Inc. */
 /* See LICENSE for licensing information */
 #define LOG_PRIVATE
 #include "torlog.h"
@@ -158,6 +158,26 @@ mock_saved_log_has_message_containing(const char *msg)
   return 0;
 }
 
+/**
+ * Return true iff there is not a message recorded by log capture
+ * that contains <b>msg</b> as a substring.
+ */
+int
+mock_saved_log_has_message_not_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 0;
+      }
+    );
+  }
+
+  return 1;
+}
+
 /** Return true iff the saved logs have any messages with <b>severity</b> */
 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 922c68b42..a087b913f 100644
--- a/src/test/log_test_helpers.h
+++ b/src/test/log_test_helpers.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014-2016, The Tor Project, Inc. */
+/* Copyright (c) 2014-2018, The Tor Project, Inc. */
 /* See LICENSE for licensing information */
 
 #include "or.h"
@@ -24,6 +24,7 @@ void teardown_capture_of_logs(void);
 
 int mock_saved_log_has_message(const char *msg);
 int mock_saved_log_has_message_containing(const char *msg);
+int mock_saved_log_has_message_not_containing(const char *msg);
 int mock_saved_log_has_severity(int severity);
 int mock_saved_log_has_entry(void);
 int mock_saved_log_n_entries(void);
@@ -46,6 +47,10 @@ void mock_dump_saved_logs(void);
   assert_log_predicate(mock_saved_log_has_message_containing(str), \
                 "expected log to contain " # str);
 
+#define expect_log_msg_not_containing(str) \
+  assert_log_predicate(mock_saved_log_has_message_not_containing(str), \
+                "expected log to not contain " # str);
+
 #define expect_log_msg_containing_either(str1, str2)                    \
   assert_log_predicate(mock_saved_log_has_message_containing(str1) ||   \
                        mock_saved_log_has_message_containing(str2),     \



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits