summaryrefslogtreecommitdiffstats
path: root/testsuite/systemtap.syscall/test.tcl
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/systemtap.syscall/test.tcl
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/systemtap.syscall/test.tcl')
-rwxr-xr-xtestsuite/systemtap.syscall/test.tcl122
1 files changed, 122 insertions, 0 deletions
diff --git a/testsuite/systemtap.syscall/test.tcl b/testsuite/systemtap.syscall/test.tcl
new file mode 100755
index 00000000..a73e22c9
--- /dev/null
+++ b/testsuite/systemtap.syscall/test.tcl
@@ -0,0 +1,122 @@
+#!/usr/bin/env expect
+
+set dir ""
+set current_dir ""
+
+proc cleanup {} {
+ global dir current_dir
+ if {$current_dir != ""} {
+ cd $current_dir
+ if {$dir != ""} {exec rm -rf $dir}
+ set current_dir ""
+ }
+ exit 0
+}
+
+proc usage {progname} {
+ puts "Usage: $progname testname [modulename]"
+}
+
+proc bgerror {error} {
+ puts "ERROR: $error"
+ cleanup
+}
+trap {cleanup} SIGINT
+set testname [lindex $argv 0]
+set modname [lindex $argv 1]
+
+if {$testname == ""} {
+ usage $argv0
+ exit
+}
+set filename "${testname}.c"
+
+if {$modname == ""} {
+ set cmd "stap -c ../${testname} ../sys.stp"
+} else {
+ set stpd ""
+ set stpd_list "/usr/local/libexec/systemtap/stpd /usr/libexec/systemtap/stpd"
+ foreach path $stpd_list {
+ if {[file exists $path]} {
+ set stpd $path
+ break
+ }
+ }
+ if {$stpd == ""} {
+ puts "stpd not found!"
+ exit
+ }
+ set user $::tcl_platform(user)
+ set cmd "sudo $stpd -rmq -u $user -c ../${testname} ${modname}"
+}
+
+# Extract the expected results
+# Use the preprocessor so we can ifdef tests in and out
+
+set ccmd "gcc -E -C -P $filename"
+catch {eval exec $ccmd} output
+
+set ind 0
+foreach line [split $output "\n"] {
+ if {[regsub {//} $line {} line]} {
+ set line "$testname: [string trimleft $line]"
+
+ regsub -all {\(} $line {\\(} line
+ regsub -all {\)} $line {\\)} line
+ regsub -all {\|} $line {\|} line
+
+ regsub -all NNNN $line {[\-0-9]+} line
+ regsub -all XXXX $line {[x0-9a-fA-F]+} line
+
+ set results($ind) $line
+ incr ind
+ }
+}
+
+if {$ind == 0} {
+ puts "UNSUPP"
+ cleanup
+ exit
+}
+
+if {[catch {exec mktemp -d staptestXXXXX} dir]} {
+ puts "Failed to create temporary directory: $dir"
+ cleanup
+}
+set current_dir [pwd]
+cd $dir
+
+catch {eval exec $cmd} output
+
+set i 0
+foreach line [split $output "\n"] {
+ if {[regexp $results($i) $line]} {
+ incr i
+ if {$i >= $ind} {break}
+ }
+}
+if {$i >= $ind} {
+ puts "PASS"
+} else {
+ puts "$testname FAILED"
+ puts "RESULTS: (\'*\' = MATCHED EXPECTED)"
+ set i 0
+ foreach line [split $output "\n"] {
+ if {[regexp "${testname}: " $line]} {
+ if {[regexp $results($i) $line]} {
+ puts "*$line"
+ incr i
+ if {$i >= $ind} {break}
+ } else {
+ puts "$line"
+ }
+ }
+ }
+ if {$i < $ind} {
+ puts "--------- EXPECTED and NOT MATCHED ----------"
+ }
+ for {} {$i < $ind} {incr i} {
+ puts "$results($i)"
+ }
+}
+cleanup