summaryrefslogtreecommitdiff
path: root/src/test/test_util.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2016-07-06 13:01:08 -0400
committerNick Mathewson <nickm@torproject.org>2016-07-06 13:01:08 -0400
commit08cc0ef8320e614c1a33ea5e70bef4f5809981f2 (patch)
tree8f456ed5820804a62f7788050be37d6ee8526124 /src/test/test_util.c
parent96d32f02f2f9d37454665325237cdc2adf7ee2d8 (diff)
downloadtor-08cc0ef8320e614c1a33ea5e70bef4f5809981f2.tar.gz
tor-08cc0ef8320e614c1a33ea5e70bef4f5809981f2.zip
Capture the LOG_ERR messages in our tests that had logged errors.
(It's confusing for the test to write an expected error to stdout, and then tell the user "OK".)
Diffstat (limited to 'src/test/test_util.c')
-rw-r--r--src/test/test_util.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/test/test_util.c b/src/test/test_util.c
index c331a662a5..19763fb737 100644
--- a/src/test/test_util.c
+++ b/src/test/test_util.c
@@ -13,6 +13,7 @@
#include "test.h"
#include "memarea.h"
#include "util_process.h"
+#include "log_test_helpers.h"
#ifdef HAVE_PWD_H
#include <pwd.h>
@@ -5187,6 +5188,7 @@ test_util_pwdb(void *arg)
const struct passwd *me = NULL, *me2, *me3;
char *name = NULL;
char *dir = NULL;
+ int prev_level = -100;
/* Uncached case. */
/* Let's assume that we exist. */
@@ -5225,8 +5227,13 @@ test_util_pwdb(void *arg)
}
tt_assert(found);
tor_free(dir);
+
+ prev_level = setup_capture_of_logs(LOG_ERR); /* We should do a LOG_ERR */
dir = get_user_homedir(badname);
tt_assert(dir == NULL);
+ tt_int_op(smartlist_len(mock_saved_logs()), OP_EQ, 1);
+ teardown_capture_of_logs(prev_level);
+ prev_level = -100;
/* Now try to find a user that doesn't exist by ID. */
found = 0;
@@ -5243,6 +5250,8 @@ test_util_pwdb(void *arg)
done:
tor_free(name);
tor_free(dir);
+ if (prev_level >= 0)
+ teardown_capture_of_logs(prev_level);
}
#endif