1 proc execOneLine { test PRS outcome lineno line } {
4 set retval [ catch { eval exec -keepnewline -- $line } errmsg ]
6 set code [lindex $::errorCode 0]
7 set lineno [expr $lineno + 1]
11 set errmsg " at line $lineno$PRS\nwhile running: $line\n$errmsg"
14 set status [lindex $::errorCode 2]
16 set resultmsg "$test: exit($status)$errmsg"
20 set signal [lindex $::errorCode 2]
21 set resultmsg "$test: signal($signal)$errmsg"
24 set signal [lindex $::errorCode 2]
25 set resultmsg "$test: suspend($signal)$errmsg"
28 set posixNum [lindex $::errorCode 1]
29 set posixMsg [lindex $::errorCode 2]
30 set resultmsg "$test: posix($posixNum,$posixMsg)$errmsg"
41 proc substitute { line test tmpFile } {
42 global srcroot objroot srcdir objdir subdir target_triplet prcontext
43 global llvmgcc llvmgxx llvmgcc_version llvmgccmajvers
44 global gccpath gxxpath compile_c compile_cxx link shlibext llvmlibsdir
45 set path [file join $srcdir $subdir]
46 set tmp [file join Output $tmpFile]
49 #replace %prcontext with prcontext.tcl (Must replace before %p)
50 regsub -all {%prcontext} $new_line $prcontext new_line
51 #replace %llvmgcc with actual path to llvmgcc
52 regsub -all {%llvmgcc} $new_line "$llvmgcc -emit-llvm" new_line
53 #replace %llvmgxx with actual path to llvmg++
54 regsub -all {%llvmgxx} $new_line "$llvmgxx -emit-llvm" new_line
55 #replace %compile_c with C compilation command
56 regsub -all {%compile_c} $new_line "$compile_c" new_line
57 #replace %compile_cxx with C++ compilation command
58 regsub -all {%compile_cxx} $new_line "$compile_cxx" new_line
59 #replace %link with C++ link command
60 regsub -all {%link} $new_line "$link" new_line
61 #replace %shlibext with shared library extension
62 regsub -all {%shlibext} $new_line "$shlibext" new_line
63 #replace %llvmlibsdir with configure library directory
64 regsub -all {%llvmlibsdir} $new_line "$llvmlibsdir" new_line
65 #replace %p with path to source,
66 regsub -all {%p} $new_line [file join $srcdir $subdir] new_line
67 #replace %s with filename
68 regsub -all {%s} $new_line $test new_line
69 #replace %t with temp filenames
70 regsub -all {%t} $new_line [file join Output $tmpFile] new_line
72 regsub -all {%%} $new_line % new_line
76 proc RunLLVMTests { test_source_files } {
77 global srcroot objroot srcdir objdir subdir target_triplet
80 set path [file join $objdir $subdir]
82 #Make Output Directory if it does not exist already
83 if { [file exists path] } {
92 foreach test $test_source_files {
93 #Should figure out best way to set the timeout
96 set filename [file tail $test]
98 set tmpFile "$filename.tmp"
100 #set hasRunline bool to check if testcase has a runline
103 # Open the test file and start reading lines
104 set testFileId [ open $test r]
107 foreach line [split [read $testFileId] \n] {
109 # if its the END. line then stop parsing (optimization for big files)
110 if {[regexp {END.[ *]$} $line match endofscript]} {
113 # if the line is continued, concatente and continue the loop
114 } elseif {[regexp {RUN: *([^\\]+)(\\)$} $line match oneline suffix]} {
115 set runline "$runline$oneline "
117 # if its a terminating RUN: line then do substitution on the whole line
118 # and then save the line.
119 } elseif {[regexp {RUN: *([^&]+)(&&)?} $line match oneline suffix]} {
120 set runline "$runline$oneline"
121 set runline [ substitute $runline $test $tmpFile ]
122 set lines($numLines) $runline
123 set numLines [expr $numLines + 1]
126 # if its an PR line, save the problem report number
127 } elseif {[regexp {PR([0-9]+)} $line match prnum]} {
131 set PRNUMS "$PRNUMS,$prnum"
133 # if its an XFAIL line, see if we should be XFAILing or not.
134 } elseif {[regexp {XFAIL:[ *](.+)} $line match targets]} {
137 #split up target if more then 1 specified
138 foreach target [split $targets ,] {
139 if { [regexp {\*} $target match] } {
141 } elseif { [regexp $target $target_triplet match] } {
143 } elseif { [regexp {llvmgcc(([0-9]+)|([0-9]+[.][0-9]+))} $target match submatch submatch2] } {
144 if { [regexp ^($submatch)$|^(($submatch)(\.)) $llvmgcc_version match] } {
152 # Done reading the script
156 if { $numLines == 0 } {
157 fail "$test: \nDoes not have a RUN line\n"
160 for { set i 0 } { $i < $numLines } { set i [ expr $i + 1 ] } {
161 regsub ^.*RUN:(.*) $lines($i) \1 theLine
162 set theLine [subst $theLine ]
163 set resultmsg [execOneLine $test $PRNUMS $outcome $i $theLine ]
164 if { $resultmsg != "" } {
165 if { $outcome == "XFAIL" } {
176 set PRNUMS " for $PRNUMS"
178 if { $outcome == "XFAIL" } {