diff options
author | Steven Murdoch <Steven.Murdoch@cl.cam.ac.uk> | 2011-09-01 18:17:54 +0100 |
---|---|---|
committer | Steven Murdoch <Steven.Murdoch@cl.cam.ac.uk> | 2011-09-01 18:17:54 +0100 |
commit | f5df96c94f0c40e4bf55e4b4b843df85e9d90a71 (patch) | |
tree | d1ee09e70890a1cfa0558f02fd3dc5021e58dfe5 /src/test | |
parent | 9f144144e383169ba6a0de78fde50c0d1f662116 (diff) | |
download | tor-f5df96c94f0c40e4bf55e4b4b843df85e9d90a71.tar.gz tor-f5df96c94f0c40e4bf55e4b4b843df85e9d90a71.zip |
Handle test case where fgets() sees EOF on the last read
On some platforms, with non-blocking IO, on EOF you first
get EAGAIN, and then on the second read you get zero bytes
and EOF is set. However on others, the EOF flag is set as
soon as the last byte is read. This patch fixes the test
case in the latter scenario.
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/test_util.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/test/test_util.c b/src/test/test_util.c index 7faa0ae20e..f9672c100b 100644 --- a/src/test/test_util.c +++ b/src/test/test_util.c @@ -1541,14 +1541,18 @@ test_util_spawn_background_partial_read(void *ptr) pos = tor_read_all_handle(process_handle.stdout_pipe, stdout_buf, sizeof(stdout_buf) - 1, &process_handle); + tt_int_op(pos, ==, 0); #else - if (!eof) + if (!eof) { + /* We should have got all the data, but maybe not the EOF flag */ pos = tor_read_all_handle(process_handle.stdout_handle, stdout_buf, sizeof(stdout_buf) - 1, &process_handle, &eof); - tt_assert(eof) + tt_int_op(pos, ==, 0); + tt_assert(eof); + } + /* Otherwise, we got the EOF on the last read */ #endif - tt_int_op(pos, ==, 0); /* Check it terminated correctly */ retval = tor_get_exit_code(process_handle, 1, &exit_code); |