diff options
author | David Smith <dsmith@redhat.com> | 2010-03-16 15:10:06 -0500 |
---|---|---|
committer | David Smith <dsmith@redhat.com> | 2010-03-16 15:10:06 -0500 |
commit | 4612f779c64aec716433124099a8f82f47d9c90e (patch) | |
tree | c065ad11c3203c61b65a92dd2363ef4100dee77c /testsuite | |
parent | f4191849c1bf0d12086f74c969ac538a30211781 (diff) | |
download | systemtap-steved-4612f779c64aec716433124099a8f82f47d9c90e.tar.gz systemtap-steved-4612f779c64aec716433124099a8f82f47d9c90e.tar.xz systemtap-steved-4612f779c64aec716433124099a8f82f47d9c90e.zip |
Move common code from {maxmemory.exp,overload.exp} into stap_run_error.exp.
* testsuite/lib/stap_run_error.exp: New file.
* testsuite/config/unix.exp: Loads stap_run_error.exp.
* testsuite/systemtap.base/maxmemory.exp: Uses stap_run_error function
instead of local code.
* testsuite/systemtap.base/overload.exp: Ditto.
Diffstat (limited to 'testsuite')
-rw-r--r-- | testsuite/config/unix.exp | 1 | ||||
-rw-r--r-- | testsuite/lib/stap_run_error.exp | 62 | ||||
-rw-r--r-- | testsuite/systemtap.base/maxmemory.exp | 63 | ||||
-rw-r--r-- | testsuite/systemtap.base/overload.exp | 57 |
4 files changed, 70 insertions, 113 deletions
diff --git a/testsuite/config/unix.exp b/testsuite/config/unix.exp index 52560cac..eddd7d63 100644 --- a/testsuite/config/unix.exp +++ b/testsuite/config/unix.exp @@ -4,3 +4,4 @@ load_lib "stap_run_exact.exp" load_lib "stap_run_binary.exp" load_lib "stap_run.exp" load_lib "stap_compile.exp" +load_lib "stap_run_error.exp" diff --git a/testsuite/lib/stap_run_error.exp b/testsuite/lib/stap_run_error.exp new file mode 100644 index 00000000..060edccd --- /dev/null +++ b/testsuite/lib/stap_run_error.exp @@ -0,0 +1,62 @@ +# stap_run TEST_NAME EXPECT_ERROR ERROR_STRING OUTPUT_CHECK_STRING +# TEST_NAME is name of the current test +# EXPECT_ERROR lets us know to expect an error or not +# ERROR_STRING lets us know which error to expect +# OUTPUT_CHECK_STRING examines the output of experiment +# Additional arguments are passed to stap as-is. +proc stap_run_error { TEST_NAME EXPECT_ERROR ERROR_STRING OUTPUT_CHECK_STRING args } { + set full_error "ERROR: $ERROR_STRING\r\n" + set cmd [concat {stap -v} $args] + eval spawn $cmd + expect { + -timeout 150 + -re {^WARNING: [^r]+\r\n} {exp_continue} + -re {^Pass\ [1234]: [^\r]+real\ ms\.\r\n} {exp_continue} + -re {^Pass\ ([34]): using cached [^\r]+\r\n} {exp_continue} + -re {^Pass 5: starting run.\r\n} {exp_continue} + -re {^Error inserting module[^\r]+\r\n} { + if {$EXPECT_ERROR} { + pass "$TEST_NAME received expected insert module error" + } else { + fail "$TEST_NAME unexpected insert module error" + } + } + -re $full_error { + if {$EXPECT_ERROR} { + pass "$TEST_NAME received expected error" + } else { + fail "$TEST_NAME unexpected error" + } + } + -re "^systemtap starting probe\r\n" { + exec kill -INT -[exp_pid] + + # check the output to see if it is sane + set output "^systemtap ending probe\r\n$OUTPUT_CHECK_STRING" + + expect { + -timeout 10 + -re $output { + if {$EXPECT_ERROR} { + fail "$TEST_NAME didn't receive expected error" + } else { + pass "$TEST_NAME didn't error" + } + } + -re $full_error { + if {$EXPECT_ERROR} { + pass "$TEST_NAME received expected error" + } else { + fail "$TEST_NAME unexpected error" + } + } + } + } + -re "semantic error:" { fail "$TEST_NAME compilation" } + timeout { fail "$TEST_NAME startup (timeout)"; + exec kill -INT -[exp_pid] } + eof { fail "$TEST_NAME startup (eof)" } + } + catch close + wait +} diff --git a/testsuite/systemtap.base/maxmemory.exp b/testsuite/systemtap.base/maxmemory.exp index 20827edf..934c2161 100644 --- a/testsuite/systemtap.base/maxmemory.exp +++ b/testsuite/systemtap.base/maxmemory.exp @@ -16,71 +16,14 @@ set script { } } -# stap_run_maxmemory TEST_NAME EXPECT_ERROR -# TEST_NAME is the name of the current test -# EXPECT_ERROR lets us know to expect an error or not -# -# Additional arguments are passed to stap as-is. -proc stap_run_maxmemory { TEST_NAME EXPECT_ERROR args } { - - set cmd [concat {stap -v} $args] - eval spawn $cmd - expect { - -timeout 150 - -re {^Pass\ [1234]: [^\r]+real\ ms\.\r\n} {exp_continue} - -re {^Pass\ ([34]): using cached [^\r]+\r\n} {exp_continue} - -re {^Pass 5: starting run.\r\n} {exp_continue} - -re {^Error inserting module[^\r]+\r\n} { - if {$EXPECT_ERROR} { - pass "$TEST_NAME received expected insert module error" - } else { - fail "$TEST_NAME unexpected insert module error" - } - } - -re {ERROR: [^\r]+ allocation failed\r\n} { - if {$EXPECT_ERROR} { - pass "$TEST_NAME received expected allocation error" - } else { - fail "$TEST_NAME unexpected allocation error" - } - } - -re "^systemtap starting probe\r\n" { - exec kill -INT -[exp_pid] - - expect { - -timeout 10 - -re {^systemtap ending probe\r\n} { - if {$EXPECT_ERROR} { - fail "$TEST_NAME didn't receive expected allocation error" - } else { - pass "$TEST_NAME didn't receive allocation error" - } - } - -re {ERROR: .+ allocation failed\r\n} { - if {$EXPECT_ERROR} { - pass "$TEST_NAME received expected allocation error" - } else { - fail "$TEST_NAME received an unexpected allocation error" - } - } - } - } - -re "semantic error:" { fail "$TEST_NAME compilation" } - timeout { fail "$TEST_NAME startup (timeout)"; - exec kill -INT -[exp_pid] } - eof { fail "$TEST_NAME startup (eof)" } - } - catch close - wait -} - # MAXMEMORY1 tests to make sure normal operation doesn't receive a # max memory error set test "MAXMEMORY1" -stap_run_maxmemory $test 0 -u -e $script +set error {[^\r]+ allocation failed} +stap_run_error $test 0 $error "" -u -e $script # MAXMEMORY2 is the same script, but we're adjusting STP_MAXMEMORY to # a low value so that we *will* get an allocation error or an insert # module error. set test "MAXMEMORY2" -stap_run_maxmemory $test 1 -u -DSTP_MAXMEMORY=200 -e $script +stap_run_error $test 1 $error "" -u -DSTP_MAXMEMORY=200 -e $script diff --git a/testsuite/systemtap.base/overload.exp b/testsuite/systemtap.base/overload.exp index ac9ceb24..26988efc 100644 --- a/testsuite/systemtap.base/overload.exp +++ b/testsuite/systemtap.base/overload.exp @@ -16,66 +16,17 @@ set script { } } -# stap_run TEST_NAME EXPECT_OVERLOAD -# TEST_NAME is name of the current test -# EXPECT_OVERLOAD lets us know to expect and probe overload or not -# Additional arguments are passed to stap as-is. -proc stap_run_overload { TEST_NAME EXPECT_OVERLOAD args } { - - set cmd [concat {stap -v} $args] - eval spawn $cmd - expect { - -timeout 150 - -re {^Pass\ [1234]: [^\r]+real\ ms\.\r\n} {exp_continue} - -re {^Pass\ ([34]): using cached [^\r]+\r\n} {exp_continue} - -re {^Pass 5: starting run.\r\n} {exp_continue} - -re {ERROR: probe overhead exceeded threshold\r\n} { - if {$EXPECT_OVERLOAD} { - pass "$TEST_NAME received expected overload" - } else { - fail "$TEST_NAME unexpected overload" - } - } - -re "^systemtap starting probe\r\n" { - exec kill -INT -[exp_pid] - - expect { - -timeout 10 - -re {^systemtap ending probe\r\n} { - if {$EXPECT_OVERLOAD} { - fail "$TEST_NAME didn't receive expected overload" - } else { - pass "$TEST_NAME didn't overload" - } - } - -re {ERROR: probe overhead exceeded threshold\r\n} { - if {$EXPECT_OVERLOAD} { - pass "$TEST_NAME received expected overload" - } else { - fail "$TEST_NAME unexpected overload" - } - } - } - } - -re "semantic error:" { fail "$TEST_NAME compilation" } - timeout { fail "$TEST_NAME startup (timeout)"; - exec kill -INT -[exp_pid] } - eof { fail "$TEST_NAME startup (eof)" } - } - catch close - wait -} - # OVERLOAD1 tests to make sure normal operation doesn't receive an # overload indication set test "OVERLOAD1" -stap_run_overload $test 0 -u -e $script +set error "probe overhead exceeded threshold" +stap_run_error $test 0 $error "" -u -e $script # OVERLOAD2 is the same script, but we're adjusting the # STP_OVERLOAD_INTERVAL and STP_OVERLOAD_THRESHOLD to low values so # that we *will* get an overload. set test "OVERLOAD2" -stap_run_overload $test 1 -u -DSTP_OVERLOAD_INTERVAL=1000LL -DSTP_OVERLOAD_THRESHOLD=100LL -e $script +stap_run_error $test 1 $error "" -u -DSTP_OVERLOAD_INTERVAL=1000LL -DSTP_OVERLOAD_THRESHOLD=100LL -e $script # OVERLOAD3 is the same script with the same low STP_OVERLOAD_INTERVAL # and STP_OVERLOAD_THRESHOLD values, but we're also specifying @@ -83,4 +34,4 @@ stap_run_overload $test 1 -u -DSTP_OVERLOAD_INTERVAL=1000LL -DSTP_OVERLOAD_THRES # even though we have low overhead tuning values, we *shouldn't* # overload. set test "OVERLOAD3" -stap_run_overload $test 0 -u -DSTP_NO_OVERLOAD -DSTP_OVERLOAD_INTERVAL=1000LL -DSTP_OVERLOAD_THRESHOLD=100LL -e $script +stap_run_error $test 0 $error "" -u -DSTP_NO_OVERLOAD -DSTP_OVERLOAD_INTERVAL=1000LL -DSTP_OVERLOAD_THRESHOLD=100LL -e $script |