Test if the compiler supports Ada, and enable Ada tests if so. While I was
[oota-llvm.git] / test / lib / llvm.exp
index 1655547cde52c99859d33a8c78e0c1450d81e826..e4a52a0c1cbfd01ebb7c1d55d9843447c6dc7af2 100644 (file)
@@ -8,26 +8,26 @@ proc execOneLine { test PRS outcome lineno line } {
     if { $PRS != ""} {
       set PRS " for $PRS" 
     }
-    set errmsg " at line $lineno$PRS\nwhile running: $line\n$errmsg"
+    set errmsg " at line $lineno\nwhile running: $line\n$errmsg"
     switch "$code" {
       CHILDSTATUS {
         set status [lindex $::errorCode 2]
-        if { $status ne 0 } {
-          set resultmsg "$test: exit($status)$errmsg"
+        if { $status != 0 } {
+          set resultmsg "$test$PRS\nFailed with exit($status)$errmsg"
         }
       }
       CHILDKILLED {
         set signal [lindex $::errorCode 2]
-        set resultmsg "$test: signal($signal)$errmsg"
+        set resultmsg "$test$PRS\nFailed with signal($signal)$errmsg"
       }
       CHILDSUSP {
         set signal [lindex $::errorCode 2]
-        set resultmsg "$test: suspend($signal)$errmsg"
+        set resultmsg "$test$PRS\nFailed with suspend($signal)$errmsg"
       }
       POSIX {
         set posixNum [lindex $::errorCode 1]
         set posixMsg [lindex $::errorCode 2]
-        set resultmsg "$test: posix($posixNum,$posixMsg)$errmsg"
+        set resultmsg "$test$PRS\nFailed with posix($posixNum,$posixMsg)$errmsg"
       }
       NONE {
       }
@@ -76,7 +76,7 @@ proc substitute { line test tmpFile } {
 }
 
 proc RunLLVMTests { test_source_files } {
-  global srcroot objroot srcdir objdir subdir target_triplet
+  global srcroot objroot srcdir objdir subdir target_triplet llvmgcc_version
   set timeout 60
 
   set path [file join $objdir $subdir]
@@ -106,13 +106,13 @@ proc RunLLVMTests { test_source_files } {
     set testFileId [ open $test r]
     set runline ""
     set PRNUMS ""
-    foreach line [split [read $testFileId 1024] \n] {
+    foreach line [split [read $testFileId] \n] {
 
       # if its the END. line then stop parsing (optimization for big files)
       if {[regexp {END.[ *]$} $line match endofscript]} {
         break
 
-      # if the line is continued, concatente and continue the loop
+      # if the line is continued, concatenate and continue the loop
       } elseif {[regexp {RUN: *(.+)(\\)$} $line match oneline suffix]} {
         set runline "$runline$oneline "
 
@@ -187,3 +187,34 @@ proc RunLLVMTests { test_source_files } {
     }
   }
 }
+
+proc llvm_gcc_supports_objc { } {
+    global llvmgcc 
+    catch { set file_h [ open "/tmp/llvm_obj_check.m" w] }
+    set R [ catch { exec $llvmgcc -c "/tmp/llvm_obj_check.m"  -o /dev/null >& /tmp/llvm_obj_check.out } ]
+    set RESULT [ file size "/tmp/llvm_obj_check.out" ]
+    catch { file delete "/tmp/llvm_obj_check.m" }
+    catch { file delete "/tmp/llvm_obj_check.out" }
+    if { $RESULT == 0 } {
+        return 1
+    } else {
+        return 0
+    }
+}
+
+proc llvm_gcc_supports_ada { } {
+    global llvmgcc 
+    catch { set file_h [ open "/tmp/llvm_ada_check.adb" w] }
+    catch { puts $file_h "procedure llvm_ada_check is begin null; end;" }
+    catch { close $file_h }
+    set R [ catch { exec $llvmgcc -c -gnats "/tmp/llvm_ada_check.adb" >& /tmp/llvm_ada_check.out } ]
+    set RESULT [ file size "/tmp/llvm_ada_check.out" ]
+    catch { file delete "/tmp/llvm_ada_check.adb" }
+    catch { file delete "/tmp/llvm_ada_check.out" }
+    if { $RESULT == 0 } {
+        return 1
+    } else {
+        return 0
+    }
+}
+