From d4b715f0aa97bae7bf2f6ebfe4837f39c0451e84 Mon Sep 17 00:00:00 2001 From: Tom Lee Date: Wed, 18 Nov 2015 00:36:29 -0800 Subject: 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. --- test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test.c') 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); } -- cgit v1.2.3