diff options
author | max99x <max99x@gmail.com> | 2011-07-24 05:26:25 +0300 |
---|---|---|
committer | max99x <max99x@gmail.com> | 2011-07-24 05:26:25 +0300 |
commit | 211884f29996dc8beb89d1bcf6b643c1fbf5d6a4 (patch) | |
tree | ea40783e53ce0588e566d386a9805c5e5b5c498f /tests/unistd | |
parent | 5aea0ba8784bc385e52e769f8e90df5fcd833a7a (diff) |
Fixed unistd sleep test to be more flexible.
Diffstat (limited to 'tests/unistd')
-rw-r--r-- | tests/unistd/sleep.c | 9 | ||||
-rw-r--r-- | tests/unistd/sleep.out | 4 |
2 files changed, 8 insertions, 5 deletions
diff --git a/tests/unistd/sleep.c b/tests/unistd/sleep.c index 5a0302e2..1171a0a6 100644 --- a/tests/unistd/sleep.c +++ b/tests/unistd/sleep.c @@ -5,16 +5,19 @@ int main() { time_t start; + time_t taken; start = time(0); printf("sleep(2) ret: %d\n", sleep(2)); - printf("after sleep(2): %d\n", time(0) - start); + taken = time(0) - start; + printf("after sleep(2) between 2 and 3: %d\n", taken >= 2 && taken <= 3); printf("errno: %d\n", errno); errno = 0; start = time(0); - printf("usleep(3000000) ret: %d\n", usleep(3100000)); - printf("after usleep(3000000): %d\n", time(0) - start); + printf("usleep(3000000) ret: %d\n", usleep(3000000)); + taken = time(0) - start; + printf("after usleep(3000000) between 3 and 4: %d\n", taken >= 3 && taken <= 4); printf("errno: %d\n", errno); return 0; diff --git a/tests/unistd/sleep.out b/tests/unistd/sleep.out index 9a668e91..3cad7c8a 100644 --- a/tests/unistd/sleep.out +++ b/tests/unistd/sleep.out @@ -1,6 +1,6 @@ sleep(2) ret: 0 -after sleep(2): 2 +after sleep(2) between 2 and 3: 1 errno: 0 usleep(3000000) ret: 0 -after usleep(3000000): 3 +after usleep(3000000) between 3 and 4: 1 errno: 0 |