lucian1900/parrot — Issue #1: [PATCH] 3.9.0 Fails timer tests on NetBSD 5.1
Author: lucian1900
Created: 2011-10-21 08:20:59+00:00
State: open

{{{
On NetBSD 5.1, with parrot-3.9.0, several timer-related tests are
now failing. Specifically:

$ prove -v t/op/time.t, t/pmc/timer.t, and t/pir/timer_exit.t
t/op/time.t .........
1..19
ok 1 - Current int time is greater than 0
ok 2 - Current int time is greater than older time
ok 3 - Current num time is greater than 0.0
ok 4 - Current num time is greater than older time
not ok 5 - sleep_i increases time
not ok 6 - sleep_i slept for at least the amount of time specified
ok 7 - Cannot sleep_i backwards
ok 8 - sleep_n increases time
ok 9 - sleep_n slept for at least the integer amount of time specified
ok 10 - Cannot sleep_n backwards
ok 11 - TM_SEC ok
ok 12 - TM_MIN ok
ok 13 - TM_HOUR ok
ok 14 - TM_MDAY ok
ok 15 - TM_MON ok
ok 16 - TM_YEAR ok
ok 17 - TM_WDAY ok
ok 18 - TM_YDAY ok
ok 19 - TM_ISDST ok
Failed 2/19 subtests

# Failed test 'Timer setup - initializer/start'
# at t/pmc/timer.t line 158.
# 'ok 1
# ok 3
# '
# doesn't match '/ok 2/
# '

# Failed test 'Timer setup - initializer/start/repeat'
# at t/pmc/timer.t line 218.
# got: 'ok 1
# ok 3
# '
# expected: 'ok 1
# ok 2
# ok 2
# ok 2
# ok 3
# '
# Looks like you failed 2 tests of 9.
t/pmc/timer.t .......
1..9
ok 1 - Timer setup
ok 2 - Timer param test/invoke
ok 3 - Timer setup - initializer
not ok 4 - Timer setup - initializer/start
ok 5 - Timer setup - initializer/start/stop
not ok 6 - Timer setup - initializer/start/repeat
ok 7 - Timer start/repeat/stop
ok 8 - check whether interface is done
ok 9 - Timer - many repetitions
Dubious, test returned 2 (wstat 512, 0x200)
Failed 2/9 subtests
t/pir/timer_exit.t ..
1..1
not ok 3
Failed 1/1 subtests

Test Summary Report
-------------------
t/op/time.t (Wstat: 0 Tests: 19 Failed: 2)
Failed tests: 5-6
t/pmc/timer.t (Wstat: 512 Tests: 9 Failed: 2)
Failed tests: 4, 6
Non-zero exit status: 2
t/pir/timer_exit.t (Wstat: 0 Tests: 1 Failed: 1)
Failed test: 3
Parse errors: Tests out of sequence. Found (3) but expected (1)
Files=3, Tests=29, 5 wallclock secs ( 0.00 usr 0.05 sys + 0.13 cusr 2.16 csys = 2.34 CPU)
Result: FAIL

The problem is that the argument to usleep() must be less than 1 second,
but the test in src/scheduler.c passes it times <= 1 second. The
following simple patch fixes this.

diff -r -u parrot-3.9.0.orig/src/scheduler.c parrot-3.9.0/src/scheduler.c
--- parrot-3.9.0.orig/src/scheduler.c	2011-10-18 18:44:11.000000000 -0400
+++ parrot-3.9.0/src/scheduler.c	2011-10-19 09:43:16.000000000 -0400
@@ -993,10 +993,10 @@
Parrot_cx_runloop_wake(interp, interp->scheduler);

/* A more primitive, platform-specific, non-threaded form of sleep. */
- if (time > 1) {
+ if (time >= 1) {
/* prevent integer overflow when converting to microseconds
- * and problems in platforms that doesn't allow usleep more
- * than 1 second */
+ * and problems in platforms that don't allow usleep of
+ * 1 second or more */
const int seconds = floor(time);
Parrot_sleep(seconds);
time -= seconds;

--
Andy Dougherty	doughera@lafayette.edu

}}}