summaryrefslogtreecommitdiffstats
path: root/testsuite/systemtap.syscall/test.tcl
diff options
context:
space:
mode:
authorhunt <hunt>2007-09-19 16:35:02 +0000
committerhunt <hunt>2007-09-19 16:35:02 +0000
commit770794f1d24a6bfb4eacabcc8f272e4bb44890ab (patch)
tree240149c6b47db0ad626502e4abd73e51b26f3cd9 /testsuite/systemtap.syscall/test.tcl
parentd5aae3f021d1a5d52e17788025053496757b7a89 (diff)
downloadsystemtap-steved-770794f1d24a6bfb4eacabcc8f272e4bb44890ab.tar.gz
systemtap-steved-770794f1d24a6bfb4eacabcc8f272e4bb44890ab.tar.xz
systemtap-steved-770794f1d24a6bfb4eacabcc8f272e4bb44890ab.zip
2007-09-19 Martin Hunt <hunt@redhat.com>
PR 4931 * test-debug.tcl (cleanup): Remove print. * README: Update. * syscall.exp: Source test.tcl and call run_one_test() from there. * test.tcl: Rewrite as a function. Do compilation as well as testing. Compile into and execute in a directory in /tmp.
Diffstat (limited to 'testsuite/systemtap.syscall/test.tcl')
-rwxr-xr-xtestsuite/systemtap.syscall/test.tcl180
1 files changed, 92 insertions, 88 deletions
diff --git a/testsuite/systemtap.syscall/test.tcl b/testsuite/systemtap.syscall/test.tcl
index 8c228cba..24a9642f 100755
--- a/testsuite/systemtap.syscall/test.tcl
+++ b/testsuite/systemtap.syscall/test.tcl
@@ -1,113 +1,117 @@
-#!/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
+ global dir current_dir
+ if {$current_dir != ""} {
+ cd $current_dir
+ set current_dir ""
+ }
+ if {$dir != ""} {
+# puts "rm -rf $dir"
+ exec rm -rf $dir
+ set dir ""
+ }
}
-proc usage {progname} {
- puts "Usage: $progname testname"
+proc cleanup_and_exit {} {
+# puts "cleanup_and_exit"
cleanup
+ exit 0
}
proc bgerror {error} {
puts "ERROR: $error"
cleanup
}
-trap {cleanup} SIGINT
-set testname [lindex $argv 0]
-if {$testname == ""} {
- usage $argv0
- exit
-}
-
-set filename [lindex $argv 1]
-if {$filename == ""} {
- set filename "${testname}.c"
- set sys_prog "../sys.stp"
-} else {
- set sys_prog "[file dirname [file normalize $filename]]/sys.stp"
-}
-set cmd "stap -c ../${testname} ${sys_prog}"
-
-# Extract the expected results
-# Use the preprocessor so we can ifdef tests in and out
+trap {cleanup_and_exit} SIGINT
-set ccmd "gcc -E -C -P $filename"
-catch {eval exec $ccmd} output
+proc run_one_test {filename flags} {
+ global dir current_dir
-set ind 0
-foreach line [split $output "\n"] {
- if {[regsub {//} $line {} line]} {
- set line "$testname: [string trimleft $line]"
+ set testname [file tail [string range $filename 0 end-2]]
+ set result "UNSUPP $testname"
- 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 stderr "Failed to create temporary directory: $dir"
- cleanup
-}
+ if {[catch {exec mktemp -td staptestXXXXX} dir]} {
+ puts stderr "Failed to create temporary directory: $dir"
+ cleanup
+ }
-set current_dir [pwd]
-cd $dir
-catch {eval exec $cmd} output
+ target_compile $filename $dir/$testname executable $flags
+
+ set sys_prog "[file dirname [file normalize $filename]]/sys.stp"
+ set cmd "stap -c $dir/${testname} ${sys_prog}"
+
+ # 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
+ }
+ }
-set i 0
-foreach line [split $output "\n"] {
- if {[regexp $results($i) $line]} {
- incr i
- if {$i >= $ind} {break}
+ if {$ind == 0} {
+ puts "UNSUPP"
+ cleanup
+ return
}
-}
-if {$i >= $ind} {
- puts "PASS"
-} else {
- puts "$testname FAILED. output of \"$cmd\" was:"
- puts "------------------------------------------"
- puts $output
- puts "------------------------------------------"
- puts "RESULTS: (\'*\' = MATCHED EXPECTED)"
+
+ set current_dir [pwd]
+ cd $dir
+
+ catch {eval exec $cmd} output
+
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 {[regexp $results($i) $line]} {
+ incr i
+ if {$i >= $ind} {break}
}
}
- if {$i < $ind} {
- puts "--------- EXPECTED and NOT MATCHED ----------"
- }
- for {} {$i < $ind} {incr i} {
- puts "$results($i)"
+ if {$i >= $ind} {
+ set result "PASS"
+ puts "PASS $testname"
+ } else {
+ set result "FAIL $testname"
+ puts "$testname FAILED. output of \"$cmd\" was:"
+ puts "------------------------------------------"
+ puts $output
+ puts "------------------------------------------"
+ 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
+ return $result
}
-cleanup