mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-02 16:43:32 +01:00
Clean up compat_libevent tests
This commit is contained in:
parent
c01f9d9ffe
commit
ac8c5ec67a
3
changes/17075
Normal file
3
changes/17075
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
o Testing:
|
||||||
|
- More unit tests for compat_libevent.c. Closes ticket 17075.
|
||||||
|
Patch from Ola Bini.
|
3
changes/17084
Normal file
3
changes/17084
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
o Testing:
|
||||||
|
- More unit tests for util_format.c. Closes ticket 17084.
|
||||||
|
Patch from Ola Bini.
|
@ -626,3 +626,4 @@ tor_gettimeofday_cached_monotonic(struct timeval *tv)
|
|||||||
memcpy(&last_tv, tv, sizeof(struct timeval));
|
memcpy(&last_tv, tv, sizeof(struct timeval));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +91,6 @@ void tor_gettimeofday_cache_set(const struct timeval *tv);
|
|||||||
#endif
|
#endif
|
||||||
void tor_gettimeofday_cached_monotonic(struct timeval *tv);
|
void tor_gettimeofday_cached_monotonic(struct timeval *tv);
|
||||||
|
|
||||||
|
|
||||||
#ifdef COMPAT_LIBEVENT_PRIVATE
|
#ifdef COMPAT_LIBEVENT_PRIVATE
|
||||||
/** A number representing a version of Libevent.
|
/** A number representing a version of Libevent.
|
||||||
|
|
||||||
@ -121,7 +120,6 @@ typedef uint32_t le_version_t;
|
|||||||
* it is. */
|
* it is. */
|
||||||
#define LE_OTHER V(0,0,99)
|
#define LE_OTHER V(0,0,99)
|
||||||
|
|
||||||
|
|
||||||
STATIC void
|
STATIC void
|
||||||
libevent_logging_callback(int severity, const char *msg);
|
libevent_logging_callback(int severity, const char *msg);
|
||||||
STATIC le_version_t
|
STATIC le_version_t
|
||||||
@ -131,3 +129,4 @@ le_versions_compatibility(le_version_t v);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
/* Copyright (c) 2015, The Tor Project, Inc. */
|
||||||
|
/* See LICENSE for licensing information */
|
||||||
#define LOG_PRIVATE
|
#define LOG_PRIVATE
|
||||||
#include "torlog.h"
|
#include "torlog.h"
|
||||||
#include "log_test_helpers.h"
|
#include "log_test_helpers.h"
|
||||||
@ -106,3 +108,4 @@ mock_saving_logv(int severity, log_domain_mask_t domain,
|
|||||||
saved_logs = smartlist_new();
|
saved_logs = smartlist_new();
|
||||||
smartlist_add(saved_logs, e);
|
smartlist_add(saved_logs, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,3 +28,4 @@ int mock_saved_severity_at(int ix);
|
|||||||
int mock_saved_log_number(void);
|
int mock_saved_log_number(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1212,3 +1212,4 @@ struct testgroup_t testgroups[] = {
|
|||||||
{ "dns/", dns_tests },
|
{ "dns/", dns_tests },
|
||||||
END_OF_GROUPS
|
END_OF_GROUPS
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -31,47 +31,67 @@ test_compat_libevent_logging_callback(void *ignored)
|
|||||||
|
|
||||||
libevent_logging_callback(_EVENT_LOG_DEBUG, "hello world");
|
libevent_logging_callback(_EVENT_LOG_DEBUG, "hello world");
|
||||||
tt_int_op(mock_saved_log_number(), OP_EQ, 1);
|
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_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);
|
tt_int_op(mock_saved_severity_at(0), OP_EQ, LOG_DEBUG);
|
||||||
|
|
||||||
mock_clean_saved_logs();
|
mock_clean_saved_logs();
|
||||||
libevent_logging_callback(_EVENT_LOG_MSG, "hello world another time");
|
libevent_logging_callback(_EVENT_LOG_MSG, "hello world another time");
|
||||||
tt_int_op(mock_saved_log_number(), OP_EQ, 1);
|
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_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);
|
tt_int_op(mock_saved_severity_at(0), OP_EQ, LOG_INFO);
|
||||||
|
|
||||||
mock_clean_saved_logs();
|
mock_clean_saved_logs();
|
||||||
libevent_logging_callback(_EVENT_LOG_WARN, "hello world a third time");
|
libevent_logging_callback(_EVENT_LOG_WARN, "hello world a third time");
|
||||||
tt_int_op(mock_saved_log_number(), OP_EQ, 1);
|
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_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);
|
tt_int_op(mock_saved_severity_at(0), OP_EQ, LOG_WARN);
|
||||||
|
|
||||||
mock_clean_saved_logs();
|
mock_clean_saved_logs();
|
||||||
libevent_logging_callback(_EVENT_LOG_ERR, "hello world a fourth time");
|
libevent_logging_callback(_EVENT_LOG_ERR, "hello world a fourth time");
|
||||||
tt_int_op(mock_saved_log_number(), OP_EQ, 1);
|
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_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);
|
tt_int_op(mock_saved_severity_at(0), OP_EQ, LOG_ERR);
|
||||||
|
|
||||||
mock_clean_saved_logs();
|
mock_clean_saved_logs();
|
||||||
libevent_logging_callback(42, "hello world a fifth time");
|
libevent_logging_callback(42, "hello world a fifth time");
|
||||||
tt_int_op(mock_saved_log_number(), OP_EQ, 1);
|
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_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);
|
tt_int_op(mock_saved_severity_at(0), OP_EQ, LOG_WARN);
|
||||||
|
|
||||||
mock_clean_saved_logs();
|
mock_clean_saved_logs();
|
||||||
libevent_logging_callback(_EVENT_LOG_DEBUG, "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"
|
libevent_logging_callback(_EVENT_LOG_DEBUG,
|
||||||
"0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"
|
"012345678901234567890123456789"
|
||||||
"0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"
|
"012345678901234567890123456789"
|
||||||
"0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"
|
"012345678901234567890123456789"
|
||||||
"0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"
|
"012345678901234567890123456789"
|
||||||
"0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"
|
"012345678901234567890123456789"
|
||||||
"0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"
|
"012345678901234567890123456789"
|
||||||
"0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"
|
"012345678901234567890123456789"
|
||||||
"0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"
|
"012345678901234567890123456789"
|
||||||
"0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"
|
"012345678901234567890123456789"
|
||||||
"0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789");
|
"012345678901234567890123456789"
|
||||||
|
"012345678901234567890123456789"
|
||||||
|
"012345678901234567890123456789"
|
||||||
|
);
|
||||||
tt_int_op(mock_saved_log_number(), OP_EQ, 1);
|
tt_int_op(mock_saved_log_number(), OP_EQ, 1);
|
||||||
tt_str_op(mock_saved_log_at(0), OP_EQ, "Message from libevent: 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012\n");
|
tt_str_op(mock_saved_log_at(0), OP_EQ, "Message from libevent: "
|
||||||
|
"012345678901234567890123456789"
|
||||||
|
"012345678901234567890123456789"
|
||||||
|
"012345678901234567890123456789"
|
||||||
|
"012345678901234567890123456789"
|
||||||
|
"012345678901234567890123456789"
|
||||||
|
"012345678901234567890123456789"
|
||||||
|
"012345678901234567890123456789"
|
||||||
|
"012345678901234567890123456789"
|
||||||
|
"012345678901234567890123456789"
|
||||||
|
"012345678901234567890123456789"
|
||||||
|
"012345678901234567890123456789"
|
||||||
|
"012345678901234567890123456789\n");
|
||||||
tt_int_op(mock_saved_severity_at(0), OP_EQ, LOG_DEBUG);
|
tt_int_op(mock_saved_severity_at(0), OP_EQ, LOG_DEBUG);
|
||||||
|
|
||||||
mock_clean_saved_logs();
|
mock_clean_saved_logs();
|
||||||
@ -84,7 +104,8 @@ test_compat_libevent_logging_callback(void *ignored)
|
|||||||
mock_clean_saved_logs();
|
mock_clean_saved_logs();
|
||||||
libevent_logging_callback(_EVENT_LOG_MSG, "hello there");
|
libevent_logging_callback(_EVENT_LOG_MSG, "hello there");
|
||||||
tt_int_op(mock_saved_log_number(), OP_EQ, 1);
|
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_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);
|
tt_int_op(mock_saved_severity_at(0), OP_EQ, LOG_INFO);
|
||||||
|
|
||||||
mock_clean_saved_logs();
|
mock_clean_saved_logs();
|
||||||
@ -204,11 +225,14 @@ test_compat_libevent_header_version(void *ignored)
|
|||||||
(void)0;
|
(void)0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
struct testcase_t compat_libevent_tests[] = {
|
struct testcase_t compat_libevent_tests[] = {
|
||||||
{ "logging_callback", test_compat_libevent_logging_callback, TT_FORK, NULL, NULL },
|
{ "logging_callback", test_compat_libevent_logging_callback,
|
||||||
{ "le_versions_compatibility", test_compat_libevent_le_versions_compatibility, 0, NULL, NULL },
|
TT_FORK, NULL, NULL },
|
||||||
{ "tor_decode_libevent_version", test_compat_libevent_tor_decode_libevent_version, 0, NULL, NULL },
|
{ "le_versions_compatibility",
|
||||||
|
test_compat_libevent_le_versions_compatibility, 0, NULL, NULL },
|
||||||
|
{ "tor_decode_libevent_version",
|
||||||
|
test_compat_libevent_tor_decode_libevent_version, 0, NULL, NULL },
|
||||||
{ "header_version", test_compat_libevent_header_version, 0, NULL, NULL },
|
{ "header_version", test_compat_libevent_header_version, 0, NULL, NULL },
|
||||||
END_OF_TESTCASES
|
END_OF_TESTCASES
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user