]> sourceware.org Git - systemtap.git/commitdiff
2007-09-19 Martin Hunt <hunt@redhat.com>
authorhunt <hunt>
Wed, 19 Sep 2007 16:35:02 +0000 (16:35 +0000)
committerhunt <hunt>
Wed, 19 Sep 2007 16:35:02 +0000 (16:35 +0000)
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.

testsuite/systemtap.syscall/ChangeLog
testsuite/systemtap.syscall/README
testsuite/systemtap.syscall/syscall.exp
testsuite/systemtap.syscall/test-debug.tcl
testsuite/systemtap.syscall/test.tcl

index 3be84fdf02c524c30e4421b45736479a3cfd74b7..c9d8077b0426eee24bfe138a78d64f5932fb6203 100644 (file)
@@ -1,3 +1,13 @@
+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.
+       
 2007-09-17  Martin Hunt  <hunt@redhat.com>
 
        * timer.c (main): Remove the return value checks.
index 41e6d895771479c213c0cc7bb6a4da746290a8f7..480bd8cddf4804c0bfdef318375b723e3df9e260 100644 (file)
@@ -1,32 +1,11 @@
 How these tests work:
 
 Dejagnu finds all *.c files, compiles them and runs them in a temporary 
-directory  while running the systemtap script sys.stp.  To avoid 
-recompiling sys.stp over and over, the test.exp is smart enough to 
-compile sys.stp once and save the module.
+directory  while running the systemtap script sys.stp.  
 
-
-You can run all the tests here with
-> runtest test.exp
-
-You can run single tests with
+If you need to know why a test is failing you can look in the test log, or
 > gcc -o testname testname.c
->./test.tcl testname
-
-OR, if you want to run multiple tests and don't want all the delays
-with recompiling sys.stp each time,
-
-> stap -kp4 sys.stp
-Keeping temporary directory "/tmp/stapPThTaQ"
-> ./test.tcl testname /tmp/stapPThTaQ/*.ko
-> ./test.tcl testname2 /tmp/stapPThTaQ/*.ko
-...
-> rm -rf /tmp/stapPThTaQ
-
-Finally, if you need to know why a test is failing, use
-"test-debug.tcl" exactly as above. After running the test, it will open a
-window with the results and expected results.
-
+> test-debug.tcl testname 
 
 
 HOW TO WRITE TESTS
index e9ea9537b742804b670397a3c365bb824e48a7d4..2313403f5205dd673e83fa61b58bf4bc713a1ced 100644 (file)
@@ -1,3 +1,5 @@
+source $srcdir/$subdir/test.tcl
+
 proc test_procedure {} {
     global srcdir subdir
     set wd [pwd]
@@ -29,20 +31,18 @@ proc test_procedure {} {
 
     if {$do_64_bit_pass} {
        foreach filename [lsort [glob $pattern]] {
-           set file [file tail [string range $filename 0 end-2]]
-           if {![installtest_p]} { untested $file; continue }
-           target_compile $filename $wd/$file executable $flags
-           send_log "Testing 64-bit ${file}\n"
-           set res [exec $srcdir/$subdir/test.tcl $file $filename]
+           set testname [file tail [string range $filename 0 end-2]]
+           if {![installtest_p]} { untested $testname; continue }
+           send_log "Testing 64-bit ${testname}\n"
+           set res [run_one_test $filename $flags]
            if {$res == "PASS"} {
-               pass "$file"
+               pass "$testname"
            } elseif {$res == "UNSUPP"} {
-               unsupported "$file not supported on this arch"
+               unsupported "$testname not supported on this arch"
            } else {
-               fail "64-bit $file"
+               fail "64-bit $testname"
                send_log "$res\n"
            }
-           catch {exec rm -f $wd/$file}
        }
     }
 
@@ -61,20 +61,18 @@ proc test_procedure {} {
 
     if {$do_32_bit_pass} {
        foreach filename [lsort [glob $pattern]] {
-           set file [file tail [string range $filename 0 end-2]]
-           if {![installtest_p]} { untested $file; continue }
-           target_compile $filename $wd/$file executable $flags
-           send_log "Testing 32-bit ${file}\n"
-           set res [exec $srcdir/$subdir/test.tcl $file $filename]
+           set testname [file tail [string range $filename 0 end-2]]
+           if {![installtest_p]} { untested $testname; continue }
+           send_log "Testing 32-bit ${testname}\n"
+           set res [run_one_test $filename $flags]
            if {$res == "PASS"} {
-               pass "32-bit $file"
+               pass "32-bit $testname"
            } elseif {$res == "UNSUPP"} {
-               unsupported "$file not supported on this arch"
+               unsupported "$testname not supported on this arch"
            } else {
-               fail "32-bit $file"
+               fail "32-bit $testname"
                send_log "$res\n"
            }
-           catch {exec rm -f $wd/$file}
        }
     }
 }
index 3497e41bcc36425a0f264453a09ae5fa5c078d4b..13e0ad54dc113308dc3973e8597076330803cb05 100755 (executable)
@@ -6,7 +6,6 @@ set current_dir ""
 
 proc cleanup {} {
     global dir current_dir
-    puts "Cleanup"
     if {$current_dir != ""} {
         cd $current_dir
        if {$dir != ""} {exec rm -rf $dir}
index 8c228cba44b67e4147e6b76af9b09377eaa0a066..24a9642f72aafc5bd968759c9f79566fcc2bc2bd 100755 (executable)
-#!/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
This page took 0.039014 seconds and 5 git commands to generate.