summaryrefslogtreecommitdiffstats
path: root/tests/clock.test
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2018-11-10 09:39:35 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2018-11-10 09:39:35 (GMT)
commit6fe99b6e66c8a2606658ee482d9f1390ef403b78 (patch)
tree0b7c81a5ac30e60661decff5cbb8bd6dae705cec /tests/clock.test
parentcbbc8d66b85371d63ec183c6712ae6c769ab9403 (diff)
downloadtcl-6fe99b6e66c8a2606658ee482d9f1390ef403b78.zip
tcl-6fe99b6e66c8a2606658ee482d9f1390ef403b78.tar.gz
tcl-6fe99b6e66c8a2606658ee482d9f1390ef403b78.tar.bz2
Tracking down test failures
Diffstat (limited to 'tests/clock.test')
-rw-r--r--tests/clock.test42
1 files changed, 23 insertions, 19 deletions
diff --git a/tests/clock.test b/tests/clock.test
index 4ec4db2..3ad5c9f 100644
--- a/tests/clock.test
+++ b/tests/clock.test
@@ -250,6 +250,16 @@ proc ::testClock::registry { cmd path key } {
return [dict get $reg $path $key]
}
+proc timeWithinDuration {duration start end} {
+ regexp {([\d.]+)(s|ms|us)} $duration -> duration unit
+ set delta [expr {$end - $start}]
+ expr {
+ ($delta > 0) && ($delta <= $duration) ?
+ "ok" :
+ "test should have taken 0-$duration $unit, actually took $delta"}
+}
+
+
# Test some of the basics of [clock format]
test clock-1.0 "clock format - wrong # args" {
@@ -35425,7 +35435,7 @@ test clock-33.2 {clock clicks tests} {
set start [clock clicks]
after 10
set end [clock clicks]
- expr "$end > $start"
+ expr {$end > $start}
} {1}
test clock-33.3 {clock clicks tests} {
list [catch {clock clicks foo} msg] $msg
@@ -35440,27 +35450,21 @@ test clock-33.4a {clock milliseconds} {
} {}
test clock-33.5 {clock clicks tests, millisecond timing test} {
# This test can fail on a system that is so heavily loaded that
- # the test takes >60 ms to run.
+ # the test takes >120 ms to run.
set start [clock clicks -milli]
after 10
set end [clock clicks -milli]
- # 60 msecs seems to be the max time slice under Windows 95/98
- expr {
- ($end > $start) && (($end - $start) <= 60) ?
- "ok" :
- "test should have taken 0-60 ms, actually took [expr $end - $start]"}
+ # 60 msecs seems to be the max time slice under Windows 95/98;
+ timeWithinDuration 120ms $start $end
} {ok}
test clock-33.5a {clock tests, millisecond timing test} {
# This test can fail on a system that is so heavily loaded that
- # the test takes >60 ms to run.
+ # the test takes >120 ms to run.
set start [clock milliseconds]
after 10
set end [clock milliseconds]
# 60 msecs seems to be the max time slice under Windows 95/98
- expr {
- ($end > $start) && (($end - $start) <= 60) ?
- "ok" :
- "test should have taken 0-60 ms, actually took [expr $end - $start]"}
+ timeWithinDuration 120ms $start $end
} {ok}
test clock-33.6 {clock clicks, milli with too much abbreviation} {
list [catch { clock clicks ? } msg] $msg
@@ -35471,20 +35475,20 @@ test clock-33.7 {clock clicks, milli with too much abbreviation} {
test clock-33.8 {clock clicks test, microsecond timing test} {
# This test can fail on a system that is so heavily loaded that
- # the test takes >60 ms to run.
+ # the test takes >120 ms to run.
set start [clock clicks -micro]
after 10
set end [clock clicks -micro]
- expr {($end > $start) && (($end - $start) <= 60000)}
-} {1}
+ timeWithinDuration 120000us $start $end
+} {ok}
test clock-33.8a {clock test, microsecond timing test} {
# This test can fail on a system that is so heavily loaded that
- # the test takes >60 ms to run.
+ # the test takes >120 ms to run.
set start [clock microseconds]
after 10
set end [clock microseconds]
- expr {($end > $start) && (($end - $start) <= 60000)}
-} {1}
+ timeWithinDuration 120000us $start $end
+} {ok}
test clock-33.9 {clock clicks test, millis align with seconds} {
set t1 [clock seconds]
@@ -35826,7 +35830,7 @@ test clock-35.3 {clock seconds tests} {
set start [clock seconds]
after 2000
set end [clock seconds]
- expr "$end > $start"
+ expr {$end > $start}
} {1}