Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
hiredis
Commits
4ad99c69
Commit
4ad99c69
authored
Aug 29, 2022
by
michael-grunder
Committed by
Michael Grunder
Aug 29, 2022
Browse files
Rework asSleep to be a generic millisleep function.
parent
75cb6c1e
Changes
1
Hide whitespace changes
Inline
Side-by-side
test.c
View file @
4ad99c69
...
@@ -76,6 +76,15 @@ static int tests = 0, fails = 0, skips = 0;
...
@@ -76,6 +76,15 @@ static int tests = 0, fails = 0, skips = 0;
#define test_cond(_c) if(_c) printf("\033[0;32mPASSED\033[0;0m\n"); else {printf("\033[0;31mFAILED\033[0;0m\n"); fails++;}
#define test_cond(_c) if(_c) printf("\033[0;32mPASSED\033[0;0m\n"); else {printf("\033[0;31mFAILED\033[0;0m\n"); fails++;}
#define test_skipped() { printf("\033[01;33mSKIPPED\033[0;0m\n"); skips++; }
#define test_skipped() { printf("\033[01;33mSKIPPED\033[0;0m\n"); skips++; }
static void millisleep(int ms)
{
#if _MSC_VER
Sleep(ms);
#else
usleep(ms*1000);
#endif
}
static long long usec(void) {
static long long usec(void) {
#ifndef _MSC_VER
#ifndef _MSC_VER
struct timeval tv;
struct timeval tv;
...
@@ -1177,7 +1186,7 @@ static void test_blocking_connection_timeouts(struct config config) {
...
@@ -1177,7 +1186,7 @@ static void test_blocking_connection_timeouts(struct config config) {
freeReplyObject(reply);
freeReplyObject(reply);
// wait for the DEBUG SLEEP to complete so that Redis server is unblocked for the following tests
// wait for the DEBUG SLEEP to complete so that Redis server is unblocked for the following tests
sleep(3);
milli
sleep(3
000
);
} else {
} else {
test_skipped();
test_skipped();
}
}
...
@@ -1938,15 +1947,6 @@ struct _astest {
...
@@ -1938,15 +1947,6 @@ struct _astest {
};
};
static struct _astest astest;
static struct _astest astest;
static void asSleep(int ms)
{
#if _MSC_VER
Sleep(ms);
#else
usleep(ms*1000);
#endif
}
/* async callbacks */
/* async callbacks */
static void asCleanup(void* data)
static void asCleanup(void* data)
{
{
...
@@ -2127,7 +2127,7 @@ static void test_async_polling(struct config config) {
...
@@ -2127,7 +2127,7 @@ static void test_async_polling(struct config config) {
while(astest.connected == 0)
while(astest.connected == 0)
redisPollTick(c, 0.1);
redisPollTick(c, 0.1);
/* sleep 0.1 s, allowing old timeout to arrive */
/* sleep 0.1 s, allowing old timeout to arrive */
asS
leep(10);
millis
leep(10);
status = redisAsyncCommand(c, commandCallback, NULL, "PING");
status = redisAsyncCommand(c, commandCallback, NULL, "PING");
assert(status == REDIS_OK);
assert(status == REDIS_OK);
while(astest.ac)
while(astest.ac)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment