aboutsummaryrefslogtreecommitdiff
path: root/tests/time
diff options
context:
space:
mode:
authorkripken <alonzakai@gmail.com>2011-07-09 10:28:19 -0700
committerkripken <alonzakai@gmail.com>2011-07-09 10:28:19 -0700
commitc79828f6b89cc64cb21ebfa00454b8ce26718cf8 (patch)
tree2f7250c054c7ff46088b3877b619f5715699b66f /tests/time
parent4fe5b2b7b6d9695a81880922ee249c620880b5d2 (diff)
parent11e404d7a8c76dbc1f10e24f4cee527f36d20092 (diff)
Merge pull request #47 from max99x/master
Emscripten.py rewrite
Diffstat (limited to 'tests/time')
-rw-r--r--tests/time/output.txt3
-rw-r--r--tests/time/src.c10
2 files changed, 9 insertions, 4 deletions
diff --git a/tests/time/output.txt b/tests/time/output.txt
index ae1fde67..45b7d4bd 100644
--- a/tests/time/output.txt
+++ b/tests/time/output.txt
@@ -33,5 +33,6 @@ asctime: Wed Dec 25 03:22:43 2002
old asctime: Wed Dec 25 03:22:43 2002
new asctime_r: Sat Jul 2 19:33:20 2011
old asctime again: Wed Dec 25 03:22:43 2002
-clock: 0
+clock(start): 1
+clock(end): 1
ctime: 0
diff --git a/tests/time/src.c b/tests/time/src.c
index 3d4da4c2..9517b74c 100644
--- a/tests/time/src.c
+++ b/tests/time/src.c
@@ -91,10 +91,14 @@ int main() {
asctime_r(tm_ptr, buffer);
printf("old asctime again: %s", formatted);
- // Verify that clock() is initially 0 and doesn't crash.
- printf("clock: %d\n", clock());
+ // Verify that clock() advances.
+ time_t start_t = time(NULL);
+ clock_t start = clock();
+ printf("clock(start): %d\n", start >= 0);
+ while (clock() - start < 2 * CLOCKS_PER_SEC); // Poor man's sleep().
+ printf("clock(end): %d\n", time(NULL) - start_t == 2);
- // Verify that ctime_r(x, buf) is equivalent to asctime_r(localtime(x), buf2).
+ // Verify that ctime_r(x, buf) is equivalent to asctime_r(localtime(x), buf).
time_t t7 = time(0);
char buffer2[30];
char buffer3[30];