diff options
author | Ola Bini <ola@olabini.se> | 2015-10-05 14:07:55 -0500 |
---|---|---|
committer | Ola Bini <ola@olabini.se> | 2015-10-05 14:07:55 -0500 |
commit | c31791b79886dd697f02af78b86281ad6d5e407d (patch) | |
tree | 7c38c195684ee44d064f83cb8ff210ac6f4a84fe /src/test | |
parent | cf4f50f94332615abcf6dd345ee1e8fce69232ca (diff) | |
download | tor-c31791b79886dd697f02af78b86281ad6d5e407d.tar.gz tor-c31791b79886dd697f02af78b86281ad6d5e407d.zip |
Test behavior on success, and fix spaces
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/log_test_helpers.c | 13 | ||||
-rw-r--r-- | src/test/log_test_helpers.h | 6 | ||||
-rw-r--r-- | src/test/test_util_process.c | 23 |
3 files changed, 26 insertions, 16 deletions
diff --git a/src/test/log_test_helpers.c b/src/test/log_test_helpers.c index 42778d4642..7dae488cb1 100644 --- a/src/test/log_test_helpers.c +++ b/src/test/log_test_helpers.c @@ -33,24 +33,25 @@ mock_clean_saved_logs(void) saved_logs = NULL; } -char * +const char * mock_saved_log_at(int ix) { int saved_log_count = mock_saved_log_number(); - if(ix < 0) { + if (ix < 0) { ix = saved_log_count + ix; } if (saved_log_count <= ix) return ""; - return ((mock_saved_log_entry_t *)smartlist_get(saved_logs, ix))->generated_msg; + return ((mock_saved_log_entry_t *) + smartlist_get(saved_logs, ix))->generated_msg; } int mock_saved_severity_at(int ix) { int saved_log_count = mock_saved_log_number(); - if(ix < 0) { + if (ix < 0) { ix = saved_log_count + ix; } @@ -74,8 +75,10 @@ mock_saved_logs(void) } void -mock_saving_logv(int severity, log_domain_mask_t domain, const char *funcname, const char *suffix, const char *format, va_list ap) +mock_saving_logv(int severity, log_domain_mask_t domain, const char *funcname, + const char *suffix, const char *format, va_list ap) { + (void)domain; char *buf = tor_malloc_zero(10240); int n; n = tor_vsnprintf(buf,10240,format,ap); diff --git a/src/test/log_test_helpers.h b/src/test/log_test_helpers.h index 789bfe4143..58d14d92aa 100644 --- a/src/test/log_test_helpers.h +++ b/src/test/log_test_helpers.h @@ -15,12 +15,14 @@ typedef struct mock_saved_log_entry_t { struct mock_saved_log_entry_t *next; } mock_saved_log_entry_t; -void mock_saving_logv(int severity, log_domain_mask_t domain, const char *funcname, const char *suffix, const char *format, va_list ap); +void mock_saving_logv(int severity, log_domain_mask_t domain, + const char *funcname, const char *suffix, + const char *format, va_list ap); void mock_clean_saved_logs(void); const smartlist_t *mock_saved_logs(void); int setup_capture_of_logs(int new_level); void teardown_capture_of_logs(int prev); -char *mock_saved_log_at(int ix); +const char *mock_saved_log_at(int ix); int mock_saved_severity_at(int ix); int mock_saved_log_number(void); diff --git a/src/test/test_util_process.c b/src/test/test_util_process.c index 5d6c072f3f..5d45b58d3e 100644 --- a/src/test/test_util_process.c +++ b/src/test/test_util_process.c @@ -13,8 +13,8 @@ #define NS_MODULE util_process -static -void temp_callback(int r, void *s) +static void +temp_callback(int r, void *s) { (void)r; (void)s; @@ -33,13 +33,14 @@ test_util_process_set_waitpid_callback(void *ignored) res = set_waitpid_callback(pid, temp_callback, NULL); tt_assert(res); - tt_str_op(mock_saved_log_at(0), OP_EQ, "Replaced a waitpid monitor on pid 42. That should be impossible.\n"); + tt_str_op(mock_saved_log_at(0), OP_EQ, + "Replaced a waitpid monitor on pid 42. That should be " + "impossible.\n"); done: teardown_capture_of_logs(previous_log); } - static void test_util_process_clear_waitpid_callback(void *ignored) { @@ -52,16 +53,20 @@ test_util_process_clear_waitpid_callback(void *ignored) res = set_waitpid_callback(pid, temp_callback, NULL); clear_waitpid_callback(res); + tt_int_op(mock_saved_log_number(), OP_EQ, 0); + clear_waitpid_callback(res); + tt_str_op(mock_saved_log_at(0), OP_EQ, + "Couldn't remove waitpid monitor for pid 43.\n"); - // done: + done: teardown_capture_of_logs(previous_log); } - - struct testcase_t util_process_tests[] = { - { "set_waitpid_callback", test_util_process_set_waitpid_callback, 0, NULL, NULL }, - { "clear_waitpid_callback", test_util_process_clear_waitpid_callback, 0, NULL, NULL }, + { "set_waitpid_callback", test_util_process_set_waitpid_callback, 0, + NULL, NULL }, + { "clear_waitpid_callback", test_util_process_clear_waitpid_callback, 0, + NULL, NULL }, END_OF_TESTCASES }; |