diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2012-06-29 12:56:05 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2012-06-29 12:56:05 +0300 |
commit | 518bcc6e640648717bc5512d3fd5c2bf16d6fec3 (patch) | |
tree | 3c9a06e92e0885fe3be95bece136fe74574218fe | |
parent | 33734338e34ed4588ca05cecd5324d5ab5a1a654 (diff) | |
parent | 47828911ae88038eda1051cfa2232f46eda95fd8 (diff) | |
download | egawk-518bcc6e640648717bc5512d3fd5c2bf16d6fec3.tar.gz egawk-518bcc6e640648717bc5512d3fd5c2bf16d6fec3.tar.bz2 egawk-518bcc6e640648717bc5512d3fd5c2bf16d6fec3.zip |
Merge branch 'extgawk' of ssh://git.sv.gnu.org/srv/git/gawk into extgawk
-rw-r--r-- | test/ChangeLog | 5 | ||||
-rw-r--r-- | test/time.awk | 14 |
2 files changed, 17 insertions, 2 deletions
diff --git a/test/ChangeLog b/test/ChangeLog index a0f7a649..057434f9 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,8 @@ +2012-06-28 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * time.awk: Avoid possibly throwing a spurious error by protecting + a race condition that depends on the order of expression evaluation. + 2012-06-25 Arnold D. Robbins <arnold@skeeve.com> * Makefile.am (rwarray): New test. diff --git a/test/time.awk b/test/time.awk index eeabc7bb..517377e2 100644 --- a/test/time.awk +++ b/test/time.awk @@ -1,10 +1,20 @@ @load "time" +# make sure gettimeofday() is consistent with systime(). We must call +# gettimeofday() before systime() to make sure the subtraction gives 0 +# without risk of rolling over to the next second. +function timecheck(st,res) { + res = gettimeofday() + st = systime() + printf "gettimeofday - systime = %d\n", res-st + return res +} + BEGIN { delta = 1.3 - printf "gettimeofday - systime = %d\n", (t0 = gettimeofday())-systime() + t0 = timecheck() printf "sleep(%s) = %s\n",delta,sleep(delta) - printf "gettimeofday - systime = %d\n", (t1 = gettimeofday())-systime() + t1 = timecheck() slept = t1-t0 if ((slept < 0.9*delta) || (slept > 1.3*delta)) printf "Warning: tried to sleep %.2f secs, but slept for %.2f secs\n", |