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.
flag.Parse()
before()
+ startAlarm()
RunTests(matchString, tests)
+ stopAlarm()
RunBenchmarks(matchString, benchmarks)
after()
}
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")
+}
keep=false
prefix=
dejagnu=no
+timeout=60
while $loop; do
case "x$1" in
x--srcdir)
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
;;
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