Message ID | mcrei5mq5nk.fsf@google.com |
---|---|
State | New |
Headers | show |
Ian Lance Taylor <iant@google.com> writes: > This patch to libgo adds a timeout for the libgo tests. The default is > 60 seconds. It can be changed by an argument to gotest, which would > normally be used as, e.g., > make GOTESTFLAGS="--timeout=120" check-target-libgo Great, thanks. Shouldn't the default match the DejaGnu default of 300, though? Rainer
Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> writes: > Ian Lance Taylor <iant@google.com> writes: > >> This patch to libgo adds a timeout for the libgo tests. The default is >> 60 seconds. It can be changed by an argument to gotest, which would >> normally be used as, e.g., >> make GOTESTFLAGS="--timeout=120" check-target-libgo > > Great, thanks. > > Shouldn't the default match the DejaGnu default of 300, though? Sure, it could, but why? If any of these tests fail to complete in a minute, something is badly wrong. Ian
Ian Lance Taylor <iant@google.com> writes: >> Shouldn't the default match the DejaGnu default of 300, though? > > Sure, it could, but why? If any of these tests fail to complete in a > minute, something is badly wrong. Ok, I'll see how long they take on my 250 MHz R10k MIPS :-) Rainer
On Apr 1, 2011, at 12:14 AM, Rainer Orth wrote: > Ian Lance Taylor <iant@google.com> writes: > >> This patch to libgo adds a timeout for the libgo tests. The default is >> 60 seconds. It can be changed by an argument to gotest, which would >> normally be used as, e.g., >> make GOTESTFLAGS="--timeout=120" check-target-libgo > > Great, thanks. > > Shouldn't the default match the DejaGnu default of 300, though? No... I like the idea that people trim it down to something sane. If nothing else, as a way to discourage them from big stupid test cases.
On Apr 1, 2011, at 7:21 AM, Rainer Orth wrote: > Ian Lance Taylor <iant@google.com> writes: > >>> Shouldn't the default match the DejaGnu default of 300, though? >> >> Sure, it could, but why? If any of these tests fail to complete in a >> minute, something is badly wrong. > > Ok, I'll see how long they take on my 250 MHz R10k MIPS :-) I'd rather slow environments and slow machines setup a scaling factor with which they can expand the time as needed. So, using a rs232 port at 110 to download testcases, scaling_factor=1000 or so.
Mike Stump <mikestump@comcast.net> writes: >> Shouldn't the default match the DejaGnu default of 300, though? > > No... I like the idea that people trim it down to something sane. If nothing else, as a way to discourage them from big stupid test cases. No argument from me, since I've often been bitten by slower testcases. I just argue that we should be consistent throughout the tree. If that means going for a 60 second default, fine :-) Rainer
Mike Stump <mikestump@comcast.net> writes: >> Ok, I'll see how long they take on my 250 MHz R10k MIPS :-) > > I'd rather slow environments and slow machines setup a scaling factor with which they can expand the time as needed. So, using a rs232 port at 110 to download testcases, scaling_factor=1000 or so. That's what I already did for this box. Probably time to get rid of it ;-) Rainer
diff -r 86dce29de0ad libgo/go/testing/testing.go --- a/libgo/go/testing/testing.go Thu Mar 31 15:18:20 2011 -0700 +++ b/libgo/go/testing/testing.go Thu Mar 31 15:33:09 2011 -0700 @@ -61,6 +61,7 @@ memProfile = flag.String("test.memprofile", "", "write a memory profile to the named file after execution") memProfileRate = flag.Int("test.memprofilerate", 0, "if >=0, sets runtime.MemProfileRate") cpuProfile = flag.String("test.cpuprofile", "", "write a cpu profile to the named file during execution") + timeout = flag.Int64("test.timeout", 0, "if > 0, sets time limit for tests in seconds") ) // Short reports whether the -test.short flag is set. @@ -158,7 +159,9 @@ flag.Parse() before() + startAlarm() RunTests(matchString, tests) + stopAlarm() RunBenchmarks(matchString, benchmarks) after() } @@ -241,3 +244,24 @@ f.Close() } } + +var timer *time.Timer + +// startAlarm starts an alarm if requested. +func startAlarm() { + if *timeout > 0 { + timer = time.AfterFunc(*timeout*1e9, alarm) + } +} + +// stopAlarm turns off the alarm. +func stopAlarm() { + if *timeout > 0 { + timer.Stop() + } +} + +// alarm is called if the timeout expires. +func alarm() { + panic("test timed out") +} diff -r 86dce29de0ad libgo/testsuite/gotest --- a/libgo/testsuite/gotest Thu Mar 31 15:18:20 2011 -0700 +++ b/libgo/testsuite/gotest Thu Mar 31 15:33:09 2011 -0700 @@ -32,6 +32,7 @@ keep=false prefix= dejagnu=no +timeout=60 while $loop; do case "x$1" in x--srcdir) @@ -83,6 +84,15 @@ dejagnu=`echo $1 | sed -e 's/^--dejagnu=//'` shift ;; + x--timeout) + timeout=$2 + shift + shift + ;; + x--timeout=*) + timeout=`echo $1 | sed -e 's/^--timeout=//'` + shift + ;; x-*) loop=false ;; @@ -357,7 +367,7 @@ xno) ${GC} -g -c _testmain.go ${GL} *.o ${GOLIBS} - ./a.out -test.short "$@" + ./a.out -test.short -test.timeout=$timeout "$@" ;; xyes) rm -rf ../testsuite/*.o