diff options
author | Peter Palfrader <peter@palfrader.org> | 2011-12-17 11:22:31 +0100 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2011-12-17 12:21:51 -0500 |
commit | f6b19ac79c348f732eb08405367d7a434f8d8f08 (patch) | |
tree | 3963455e2334ef4264e10e993686d658e4f83a5e /src/test | |
parent | d37cb8f74aa741cebe0001a4b56bd2bae539e225 (diff) | |
download | tor-f6b19ac79c348f732eb08405367d7a434f8d8f08.tar.gz tor-f6b19ac79c348f732eb08405367d7a434f8d8f08.zip |
test_util_spawn_background_ok: fix expectation
test_util_spawn_background_ok() hardcoded the expected value
for ENOENT to 2. This isn't portable as error numbers are
platform specific, and particularly the hurd has ENOENT at
0x40000002.
Construct expected string at runtime, using the correct value
for ENOENT (closes: #4733).
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/test_util.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/test/test_util.c b/src/test/test_util.c index f9b57d61da..389e0a08d6 100644 --- a/src/test/test_util.c +++ b/src/test/test_util.c @@ -1460,17 +1460,13 @@ test_util_spawn_background_ok(void *ptr) static void test_util_spawn_background_fail(void *ptr) { -#ifdef MS_WINDOWS const char *argv[] = {BUILDDIR "/src/test/no-such-file", "--test", NULL}; - const char *expected_out = "ERR: Failed to spawn background process " - "- code 9/2\n"; const char *expected_err = ""; + char expected_out[1024]; + char code[32]; +#ifdef MS_WINDOWS const int expected_status = PROCESS_STATUS_ERROR; #else - const char *argv[] = {BUILDDIR "/src/test/no-such-file", "--test", NULL}; - const char *expected_out = "ERR: Failed to spawn background process " - "- code 9/2\n"; - const char *expected_err = ""; /* TODO: Once we can signal failure to exec, set this to be * PROCESS_STATUS_ERROR */ const int expected_status = PROCESS_STATUS_RUNNING; @@ -1478,6 +1474,11 @@ test_util_spawn_background_fail(void *ptr) (void)ptr; + tor_snprintf(code, sizeof(code), "%x/%x", + 9 /* CHILD_STATE_FAILEXEC */ , ENOENT); + tor_snprintf(expected_out, sizeof(expected_out), + "ERR: Failed to spawn background process - code %12s\n", code); + run_util_spawn_background(argv, expected_out, expected_err, 255, expected_status); } |