Fix bug in regression tests that ignored stderr output in RUN lines. Updated tests...
[oota-llvm.git] / test / lib / llvm.exp
index 4fc9c4aa5e1e0c26b25607456e9eaaa6a3f5669e..05c910771ad16ba5b3849178d9ed9d76294c1a93 100644 (file)
@@ -39,14 +39,13 @@ proc execOneLine { test PRS outcome lineno line } {
   return $resultmsg
 }
 
-# This prcoedure performs variable substitutions on the RUN: lines of a test
+# This procedure performs variable substitutions on the RUN: lines of a test
 # cases.
 proc substitute { line test tmpFile } {
   global srcroot objroot srcdir objdir subdir target_triplet prcontext 
-  global llvmgcc llvmgxx llvmgcc_version llvmgccmajvers 
+  global llvmgcc llvmgxx llvmgcc_version llvmgccmajvers ocamlc
   global gccpath gxxpath compile_c compile_cxx link shlibext llvmlibsdir
   set path [file join $srcdir $subdir]
-  set tmp  [file join Output $tmpFile]
 
   # Substitute all Tcl variables.
   set new_line [subst $line ]
@@ -65,6 +64,8 @@ proc substitute { line test tmpFile } {
   regsub -all {%link} $new_line "$link" new_line
   #replace %shlibext with shared library extension
   regsub -all {%shlibext} $new_line "$shlibext" new_line
+  #replace %ocamlc with ocaml compiler command
+  regsub -all {%ocamlc} $new_line "$ocamlc" new_line
   #replace %llvmlibsdir with configure library directory
   regsub -all {%llvmlibsdir} $new_line "$llvmlibsdir" new_line
   #replace %p with path to source, 
@@ -72,7 +73,7 @@ proc substitute { line test tmpFile } {
   #replace %s with filename
   regsub -all {%s} $new_line $test new_line
   #replace %t with temp filenames
-  regsub -all {%t} $new_line [file join Output $tmpFile] new_line
+  regsub -all {%t} $new_line $tmpFile new_line
   #replace %% with %
   regsub -all {%%} $new_line % new_line
   return $new_line
@@ -94,6 +95,7 @@ proc RunLLVMTests { test_source_files } {
   }
   
   file mkdir Output
+  cd Output
 
   foreach test $test_source_files {
     #Should figure out best way to set the timeout
@@ -102,7 +104,10 @@ proc RunLLVMTests { test_source_files } {
     set filename [file tail $test]
     set outcome PASS
     set tmpFile "$filename.tmp"
-
+    
+    # Mark that it should not be XFAIL for this target.
+    set targetPASS 0
+    
     #set hasRunline bool to check if testcase has a runline
     set numLines 0
 
@@ -121,8 +126,8 @@ proc RunLLVMTests { test_source_files } {
         set runline "$runline$oneline "
 
       # if its a terminating RUN: line then do substitution on the whole line
-      # and then save the line.
-      } elseif {[regexp {RUN: *([^&]+)(&&)?} $line match oneline suffix]} {
+      # and then save the line. 
+      } elseif {[regexp {RUN: *(.+)$} $line match oneline suffix]} {
         set runline "$runline$oneline"
         set runline [ substitute $runline $test $tmpFile ]
         set lines($numLines) $runline
@@ -143,12 +148,36 @@ proc RunLLVMTests { test_source_files } {
         #split up target if more then 1 specified
         foreach target [split $targets ,] {
           if { [regexp {\*} $target match] } {
-              set outcome XFAIL
+              if {$targetPASS != 1} {
+                 set outcome XFAIL
+              }
+          } elseif { [regexp $target $target_triplet match] } {
+              if {$targetPASS != 1} {
+                 set outcome XFAIL
+              }
+          } elseif { [regexp {llvmgcc(([0-9]+)|([0-9]+[.][0-9]+))} $target match submatch submatch2]  } {
+            if { [regexp ^($submatch)$|^(($submatch)(\.)) $llvmgcc_version match] } {
+              if {$targetPASS != 1} {
+                 set outcome XFAIL
+              }
+            }
+          }
+        }
+      } elseif {[regexp {XTARGET:[ *](.+)} $line match targets]} {
+        set targets
+
+        #split up target if more then 1 specified
+        foreach target [split $targets ,] {
+          if { [regexp {\*} $target match] } {
+              set targetPASS 1
+              set outcome PASS
           } elseif { [regexp $target $target_triplet match] } {
-              set outcome XFAIL
+              set targetPASS 1
+              set outcome PASS
           } elseif { [regexp {llvmgcc(([0-9]+)|([0-9]+[.][0-9]+))} $target match submatch submatch2]  } {
             if { [regexp ^($submatch)$|^(($submatch)(\.)) $llvmgcc_version match] } {
-              set outcome XFAIL
+              set targetPASS 1
+              set outcome PASS
             }
           }
         }