summaryrefslogtreecommitdiff
path: root/test.c
diff options
context:
space:
mode:
authorTom Lee <github@tomlee.co>2015-11-18 00:36:29 -0800
committerTom Lee <github@tomlee.co>2015-11-18 00:36:29 -0800
commitd4b715f0aa97bae7bf2f6ebfe4837f39c0451e84 (patch)
treec818019583e1c1c6da7cee6fb1c1fa4e3e1758d7 /test.c
parentdb1c46dac7f0c54310e05a682cc444b7ae287dcf (diff)
Fix potential race in 'invalid timeout' tests
It's possible for the call to connect() to succeed on the very first try, in which case the logic for checking for invalid timeout fields is never executed. When this happens, the tests fail because they expect a REDIS_ERR_IO but no such failure has occurred. Tests aside, this is a potential source of irritating and hard-to-find intermittent bugs. This patch forces the validation to occur early so that we get predictable behavior whenever an invalid timeout is specified.
Diffstat (limited to 'test.c')
-rw-r--r--test.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/test.c b/test.c
index d5e8217..5dcac90 100644
--- a/test.c
+++ b/test.c
@@ -552,7 +552,7 @@ static void test_invalid_timeout_errors(struct config config) {
c = redisConnectWithTimeout(config.tcp.host, config.tcp.port, config.tcp.timeout);
- test_cond(c->err == REDIS_ERR_IO);
+ test_cond(c->err == REDIS_ERR_IO && strcmp(c->errstr, "Invalid timeout specified") == 0);
redisFree(c);
test("Set error when an invalid timeout sec value is given to redisConnectWithTimeout: ");
@@ -562,7 +562,7 @@ static void test_invalid_timeout_errors(struct config config) {
c = redisConnectWithTimeout(config.tcp.host, config.tcp.port, config.tcp.timeout);
- test_cond(c->err == REDIS_ERR_IO);
+ test_cond(c->err == REDIS_ERR_IO && strcmp(c->errstr, "Invalid timeout specified") == 0);
redisFree(c);
}