summaryrefslogtreecommitdiffstats
path: root/testsuite/lib/stap_run_error.exp
diff options
context:
space:
mode:
authorDavid Smith <dsmith@redhat.com>2010-03-16 15:10:06 -0500
committerDavid Smith <dsmith@redhat.com>2010-03-16 15:10:06 -0500
commit4612f779c64aec716433124099a8f82f47d9c90e (patch)
treec065ad11c3203c61b65a92dd2363ef4100dee77c /testsuite/lib/stap_run_error.exp
parentf4191849c1bf0d12086f74c969ac538a30211781 (diff)
downloadsystemtap-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/lib/stap_run_error.exp')
-rw-r--r--testsuite/lib/stap_run_error.exp62
1 files changed, 62 insertions, 0 deletions
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
+}