| 1 |
|
| 2 |
|
| 3 |
# # flag values |
| 4 |
proc F_UNCACHED {} {return 0x1}; # compilation should be uncached |
| 5 |
proc F_CACHED {} {return 0x2}; # compilation should be cached |
| 6 |
proc F_NO_COMPILE {} {return 0x4}; # script doesn't compile |
| 7 |
proc F_COMPILE {} {return 0x8}; # script compiles |
| 8 |
|
| 9 |
# mask values to get either the cache vale or the compile value |
| 10 |
proc F_CACHE_MASK {} {return [expr [F_UNCACHED] | [F_CACHED]]} |
| 11 |
proc F_COMPILE_MASK {} {return [expr [F_NO_COMPILE] | [F_COMPILE]]} |
| 12 |
|
| 13 |
# convenience combination of flags |
| 14 |
proc F_CACHED_COMPILE {} {return [expr [F_CACHED] | [F_COMPILE]]} |
| 15 |
proc F_UNCACHED_COMPILE {} {return [expr [F_UNCACHED] | [F_COMPILE]]} |
| 16 |
proc F_UNCACHED_NO_COMPILE {} {return [expr [F_UNCACHED] | [F_NO_COMPILE]]} |
| 17 |
|
| 18 |
# cache_compile TEST_NAME flags script args |
| 19 |
# - TEST_NAME is the name of the current test |
| 20 |
# - flags indicates the expected outcome of this test |
| 21 |
# - script is the script to compile |
| 22 |
# Additional arguments are passed to stap as-is. |
| 23 |
proc cache_compile { TEST_NAME flags script args } { |
| 24 |
set cmd [concat {stap -v -p4 -e} $script $args] |
| 25 |
|
| 26 |
eval spawn $cmd |
| 27 |
set cached 0 |
| 28 |
set compile_errors 0 |
| 29 |
expect { |
| 30 |
-timeout 180 |
| 31 |
-re {^Pass\ [1234]:[^\r]*\ in\ [^\r]*\ ms\.\r\n} {exp_continue} |
| 32 |
-re {^Pass\ [34]: using cached [^\r\n]+\r\n} {incr cached 1; exp_continue} |
| 33 |
-re "^WARNING" {exp_continue} |
| 34 |
# pass-4 output |
| 35 |
-re {^/[^\r\n]+\.ko\r\n} {exp_continue} |
| 36 |
-re "compilation failed" {incr compile_errors 1; exp_continue} |
| 37 |
-re "semantic error:" {incr compile_errors 1; exp_continue} |
| 38 |
timeout { fail "$TEST_NAME (timeout)" } |
| 39 |
} |
| 40 |
catch close |
| 41 |
wait |
| 42 |
|
| 43 |
# If we've got compile errors and the script was supposed to |
| 44 |
# compile, fail. |
| 45 |
if {$compile_errors > 0 |
| 46 |
&& [expr $flags & [F_COMPILE_MASK]] == [F_COMPILE]} { |
| 47 |
fail "$TEST_NAME compilation failed" |
| 48 |
return |
| 49 |
} |
| 50 |
|
| 51 |
# If we were supposed to use a cached module... |
| 52 |
if {[expr $flags & [F_CACHE_MASK]] == [F_CACHED]} { |
| 53 |
if {$cached == 2} { |
| 54 |
pass "$TEST_NAME was cached" |
| 55 |
} else { |
| 56 |
fail "$TEST_NAME wasn't cached" |
| 57 |
} |
| 58 |
# If we weren't supposed to use a cached module... |
| 59 |
} else { |
| 60 |
if {$cached > 0} { |
| 61 |
fail "$TEST_NAME was cached" |
| 62 |
} else { |
| 63 |
pass "$TEST_NAME wasn't cached" |
| 64 |
} |
| 65 |
} |
| 66 |
} |
| 67 |
|
| 68 |
|