summaryrefslogtreecommitdiffstats
path: root/testsuite/lib
diff options
context:
space:
mode:
authorfche <fche>2006-08-12 05:13:09 +0000
committerfche <fche>2006-08-12 05:13:09 +0000
commit814bc89d4635f101b2c0077598f31aad95ed15b7 (patch)
tree407a49dbaf446af4751f5068607a7fb8dad0611d /testsuite/lib
parent6b6d04673a1ef175821afc7d4fabdb496698e8e3 (diff)
downloadsystemtap-steved-814bc89d4635f101b2c0077598f31aad95ed15b7.tar.gz
systemtap-steved-814bc89d4635f101b2c0077598f31aad95ed15b7.tar.xz
systemtap-steved-814bc89d4635f101b2c0077598f31aad95ed15b7.zip
2006-08-12 Frank Ch. Eigler <fche@elastic.org>
* configure.ac, Makefile.am: Descend into testsuite/ directory. Remove local test logic. * configure, Makefile.in: Regenerated. * runtest.sh: Not yet removed. * HACKING: Update for new testsuite layout. 2006-08-12 Frank Ch. Eigler <fche@elastic.org> * all: Reorganized old pass-1..4 tests one dejagnu bucket. Moved over old pass-5 tests, except for disabled syscalls tests. * Makefile (installcheck): New target for running pass-1..5 tests against installed systemtap.
Diffstat (limited to 'testsuite/lib')
-rw-r--r--testsuite/lib/stap_run.exp72
-rw-r--r--testsuite/lib/stap_run2.exp51
-rw-r--r--testsuite/lib/stap_run_binary.exp23
-rw-r--r--testsuite/lib/systemtap.exp61
4 files changed, 207 insertions, 0 deletions
diff --git a/testsuite/lib/stap_run.exp b/testsuite/lib/stap_run.exp
new file mode 100644
index 00000000..d230e8e5
--- /dev/null
+++ b/testsuite/lib/stap_run.exp
@@ -0,0 +1,72 @@
+# stap_run.exp
+#
+# Will Cohen
+# 8/12/2005
+
+
+# stap_run TEST_NAME LOAD_GEN_FUNCTION OUTPUT_CHECK_STRING
+# TEST_NAME is path to the current test
+# LOAD_GEN_FUNCTION (optional) to produce something to measure
+# returns 0 if successful
+# returns 1 if there was a problem
+# OUTPUT_CHECK_STRING (optional) examines the output of experiment
+# returns 0 if successful
+# returns 1 if there was a problem
+# Additional arguments are passed to stap as-is.
+proc stap_run { TEST_NAME {LOAD_GEN_FUNCTION ""} {OUTPUT_CHECK_STRING ""} args } {
+ if {![installtest_p]} { untested $TEST_NAME; return }
+
+ set cmd [concat {stap -v} $args]
+ if [file readable $TEST_NAME] {
+ lappend cmd $TEST_NAME
+ }
+ eval spawn $cmd
+ expect {
+ -re {^Pass\ ([1234]):[^\r]*\ in\ ([0-9]+)usr/([0-9]+)sys/([0-9]+)real\ ms.\r\n}
+ {set pass$expect_out(1,string) "\t$expect_out(2,string)\t$expect_out(3,string)\t$expect_out(4,string)"; exp_continue}
+ -re {^Pass 5: starting run.\r\n} {exp_continue}
+ -timeout 30 -re "^systemtap starting probe\r\n" {
+ pass "$TEST_NAME startup"
+ if {$LOAD_GEN_FUNCTION != ""} then {
+ #run the interesting test here
+ if {[eval $LOAD_GEN_FUNCTION] == 0} then {
+ pass "$TEST_NAME load generation"
+ } else {
+ fail "$TEST_NAME load generation"
+ }
+ }
+
+ send "\003"
+
+ #check the output to see if it is sane
+ set output "^systemtap ending probe\r\n$OUTPUT_CHECK_STRING"
+
+ expect {
+ -re $output {
+ pass "$TEST_NAME shutdown and output"
+ expect {
+ -re {^Pass\ ([5]):[^\r]*\ in\ ([0-9]+)usr/([0-9]+)sys/([0-9]+)real\ ms.\r\n}
+ {set pass$expect_out(1,string) "\t$expect_out(2,string)\t$expect_out(3,string)\t$expect_out(4,string)"
+ verbose -log "metric:\t$TEST_NAME $pass1$pass2$pass3$pass4$pass5"}
+ }
+ }
+ timeout { fail "$TEST_NAME shutdown (timeout)" }
+ eof { fail "$TEST_NAME shutdown (eof)" }
+ }
+ }
+ -re "semantic error:" { fail "$TEST_NAME compilation" }
+ timeout { fail "$TEST_NAME startup (timeout)"; send "\003" }
+ eof { fail "$TEST_NAME startup (eof)" }
+ }
+ catch close
+ wait
+}
+
+proc no_load {} {
+# nothing in here
+# load to use when nothing is needed
+ return 0
+}
+
+# tests better all be true
+set all_pass_string "(systemtap test success\r\n)+"
diff --git a/testsuite/lib/stap_run2.exp b/testsuite/lib/stap_run2.exp
new file mode 100644
index 00000000..a182a2c5
--- /dev/null
+++ b/testsuite/lib/stap_run2.exp
@@ -0,0 +1,51 @@
+# stap_run2.exp
+#
+# Simple script for testing multiple lines of exact output.
+
+
+# stap_run2 TEST_NAME
+# TEST_NAME is path to the current test
+# Additional arguments are passed to stap as-is.
+#
+# global result_string must be set to the expected output
+
+set timeout 20
+
+proc stap_run2 { TEST_NAME args } {
+ if {![installtest_p]} { untested $TEST_NAME; return }
+
+ # fix up expected string
+ regsub -all \n $::result_string \r\n output
+
+ # spawn test
+ set cmd [concat {stap -v} $args]
+ if [file readable $TEST_NAME] {
+ lappend cmd $TEST_NAME
+ }
+ eval spawn $cmd
+
+ expect {
+ -re {^Pass\ ([1234]):[^\r]*\ in\ ([0-9]+)usr/([0-9]+)sys/([0-9]+)real\ ms.\r\n}
+ {set pass$expect_out(1,string) "\t$expect_out(2,string)\t$expect_out(3,string)\t$expect_out(4,string)"; exp_continue}
+ -re {^Pass 5: starting run.\r\n} {exp_continue}
+ -ex $output {
+ pass "$TEST_NAME passed"
+ expect {
+ -re {^Pass\ ([5]):[^\r]*\ in\ ([0-9]+)usr/([0-9]+)sys/([0-9]+)real\ ms.\r\n}
+ {set pass$expect_out(1,string) "\t$expect_out(2,string)\t$expect_out(3,string)\t$expect_out(4,string)"
+ verbose -log "metric:\t$TEST_NAME $pass1$pass2$pass3$pass4$pass5"}
+ }
+ }
+ timeout {
+ fail "$TEST_NAME timed out" }
+ eof {
+ fail "$TEST_NAME unexpected EOF" }
+ -re "semantic error:" { fail "$TEST_NAME compilation" }
+ -re "ERROR:" {
+ send "\003"
+ fail "$TEST_NAME runtime error"
+ }
+ }
+ catch close
+ wait
+}
diff --git a/testsuite/lib/stap_run_binary.exp b/testsuite/lib/stap_run_binary.exp
new file mode 100644
index 00000000..6d5de4b8
--- /dev/null
+++ b/testsuite/lib/stap_run_binary.exp
@@ -0,0 +1,23 @@
+# stap_run_binary.exp
+#
+# Simple script for testing binary output
+# stap_run_binary TEST_NAME
+# TEST_NAME is path to the current test
+# global result_string must be set to the expected output
+
+proc stap_run_binary { TEST_NAME} {
+ if {![installtest_p]} { untested $TEST_NAME; return }
+
+ set hex_args {-ve 8/1 "%02x " "\n"}
+ set res [exec stap $TEST_NAME | hexdump $hex_args]
+
+ if {[string compare $res $::result_string] == 0} {
+ pass "$TEST_NAME passed"
+ } else {
+ fail "$TEST_NAME failed"
+ puts "EXPECTED:\n-----------------------\n<$::result_string>"
+ puts "-----------------------\n"
+ puts "GOT:\n-----------------------\n<$res>"
+ puts "-----------------------\n"
+ }
+}
diff --git a/testsuite/lib/systemtap.exp b/testsuite/lib/systemtap.exp
new file mode 100644
index 00000000..6bb578b4
--- /dev/null
+++ b/testsuite/lib/systemtap.exp
@@ -0,0 +1,61 @@
+load_lib site.exp
+
+proc installtest_p {} {
+ global TOOL_OPTIONS
+ if {[info exists TOOL_OPTIONS] && ($TOOL_OPTIONS == "install")} {
+ return 1
+ } else { return 0 }
+}
+
+proc print_systemtap_version {} {
+ set version [exec /bin/uname -r]
+ set location "/boot/vmlinux-$version"
+ if {! [file exists $location]} {
+ # try the debuginfo location
+ set location "/usr/lib/debug/lib/modules/$version/vmlinux"
+ if {! [file exists $location]} { set location "" }
+ }
+
+ print "kernel location: $location"
+ print "kernel version: $version"
+
+ set location [exec /usr/bin/which stap]
+ regexp {version [^)]*} [exec stap -V 2>@ stdout] version
+
+ print "systemtap location: $location"
+ print "systemtap version: $version"
+}
+
+
+proc setup_systemtap_environment {} {
+ global srcdir prefix env
+
+ # need an absolute SRCDIR for the top-level src/ tree
+ if {[string index $srcdir 0] != "/"} then {
+ set env(SRCDIR) [exec pwd]/$srcdir/..
+ } else {
+ set env(SRCDIR) $srcdir/..
+ }
+
+ if [installtest_p] {
+ set env(LD_LIBRARY_PATH) $prefix/lib/systemtap
+ set env(SYSTEMTAP_TAPSET) $prefix/share/systemtap/tapset
+ set env(SYSTEMTAP_RUNTIME) $prefix/share/systemtap/runtime
+ set env(PATH) $prefix/bin:$env(PATH)
+ } else {
+ set env(LD_LIBRARY_PATH) ../lib-elfutils:../lib-elfutils/systemtap
+ set env(SYSTEMTAP_TAPSET) $env(SRCDIR)/tapset
+ set env(SYSTEMTAP_RUNTIME) $env(SRCDIR)/runtime
+ set env(PATH) ..:$env(PATH)
+ }
+}
+
+
+setup_systemtap_environment
+print_systemtap_version
+
+
+proc systemtap_init {args} {}
+proc systemtap_version {} {}
+proc systemtap_exit {} {}
+