1 proc execOneLine { test outcome lineno line } {
4 set retval [ catch { eval exec -keepnewline -- $line } errmsg ]
6 set code [lindex $::errorCode 0]
9 set status [lindex $::errorCode 2]
11 set resultmsg "$test: exit($status)\nwhile running: $line\n$errmsg"
15 set signal [lindex $::errorCode 2]
16 set resultmsg "$test: signal($signal)\nwhile running: $line\n$errmsg"
19 set signal [lindex $::errorCode 2]
20 set resultmsg "$test: suspend($signal)\nwhile running: $line\n$errmsg"
23 set posixNum [lindex $::errorCode 1]
24 set posixMsg [lindex $::errorCode 2]
25 set resultmsg "$test: posix($posixNum)\n$posixMsg\nwhile running: $line\n$errmsg"
36 proc substitute { line test tmpFile } {
37 global srcroot objroot srcdir objdir subdir target_triplet prcontext
38 global llvmgcc llvmgxx global llvmgcc_version llvmgccmajvers
39 global gccpath gxxpath compile_c compile_cxx link shlibext llvmlibsdir
42 #replace %prcontext with prcontext.tcl (Must replace before %p)
43 regsub -all {%prcontext} $new_line $prcontext new_line
44 #replace %llvmgcc with actual path to llvmgcc
45 regsub -all {%llvmgcc} $new_line "$llvmgcc -emit-llvm" new_line
46 #replace %llvmgxx with actual path to llvmg++
47 regsub -all {%llvmgxx} $new_line "$llvmgxx -emit-llvm" new_line
48 #replace %compile_c with C compilation command
49 regsub -all {%compile_c} $new_line "$compile_c" new_line
50 #replace %compile_cxx with C++ compilation command
51 regsub -all {%compile_cxx} $new_line "$compile_cxx" new_line
52 #replace %link with C++ link command
53 regsub -all {%link} $new_line "$link" new_line
54 #replace %shlibext with shared library extension
55 regsub -all {%shlibext} $new_line "$shlibext" new_line
56 #replace %llvmlibsdir with configure library directory
57 regsub -all {%llvmlibsdir} $new_line "$llvmlibsdir" new_line
58 #replace %p with path to source,
59 regsub -all {%p} $new_line [file join $srcdir $subdir] new_line
60 #replace %s with filename
61 regsub -all {%s} $new_line $test new_line
62 #replace %t with temp filenames
63 regsub -all {%t} $new_line [file join Output $tmpFile] new_line
67 proc llvm-runtest { programs } {
68 global srcroot objroot srcdir objdir subdir target_triplet
71 set path [file join $objdir $subdir]
73 #Make Output Directory if it does not exist already
74 if { [file exists path] } {
83 foreach test $programs {
84 #Should figure out best way to set the timeout
87 set filename [file tail $test]
89 set tmpFile "$filename.tmp"
91 #set hasRunline bool to check if testcase has a runline
94 # Open the test file and start reading lines
95 set testFileId [ open $test r]
97 foreach line [split [read $testFileId] \n] {
99 #see if this is our run line
100 if {[regexp {END.[ *]$} $line match endofscript]} {
102 } elseif {[regexp {RUN: *([^\\]+)(\\)} $line match oneline suffix]} {
103 set runline "$runline$oneline "
104 } elseif {[regexp {RUN: *([^&]+)(&&)?} $line match oneline suffix]} {
105 set runline "$runline$oneline"
106 set runline [ substitute $runline $test $tmpFile ]
107 set lines($numLines) $runline
108 set numLines [expr $numLines + 1]
110 } elseif {[regexp {XFAIL:[ *](.+)} $line match targets]} {
113 #split up target if more then 1 specified
114 foreach target [split $targets ,] {
115 if { [regexp {\*} $target match] } {
117 } elseif { [regexp $target $target_triplet match] } {
119 } elseif { [regexp {llvmgcc(([0-9]+)|([0-9]+[.][0-9]+))} $target match submatch submatch2] } {
120 if { [regexp ^($submatch)$|^(($submatch)(\.)) $llvmgcc_version match] } {
128 # Done reading the script
132 if { $numLines == 0 } {
133 fail "$test: \nDoes not have a RUN line\n"
136 for { set i 0 } { $i < $numLines } { set i [ expr $i + 1 ] } {
137 regsub ^.*RUN:(.*) $lines($i) \1 theLine
138 set theLine [subst $theLine ]
139 set resultmsg [execOneLine $test $outcome $i $theLine ]
140 if { $resultmsg != "" } {
141 if { $outcome == "XFAIL" } {
151 if { $outcome == "XFAIL" } {