summaryrefslogtreecommitdiff
path: root/tests/timeo.cpp
diff options
context:
space:
mode:
authorMartin Sustrik <sustrik@250bpm.cpm>2012-02-16 10:06:30 +0900
committerMartin Sustrik <sustrik@250bpm.com>2012-02-16 10:06:30 +0900
commitfb1209c72bbfd431b61fa4588785586d24ef67c9 (patch)
tree6c33ac55809c64e57e44b347879fe297e894be5e /tests/timeo.cpp
parent0d384b7944c20f3389c2be9363afac99783d776a (diff)
More MSVC tests added
Signed-off-by: Martin Sustrik <sustrik@250bpm.cpm>
Diffstat (limited to 'tests/timeo.cpp')
-rw-r--r--tests/timeo.cpp24
1 files changed, 5 insertions, 19 deletions
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 <pthread.h>
-
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