| 1 |
# stap_compile TEST_NAME flags script args |
| 2 |
# - TEST_NAME is the name of the current test |
| 3 |
# - compile indicates whether the script is supposed to compile |
| 4 |
# - script is the script to compile |
| 5 |
# Additional arguments are passed to stap as-is. |
| 6 |
proc stap_compile { TEST_NAME compile script args } { |
| 7 |
set cmd [concat stap {-v -p4 -e} $script $args] |
| 8 |
|
| 9 |
verbose -log "running $cmd" |
| 10 |
eval spawn $cmd |
| 11 |
set compile_errors 0 |
| 12 |
expect { |
| 13 |
-re {^Pass\ [1234]:[^\n\r]+\ in\ [^\n\r]+\ ms.\r\n} {exp_continue} |
| 14 |
-re {^Pass\ [34]: using cached [^\r\n]+\r\n} {exp_continue} |
| 15 |
-re "^WARNING" {exp_continue} |
| 16 |
# pass-4 output |
| 17 |
-re {^/[^\r\n]+.ko\r\n} {exp_continue} |
| 18 |
-re "parse error" { incr compile_errors 1; exp_continue} |
| 19 |
-re "compilation failed" {incr compile_errors 1; exp_continue} |
| 20 |
-re "semantic error:" {incr compile_errors 1; exp_continue} |
| 21 |
} |
| 22 |
catch close |
| 23 |
set res [wait -i $spawn_id] |
| 24 |
set res [lindex $res 3] |
| 25 |
|
| 26 |
if {($res == 0 && $compile_errors == 0) |
| 27 |
|| ($res != 0 && $compile_errors > 0)} { |
| 28 |
# Expected case. Ignore. Real pass/fail result will come below. |
| 29 |
} else { |
| 30 |
# stap result doesn't match errors seen. |
| 31 |
if {$res == 0} { |
| 32 |
fail "${TEST_NAME}_compile successfull, but got error messages" |
| 33 |
} else { |
| 34 |
fail "${TEST_NAME}_compile failed, but got no error messages" |
| 35 |
} |
| 36 |
} |
| 37 |
|
| 38 |
# If we've got compile errors and the script was supposed to |
| 39 |
# compile, fail. |
| 40 |
if {$compile_errors > 0} { |
| 41 |
if {$compile == 1} { |
| 42 |
fail "$TEST_NAME compilation" |
| 43 |
} else { |
| 44 |
xfail "$TEST_NAME compilation" |
| 45 |
} |
| 46 |
} else { |
| 47 |
if {$compile == 1} { |
| 48 |
pass "$TEST_NAME compilation" |
| 49 |
} else { |
| 50 |
xpass "$TEST_NAME compilation" |
| 51 |
} |
| 52 |
} |
| 53 |
} |