* test.exp, test.tcl, test-debug.tcl: PR 3524.
Support for separtet source and obj trees.
+2007-01-09 Martin Hunt <hunt@redhat.com>
+
+ * test.exp, test.tcl, test-debug.tcl: PR 3524.
+ Support for separtet source and obj trees.
+
2006-10-27 Martin Hunt <hunt@redhat.com>
* test.exp, test.tcl: Remove our own caching code
#!/usr/bin/env wish
package require Expect
+set dir ""
+set current_dir ""
+
proc cleanup {} {
global dir current_dir
- puts "cleanup"
+ puts "Cleanup"
if {$current_dir != ""} {
- cd $current_dir
- exec rm -rf $dir
+ cd $current_dir
+ if {$dir != ""} {exec rm -rf $dir}
set current_dir ""
}
exit 0
cleanup
}
trap {cleanup} SIGINT
-if {[catch {exec mktemp -d staptestXXXXX} dir]} {
- puts "Failed to create temporary directory: $dir"
- cleanup
-}
-
-set current_dir ""
set testname [lindex $argv 0]
-set modname [lindex $argv 1]
-
if {$testname == ""} {
usage $argv0
- cleanup
+ exit
}
-set filename "${testname}.c"
-set cmd "stap -c ../${testname} ../sys.stp"
+
+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
}
if {$ind == 0} {
- puts "UNSUPP"
- exit
+ puts "UNSUPP"
+ cleanup
+ exit
+}
+
+if {[catch {exec mktemp -d staptestXXXXX} dir]} {
+ puts stderr "Failed to create temporary directory: $dir"
+ cleanup
}
set current_dir [pwd]
proc test_procedure {} {
- global subdir
- if {$subdir != ""} {
- cd $subdir
- }
-
-
+ global srcdir subdir
+ set wd [pwd]
set flags ""
- foreach filename [lsort [glob *.c]] {
- set file [string range $filename 0 end-2]
- target_compile $filename $file executable $flags
+ if {$srcdir == ""} {
+ set pattern "*.c"
+ } else {
+ set pattern "$srcdir/$subdir/*.c"
+ }
+ foreach filename [lsort [glob $pattern]] {
+ set file [file tail [string range $filename 0 end-2]]
+ target_compile $filename $wd/$file executable $flags
send_log "Testing ${file}\n"
- set res [exec ./test.tcl $file]
+ set res [exec $srcdir/$subdir/test.tcl $file $filename]
if {$res == "PASS"} {
pass "$file"
} elseif {$res == "UNSUPP"} {
if {$::tcl_platform(machine) == "x86_64"} {
# on x86_64, test 32-bit and 64-bit binaries
set flags "additional_flags=-m32"
- foreach filename [lsort [glob *.c]] {
- set file [string range $filename 0 end-2]
- target_compile $filename $file executable $flags
+ foreach filename [lsort [glob $pattern]] {
+ set file [file tail [string range $filename 0 end-2]]
+ target_compile $filename $wd/$file executable $flags
send_log "Testing 32-bit ${file}\n"
- set res [exec ./test.tcl $file]
+ set res [exec $srcdir/$subdir/test.tcl $file $filename]
if {$res == "PASS"} {
pass "32-bit $file"
} elseif {$res == "UNSUPP"} {
send_log "$res\n"
}
}
- }
-
- if {$subdir != ""} {
- cd ..
- }
+ }
}
test_procedure
proc usage {progname} {
puts "Usage: $progname testname"
+ cleanup
}
proc bgerror {error} {
}
trap {cleanup} SIGINT
set testname [lindex $argv 0]
-
if {$testname == ""} {
usage $argv0
exit
}
-set filename "${testname}.c"
-set cmd "stap -c ../${testname} ../sys.stp"
+
+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
}
if {[catch {exec mktemp -d staptestXXXXX} dir]} {
- puts "Failed to create temporary directory: $dir"
+ puts stderr "Failed to create temporary directory: $dir"
cleanup
}
+
set current_dir [pwd]
-cd $dir
-
+cd $dir
catch {eval exec $cmd} output
set i 0