diff options
author | Alexander Færøy <ahf@torproject.org> | 2019-10-17 16:56:21 +0200 |
---|---|---|
committer | Alexander Færøy <ahf@torproject.org> | 2019-10-17 20:52:32 +0200 |
commit | 4ed06acb2ada14e424f453c24c477659b4cb7cbf (patch) | |
tree | cc44e3699e9ad1dacedbb27a70e083a7fe04d895 /src/test/test_process_slow.c | |
parent | 7a64f6ea049747385acf77985ad4df5fa497b3e1 (diff) | |
download | tor-4ed06acb2ada14e424f453c24c477659b4cb7cbf.tar.gz tor-4ed06acb2ada14e424f453c24c477659b4cb7cbf.zip |
Add test to check if the exit callback is called in process_t upon process_exec() failures.
This patch adds a test to check for whether the exit callback is always
called when process_exec() fails, both on Windows and Unix.
See: https://bugs.torproject.org/31810
Diffstat (limited to 'src/test/test_process_slow.c')
-rw-r--r-- | src/test/test_process_slow.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/test/test_process_slow.c b/src/test/test_process_slow.c index 91252c725d..f311e8b293 100644 --- a/src/test/test_process_slow.c +++ b/src/test/test_process_slow.c @@ -328,8 +328,38 @@ test_callbacks_terminate(void *arg) process_free(process); } +static void +test_nonexistent_executable(void *arg) +{ + (void)arg; + + /* Process callback data. */ + process_data_t *process_data = process_data_new(); + + /* Setup our process. */ + process_t *process = process_new("binary-does-not-exist"); + process_set_data(process, process_data); + process_set_exit_callback(process, process_exit_callback); + + /* Run our process. */ + process_exec(process); + + /* Start our main loop. */ + run_main_loop(process_data); + + /* Ensure that the exit callback was actually called even though the binary + * did not exist. + */ + tt_assert(process_data->did_exit); + + done: + process_data_free(process_data); + process_free(process); +} + struct testcase_t slow_process_tests[] = { { "callbacks", test_callbacks, 0, NULL, NULL }, { "callbacks_terminate", test_callbacks_terminate, 0, NULL, NULL }, + { "nonexistent_executable", test_nonexistent_executable, 0, NULL, NULL }, END_OF_TESTCASES }; |