| 1 |
# stap_run TEST_NAME EXPECT_ERROR ERROR_STRING OUTPUT_CHECK_STRING |
| 2 |
# TEST_NAME is name of the current test |
| 3 |
# EXPECT_ERROR lets us know to expect an error or not |
| 4 |
# ERROR_STRING lets us know which error to expect |
| 5 |
# OUTPUT_CHECK_STRING examines the output of experiment |
| 6 |
# Additional arguments are passed to stap as-is. |
| 7 |
proc stap_run_error { TEST_NAME EXPECT_ERROR ERROR_STRING OUTPUT_CHECK_STRING args } { |
| 8 |
set full_error "ERROR: $ERROR_STRING\r\n" |
| 9 |
set cmd [concat {stap -v} $args] |
| 10 |
send_log "executing: $cmd\n" |
| 11 |
eval spawn $cmd |
| 12 |
set mypid [exp_pid -i $spawn_id] |
| 13 |
expect { |
| 14 |
-timeout 150 |
| 15 |
-re {^WARNING: [^\r]+\r\n} {exp_continue} |
| 16 |
-re {^Pass\ [1234]: [^\r]+real\ ms\.\r\n} {exp_continue} |
| 17 |
-re {^Pass\ ([34]): using cached [^\r]+\r\n} {exp_continue} |
| 18 |
-re {^Pass 5: starting run.\r\n} {exp_continue} |
| 19 |
-re {^ERROR: Couldn't insert module[^\r]+\r\n} { |
| 20 |
if {$EXPECT_ERROR} { |
| 21 |
pass "$TEST_NAME expected insert module error" |
| 22 |
} else { |
| 23 |
fail "$TEST_NAME expected insert module error" |
| 24 |
} |
| 25 |
} |
| 26 |
-re $full_error { |
| 27 |
if {$EXPECT_ERROR} { |
| 28 |
pass "$TEST_NAME expected error" |
| 29 |
} else { |
| 30 |
fail "$TEST_NAME expected error" |
| 31 |
} |
| 32 |
} |
| 33 |
-re "^systemtap starting probe\r\n" { |
| 34 |
kill -INT -$mypid |
| 35 |
|
| 36 |
# check the output to see if it is sane |
| 37 |
set output "^systemtap ending probe\r\n$OUTPUT_CHECK_STRING" |
| 38 |
|
| 39 |
expect { |
| 40 |
-timeout 20 |
| 41 |
-re $output { |
| 42 |
if {$EXPECT_ERROR} { |
| 43 |
fail "$TEST_NAME no expected error" |
| 44 |
} else { |
| 45 |
pass "$TEST_NAME no expected error" |
| 46 |
} |
| 47 |
} |
| 48 |
-re $full_error { |
| 49 |
if {$EXPECT_ERROR} { |
| 50 |
pass "$TEST_NAME expected error" |
| 51 |
} else { |
| 52 |
fail "$TEST_NAME expected error" |
| 53 |
} |
| 54 |
} |
| 55 |
timeout { |
| 56 |
fail "$TEST_NAME shutdown (timeout)" |
| 57 |
kill -INT -$mypid |
| 58 |
} |
| 59 |
eof { fail "$TEST_NAME shutdown (eof)" } |
| 60 |
} |
| 61 |
} |
| 62 |
-re "semantic error:" { fail "$TEST_NAME compilation" } |
| 63 |
timeout { fail "$TEST_NAME startup (timeout)"; |
| 64 |
kill -INT -$mypid } |
| 65 |
eof { fail "$TEST_NAME startup (eof)" } |
| 66 |
} |
| 67 |
# again for good measure with KILL after 3s |
| 68 |
kill -INT -$mypid 3 |
| 69 |
catch close |
| 70 |
wait |
| 71 |
} |