In an XFAIL line, treat "XFAIL: foo*bar" as a regular expression to be matched
[oota-llvm.git] / test / lib / llvm2cpp.exp
index 9450fe92a7bcd3a9ff79254c4d2be379ebaaffb1..d8a65ffc4bece2efc48fa2eb05eabec31fd5d536 100644 (file)
@@ -9,7 +9,7 @@ proc llvm2cpp-test { files } {
   global subdir llvmtoolsdir llvmlibsdir objdir srcdir objroot srcroot 
   set timeout 30
   set path [file join $objdir $subdir]
-  set llvm2cpp [file join $llvmtoolsdir llvm2cpp ]
+  set llc [file join $llvmtoolsdir llc ]
   set llvmas [file join $llvmtoolsdir llvm-as ]
   set llvmdis [file join $llvmtoolsdir llvm-dis ]
 
@@ -33,20 +33,39 @@ proc llvm2cpp-test { files } {
     set testname [file rootname $filename]
     set bytecode [file join Output $filename.bc]
 
-    # Note that the stderr for llvm-as must be redirected to /dev/null because
-    # otherwise exec will see the msgs and return 1 even though they are only 
-    # warnings. If real errors are generated on stderr then llvm-as will return
-    # a non-zero retval anyway so we're good.
+    # Note that the stderr for llvm-as, etc. must be redirected to /dev/null 
+    # because otherwise exec will see the msgs and return 1 even though they 
+    # are only warnings. If real errors are generated on stderr then llvm-as 
+    # will return a non-zero retval anyway so we're good.
+
+    # Scan the test file to see if there's an XFAIL file. If so, don't run it
+    set retval [ catch { 
+      exec -keepnewline grep XFAIL $test 2>/dev/null } msg ]
+    if { $retval == 0 } {
+      continue;
+    }
+
+    # Run llvm-as/llvm-dis
+    set pipeline llvm-as|llvm-dis
+    set retval [ catch { 
+      exec -keepnewline $llvmas < $test -o - | $llvmdis -f -o $assembly 2>/dev/null } msg ]
+
+    if { $retval != 0 } {
+      fail "$test: $pipeline returned $retval\n$msg"
+      continue 
+    }
+
+    # Build bytecode for llvm2cpp input
     set retval [ catch { 
-      exec -keepnewline $llvmas $test -o - | $llvmdis -f -o $assembly 2>/dev/null } msg ]
+      exec -keepnewline $llvmas < $assembly > $bytecode 2>/dev/null } msg ]
 
     if { $retval != 0 } {
-      fail "$test: llvm-as/llvm-dis returned $retval\n$msg"
+      fail "$test: llvm-as returned $retval\n$msg"
       continue 
     }
 
     set retval [ catch { 
-      exec -keepnewline $llvm2cpp -f -o $generated < $test 2>/dev/null } msg]
+      exec -keepnewline $llc -march=cpp -f -o $generated < $bytecode 2>/dev/null } msg]
 
     if { $retval != 0 } {
       fail "$test: llvm2cpp returned $retval\n$msg"
@@ -54,7 +73,7 @@ proc llvm2cpp-test { files } {
     }
 
     set retval [ catch { 
-      exec -keepnewline gcc -g -D__STDC_LIMIT_MACROS -o $executable $generated -I$srcroot/include -I$objroot/include -L$llvmlibsdir $llvmlibsdir/LLVMCore.o -lLLVMSupport $llvmlibsdir/LLVMbzip2.o -lLLVMSystem -lstdc++ } msg ] 
+      exec -keepnewline gcc -g -D__STDC_LIMIT_MACROS -o $executable $generated -I$srcroot/include -I$objroot/include -L$llvmlibsdir -lLLVMCore -lLLVMSupport -lLLVMbzip2 -lLLVMSystem -lstdc++ } msg ] 
     if { $retval != 0 } {
       fail "$test: gcc returned $retval\n$msg"
       continue