1 2load_lib "dejagnu.exp" 3 4 5# If tracing has been enabled at the top level, then turn it on here 6# too. 7if $tracelevel { 8 strace $tracelevel 9} 10 11# After these many seconds of execution the test script is aborted 12# with a failure. 13# This is to handle deadlocks. We don't reset the timeout when a match is 14# found to avoid hanging in case of a testcase sending matches in an 15# infinite loops. 16# (not unlikely as it seems, think about flash movies...) 17# 18# Expressed in seconds. 19# 20set timeout 300 21set file all 22set params "" 23 24global env 25 26# testcases is set by the Makefile in the site.exp data file. 27foreach file $testcases { 28 29 verbose "Running test $file" 30 31 # spawn the executable and look for the DejaGnu output messages from the 32 # test case. 33 34 # this version of the call allows use of 'wait' to check return code 35 # -open [open "|cmd" "r"] doesn't work for that 36 37 # Ignore SIGHUP or we'd get a lot of them on Debian stable 38 set PID [spawn -noecho -ignore SIGHUP ./$file] 39 40 expect { 41 -re "^\[^\n]*NOTE:\[^\n]*\n" { 42 regsub ".*NOTE: " $expect_out(0,string) "" output 43 set output [string range $output 0 end-2] 44 verbose "${file} $output" 45 # notes tipically come from the test runner, so we'll trust it to mean 46 # things are someone not too bad... 47 # -continue_timer 48 exp_continue 49 } 50 -re "^\[^\n]* ERROR:\[^\n]*\n" { 51 regsub ".* ERROR: " $expect_out(0,string) "" output 52 set output [string range $output 0 end-2] 53 verbose "ERROR: ${file}: $output" 54 exp_continue -continue_timer 55 } 56 -re "^\[^\n]*XPASSED:\[^\n]*\n" { 57 regsub ".*XPASSED: " $expect_out(0,string) "" output 58 set output [string range $output 0 end-2] 59 xpass "${file}: $output" 60 exp_continue -continue_timer 61 } 62 -re "^\[^\n]*PASSED:\[^\n]*\n" { 63 regsub ".*PASSED: " $expect_out(0,string) "" output 64 set output [string range $output 0 end-2] 65 pass "${file}: $output" 66 exp_continue -continue_timer 67 } 68 -re "^\[^\n]*XFAILED:\[^\n]*\n" { 69 regsub ".*XFAILED: " $expect_out(0,string) "" output 70 set output [string range $output 0 end-2] 71 xfail "${file}: $output" 72 exp_continue -continue_timer 73 } 74 -re "^\[^\n]*FAILED:\[^\n]*\n" { 75 regsub ".*FAILED: " $expect_out(0,string) "" output 76 set output [string range $output 0 end-2] 77 fail "${file}: $output" 78 exp_continue -continue_timer 79 } 80 -re "^\[^\n]*UNTESTED:\[^\n]*\n" { 81 regsub ".*UNTESTED: " $expect_out(0,string) "" output 82 set output [string range $output 0 end-2] 83 untested "${file}: $output" 84 exp_continue -continue_timer 85 } 86 -re "^\[^\n]*UNRESOLVED:\[^\n]*\n" { 87 regsub ".*UNRESOLVED: " $expect_out(0,string) "" output 88 set output [string range $output 0 end-2] 89 unresolved "${file}: $output" 90 exp_continue -continue_timer 91 } 92 -re "^\[^\n]*\n" { 93 # just remove non-matching lines! 94 exp_continue -continue_timer 95 } 96 eof { 97 # unresolved "${file} died prematurely" 98 # catch close 99 # return "${file} died prematurely" 100 } 101 timeout { 102 fail "Test case ${file} still running after ${timeout} seconds, killing it (deadlock?)" 103 exec kill -9 $PID 104 catch close 105 continue; 106 } 107 } 108 109 # wait for the process to coplete to 110 # check return code 111 set retcode [wait] 112 113 # debugging 114 #set i 0; foreach j $retcode { print "${file} wait($i) $j"; incr i } 115 116 # This snippet catches segfaults and aborts. 117 # Would also catch SIGHUP, but we're ignoring them 118 # as on Debian Stable we unexpectedly get them for no apparent reason 119 # 120 if { [ llength $retcode ] > 5 } { 121 fail "${file} died prematurely ([lindex $retcode 6])" 122 } 123 124 # This snippet catches non-zero returns 125 if { [ lindex $retcode 3 ] != 0 } { 126 fail "${file} exited with non-zero code ([lindex $retcode 3])" 127 } 128 129 # force a close of the executable to be safe. 130 catch close 131} 132 133 134