1 proc llvm-runtest { programs srcdir subdir target_triplet} {
3 set path [file join $srcdir $subdir]
5 #Make Output Directory if it does not exist already
10 foreach test $programs {
13 set filename [file tail $test]
14 set output [file join Output $filename.out]
15 set script $output.script
17 set tmpFile testscript.
18 append tmpFile $filename .tmp
20 #set hasRunline bool to check if testcase has a runline
23 #check if script files exists, and delete if it does
24 if { [file exists $script] } {
28 #create script file and write run line out to it
29 set scriptFileId [open $script w 0700]
30 set testFileId [ open $test r]
31 foreach line [split [read $testFileId] \n] {
33 #see if this is our run line
34 if {[regexp {RUN:(.+)} $line match runline]} {
38 #replace %s with filename
39 regsub -all {%s} $runline $filename new_runline
41 regsub -all {%t} $new_runline [file join Output $tmpFile] new_runline
43 puts $scriptFileId $new_runline
44 } elseif {[regexp {XFAIL:[ *](.+)} $line match targets]} {
48 #split up target if more then 1 specified
49 foreach target [split $targets ,] {
50 if { [regexp {\*} $target match] } {
52 } elseif { [regexp $target $target_triplet match] } {
65 if { $hasRunline == 0 } {
66 fail "$test: \nDoes not have a RUN line\n"
69 #run script and catch errors
70 set retval [ catch {exec /bin/sh $script >& $output} ]
74 set outputFile [open $output {RDONLY}]
75 set result [read $outputFile]
77 file delete $outputFile
82 fail "$test: \n$result"
85 xfail "$test: \n$result"