aboutsummaryrefslogtreecommitdiff
path: root/tests/libtest/first.c
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2011-10-21 16:26:18 +0200
committerYang Tse <yangsita@gmail.com>2011-10-21 16:52:14 +0200
commit629d2e34508838069db83e1082ce9e7f2c7b8ff8 (patch)
tree365dedb351b18ba56d36d846b9270120850c8583 /tests/libtest/first.c
parent90fcad63cbb9943c7c7a564944a3bce7d10e581a (diff)
multi tests: OOM handling fixes
Additionally, improved error checking and logging.
Diffstat (limited to 'tests/libtest/first.c')
-rw-r--r--tests/libtest/first.c20
1 files changed, 14 insertions, 6 deletions
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