diff options
author | Sander Vrijders <[email protected]> | 2016-11-25 19:15:28 +0000 |
---|---|---|
committer | Sander Vrijders <[email protected]> | 2016-11-25 19:15:28 +0000 |
commit | 356da57dbd882a2e9a380c4d8b60f132f41cc593 (patch) | |
tree | 4ad06a26bea1e80ba292f516da3afb34478d5af6 /src/ipcpd/tests/timerwheel_test.c | |
parent | aee22e3b33e3e051cbc0f99ca033faf5fac22990 (diff) | |
parent | bf596a9abd6dc05b0d15e8401d267696632350a4 (diff) | |
download | ouroboros-356da57dbd882a2e9a380c4d8b60f132f41cc593.tar.gz ouroboros-356da57dbd882a2e9a380c4d8b60f132f41cc593.zip |
Merged in dstaesse/ouroboros/be-timerwheel (pull request #309)
ipcpd, lib: Fix timerwheel issues / time_utils
Diffstat (limited to 'src/ipcpd/tests/timerwheel_test.c')
-rw-r--r-- | src/ipcpd/tests/timerwheel_test.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/src/ipcpd/tests/timerwheel_test.c b/src/ipcpd/tests/timerwheel_test.c index 615e6e41..9274577a 100644 --- a/src/ipcpd/tests/timerwheel_test.c +++ b/src/ipcpd/tests/timerwheel_test.c @@ -54,16 +54,18 @@ int timerwheel_test(int argc, char ** argv) (void) argc; (void) argv; - srand(time(NULL)); - total = 0; + srand(time(NULL)); + resolution = rand() % (MAX_RESOLUTION - 1) + 1; elements = rand() % (MAX_ELEMENTS - 10) + 10; tw = timerwheel_create(resolution, resolution * elements); - if (tw == NULL) + if (tw == NULL) { + printf("Failed to create timerwheel.\n"); return -1; + } wait.tv_sec = (resolution * elements) / 1000; wait.tv_nsec = ((resolution * elements) % 1000) * MILLION; @@ -74,19 +76,24 @@ int timerwheel_test(int argc, char ** argv) int delay = rand() % (resolution * elements); int var = rand() % 5; check_total += var; - timerwheel_add(tw, - (void (*)(void *)) add, - (void *) &var, - sizeof(var), - delay); + if (timerwheel_add(tw, + (void (*)(void *)) add, + (void *) &var, + sizeof(var), + delay)) { + printf("Failed to add function."); + return -1; + } } nanosleep(&wait, NULL); timerwheel_destroy(tw); - if (total != check_total) + if (total != check_total) { + printf("Totals do not match.\n"); return -1; + } return 0; } |