summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMartin Sustrik <sustrik@250bpm.com>2012-04-16 07:47:00 +0200
committerMartin Sustrik <sustrik@250bpm.com>2012-04-17 07:34:37 +0200
commitdc4ed5a7b59f1d5b4e4f7fb4b6e29ecaf5e6cc5c (patch)
tree29987586f7012a31c187de491edc99aea174473b /tests
parent443d06f894751062da6d69238ce09f6fbfc27577 (diff)
XS_SURVEY_TIMEOUT socket option added.
It can be used to timeout the survey. Value is in milliseconds and -1 means infinite (default). Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/survey.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/survey.cpp b/tests/survey.cpp
index 41f39aa..c6b3131 100644
--- a/tests/survey.cpp
+++ b/tests/survey.cpp
@@ -118,6 +118,18 @@ int XS_TEST_MAIN ()
rc = xs_recv (surveyor, buf, sizeof (buf), 0);
assert (rc == 4);
+ // Now let's test whether survey timeout works as expected.
+ int timeout = 100;
+ rc = xs_setsockopt (surveyor, XS_SURVEY_TIMEOUT, &timeout, sizeof (int));
+ assert (rc == 0);
+ rc = xs_send (surveyor, "ABC", 3, 0);
+ assert (rc == 3);
+ void *watch = xs_stopwatch_start ();
+ rc = xs_recv (surveyor, buf, sizeof (buf), 0);
+ assert (rc == - 1 && errno == EAGAIN);
+ unsigned long elapsed = xs_stopwatch_stop (watch) / 1000;
+ time_assert (elapsed, (unsigned long) timeout);
+
rc = xs_close (respondent2);
assert (rc == 0);
rc = xs_close (respondent1);