2016-02-27 18:48:19 +01:00
|
|
|
/* Copyright (c) 2014-2016, The Tor Project, Inc. */
|
2015-09-15 17:20:44 +02:00
|
|
|
/* See LICENSE for licensing information */
|
|
|
|
|
|
|
|
#include "or.h"
|
|
|
|
|
|
|
|
#ifndef TOR_LOG_TEST_HELPERS_H
|
|
|
|
#define TOR_LOG_TEST_HELPERS_H
|
|
|
|
|
2016-08-31 19:03:59 +02:00
|
|
|
/** An element of mock_saved_logs(); records the log element that we
|
|
|
|
* received. */
|
2015-09-15 17:20:44 +02:00
|
|
|
typedef struct mock_saved_log_entry_t {
|
|
|
|
int severity;
|
|
|
|
const char *funcname;
|
|
|
|
const char *suffix;
|
|
|
|
const char *format;
|
|
|
|
char *generated_msg;
|
|
|
|
} mock_saved_log_entry_t;
|
|
|
|
|
|
|
|
void mock_clean_saved_logs(void);
|
|
|
|
const smartlist_t *mock_saved_logs(void);
|
|
|
|
int setup_capture_of_logs(int new_level);
|
2016-08-31 18:51:22 +02:00
|
|
|
int setup_full_capture_of_logs(int new_level);
|
2015-09-15 17:20:44 +02:00
|
|
|
void teardown_capture_of_logs(int prev);
|
2016-02-11 18:45:51 +01:00
|
|
|
|
2016-01-29 17:38:54 +01:00
|
|
|
int mock_saved_log_has_message(const char *msg);
|
2016-08-31 17:35:12 +02:00
|
|
|
int mock_saved_log_has_message_containing(const char *msg);
|
2016-02-01 00:02:04 +01:00
|
|
|
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);
|
|
|
|
|
2016-08-31 18:51:22 +02:00
|
|
|
#define expect_log_msg_containing(str) \
|
|
|
|
tt_assert_msg(mock_saved_log_has_message_containing(str), \
|
|
|
|
"expected log to contain " # str);
|
|
|
|
|
2016-02-01 00:02:04 +01:00
|
|
|
#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");
|
2015-09-15 17:20:44 +02:00
|
|
|
|
|
|
|
#endif
|
2016-01-15 16:57:03 +01:00
|
|
|
|