From 9e4f6c58093d5bb6d2fc8e7dfda225080450a47d Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 9 May 2014 16:48:11 +0200 Subject: libtests: add a wait_ms() function This allows a libcurl test to portably sleep for a given number of milliseconds. --- tests/libtest/first.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'tests/libtest/first.c') diff --git a/tests/libtest/first.c b/tests/libtest/first.c index 9ab7dc758..5851faf62 100644 --- a/tests/libtest/first.c +++ b/tests/libtest/first.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -59,6 +59,15 @@ int select_wrapper(int nfds, fd_set *rd, fd_set *wr, fd_set *exc, return select(nfds, rd, wr, exc, tv); } +void wait_ms(int ms) +{ + struct timeval t; + t.tv_sec = ms/1000; + ms -= (int)t.tv_sec * 1000; + t.tv_usec = ms * 1000; + select_wrapper(0, NULL, NULL , NULL, &t); +} + char *libtest_arg2=NULL; char *libtest_arg3=NULL; int test_argc; -- cgit v1.2.3