From 4612f779c64aec716433124099a8f82f47d9c90e Mon Sep 17 00:00:00 2001 From: David Smith Date: Tue, 16 Mar 2010 15:10:06 -0500 Subject: 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. --- testsuite/lib/stap_run_error.exp | 62 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 testsuite/lib/stap_run_error.exp (limited to 'testsuite/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 +} -- cgit