From fb1209c72bbfd431b61fa4588785586d24ef67c9 Mon Sep 17 00:00:00 2001 From: Martin Sustrik Date: Thu, 16 Feb 2012 10:06:30 +0900 Subject: More MSVC tests added Signed-off-by: Martin Sustrik --- tests/timeo.cpp | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) (limited to 'tests/timeo.cpp') diff --git a/tests/timeo.cpp b/tests/timeo.cpp index 3cb09f1..ade5150 100644 --- a/tests/timeo.cpp +++ b/tests/timeo.cpp @@ -20,30 +20,20 @@ #include "testutil.hpp" -#if defined XS_HAVE_WINDOWS -int XS_TEST_MAIN () -{ - return 0; -} -#else - -#include - extern "C" { - void *worker(void *ctx) + void timeo_worker(void *ctx_) { // Worker thread connects after delay of 1 second. Then it waits // for 1 more second, so that async connect has time to succeed. xs_sleep (1); - void *sc = xs_socket (ctx, XS_PUSH); + void *sc = xs_socket (ctx_, XS_PUSH); assert (sc); int rc = xs_connect (sc, "inproc://timeout_test"); assert (rc == 0); xs_sleep (1); rc = xs_close (sc); assert (rc == 0); - return NULL; } } @@ -82,17 +72,15 @@ int XS_TEST_MAIN () timeout = 2000; rc = xs_setsockopt(sb, XS_RCVTIMEO, &timeout, timeout_size); assert (rc == 0); - pthread_t thread; - rc = pthread_create (&thread, NULL, worker, ctx); - assert (rc == 0); + void *thread = xs_thread_create (timeo_worker, ctx); + assert (thread); watch = xs_stopwatch_start (); rc = xs_recv (sb, buf, 32, 0); assert (rc == -1); assert (xs_errno () == EAGAIN); elapsed = xs_stopwatch_stop (watch); assert (elapsed > 1900000 && elapsed < 2100000); - rc = pthread_join (thread, NULL); - assert (rc == 0); + xs_thread_join (thread); // Check that timeouts don't break normal message transfer. void *sc = xs_socket (ctx, XS_PUSH); @@ -118,5 +106,3 @@ int XS_TEST_MAIN () return 0 ; } - -#endif \ No newline at end of file -- cgit v1.2.3