From 629d2e34508838069db83e1082ce9e7f2c7b8ff8 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Fri, 21 Oct 2011 16:26:18 +0200 Subject: multi tests: OOM handling fixes Additionally, improved error checking and logging. --- tests/libtest/first.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'tests/libtest/first.c') diff --git a/tests/libtest/first.c b/tests/libtest/first.c index d6b486003..57e6ddd79 100644 --- a/tests/libtest/first.c +++ b/tests/libtest/first.c @@ -30,19 +30,25 @@ # include "memdebug.h" #endif -int select_test (int num_fds, fd_set *rd, fd_set *wr, fd_set *exc, - struct timeval *tv) +int select_wrapper(int nfds, fd_set *rd, fd_set *wr, fd_set *exc, + struct timeval *tv) { + if(nfds < 0) { + SET_SOCKERRNO(EINVAL); + return -1; + } #ifdef USE_WINSOCK - /* Winsock doesn't like no socket set in 'rd', 'wr' or 'exc'. This is - * case when 'num_fds <= 0. So sleep. + /* + * Winsock select() requires that at least one of the three fd_set + * pointers is not NULL and points to a non-empty fdset. IOW Winsock + * select() can not be used to sleep without a single fd_set. */ - if (num_fds <= 0) { + if(!nfds) { Sleep(1000*tv->tv_sec + tv->tv_usec/1000); return 0; } #endif - return select(num_fds, rd, wr, exc, tv); + return select(nfds, rd, wr, exc, tv); } char *libtest_arg2=NULL; @@ -50,6 +56,8 @@ char *libtest_arg3=NULL; int test_argc; char **test_argv; +struct timeval tv_test_start; /* for test timing */ + #ifdef UNITTESTS int unitfail; /* for unittests */ #endif -- cgit v1.2.3