1 proc llvm-runtest { programs objdir subdir target_triplet llvmgcc llvmgxx prcontext} {
3 set path [file join $objdir $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 $test new_runline
41 #replace %t with temp filenames
42 regsub -all {%t} $new_runline [file join Output $tmpFile] new_runline
44 #replace %llvmgcc with actual path to llvmgcc
45 regsub -all {%llvmgcc} $new_runline $llvmgcc new_runline
47 #replace %llvmgxx with actual path to llvmg++
48 regsub -all {%llvmgxx} $new_runline $llvmgxx new_runline
50 #replace %prcontext with actual path to llvmg++ (Goes away when we remove qmtest)
51 regsub -all {%prcontext} $new_runline "python $prcontext" new_runline
53 puts $scriptFileId $new_runline
54 } elseif {[regexp {XFAIL:[ *](.+)} $line match targets]} {
58 #split up target if more then 1 specified
59 foreach target [split $targets ,] {
60 if { [regexp {\*} $target match] } {
62 } elseif { [regexp $target $target_triplet match] } {
75 if { $hasRunline == 0 } {
76 fail "$test: \nDoes not have a RUN line\n"
79 #run script and catch errors
80 set retval [ catch {exec /bin/sh $script >& $output} ]
84 set outputFile [open $output {RDONLY}]
85 set result [read $outputFile]
87 file delete $outputFile
92 fail "$test: \n$result"
95 xfail "$test: \n$result"