Remove two convenience constructors because they're now private, and the
[oota-llvm.git] / test / lib / llvm.exp
index e7245064532bf6491e53b448ed46c36f6e669a24..1afc00a21bed084db24aa36fdf1544e7ae22417c 100644 (file)
@@ -31,22 +31,25 @@ proc execOneLine { test PRS outcome lineno line } {
         set resultmsg "$test$PRS\nFailed with posix($posixNum,$posixMsg)$errmsg"
       }
       NONE {
+        # Any other error such as stderr output of a program, or syntax error in
+        # the RUN line.
+        set resultmsg "$test$PRS\nFailed with unknown error (or has stderr output)$errmsg" 
       }
       default {
+        set resultmsg "$test$PRS\nFailed with unknown error$errmsg" 
       }
     }
   } 
   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 ]
@@ -54,17 +57,19 @@ proc substitute { line test tmpFile } {
   #replace %prcontext with prcontext.tcl (Must replace before %p)
   regsub -all {%prcontext} $new_line $prcontext new_line
   #replace %llvmgcc with actual path to llvmgcc
-  regsub -all {%llvmgcc} $new_line "$llvmgcc -emit-llvm" new_line
+  regsub -all {%llvmgcc} $new_line "$llvmgcc -emit-llvm -w" new_line
   #replace %llvmgxx with actual path to llvmg++
-  regsub -all {%llvmgxx} $new_line "$llvmgxx -emit-llvm" new_line
-  #replace %compile_c with C compilation command
-  regsub -all {%compile_c} $new_line "$compile_c" new_line
+  regsub -all {%llvmgxx} $new_line "$llvmgxx -emit-llvm -w" new_line
   #replace %compile_cxx with C++ compilation command
   regsub -all {%compile_cxx} $new_line "$compile_cxx" new_line
+  #replace %compile_c with C compilation command
+  regsub -all {%compile_c} $new_line "$compile_c" new_line
   #replace %link with C++ link command
   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 +77,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,15 +99,20 @@ proc RunLLVMTests { test_source_files } {
   }
   
   file mkdir Output
+  cd Output
 
   foreach test $test_source_files {
     #Should figure out best way to set the timeout
     #set timeout 40
     
     set filename [file tail $test]
+    verbose "ABOUT TO RUN: $filename" 2
     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
 
@@ -113,7 +123,7 @@ proc RunLLVMTests { test_source_files } {
     foreach line [split [read $testFileId] \n] {
 
       # if its the END. line then stop parsing (optimization for big files)
-      if {[regexp {END.[ *]$} $line match endofscript]} {
+      if {[regexp {END.[[:space:]]*$} $line match endofscript]} {        
         break
 
       # if the line is continued, concatenate and continue the loop
@@ -121,8 +131,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 +153,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] } {
-              set outcome XFAIL
+              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] } {
-              set outcome XFAIL
+              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 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 targetPASS 1
+              set outcome PASS
             }
           }
         }
@@ -207,13 +241,15 @@ proc llvm_gcc_supports { lang } {
     fortran { set file fcc1 }
     default { return 0 }
   }
-  if { [ string first "$lang" "$llvmgcc_langs" ] >= 0 } {
-    # FIXME: Knowing it is configured is not enough. We should do two more
-    # checks here. First, we need to run llvm-gcc -print-prog-name=$file to get
-    # the path to the compiler. If we don't get a path, the language isn't
-    # properly configured or built. If we do get a path, we should check to make
-    # sure that it is executable and perhaps even try executing it.
-    return 1;
+  foreach supported_lang [split "$llvmgcc_langs" ,] {
+    if { "$lang" == "$supported_lang" } {
+      # FIXME: Knowing it is configured is not enough. We should do two more
+      # checks here. First, we need to run llvm-gcc -print-prog-name=$file to 
+      # get the path to the compiler. If we don't get a path, the language isn't
+      # properly configured or built. If we do get a path, we should check to 
+      # make sure that it is executable and perhaps even try executing it.
+      return 1;
+    }
   }
   return 0;
 }