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
6 if { [file exists path] } {
15 foreach test $programs {
18 set filename [file tail $test]
19 set output [file join Output $filename.out]
20 set script $output.script
22 set tmpFile testscript.
23 append tmpFile $filename .tmp
25 #set hasRunline bool to check if testcase has a runline
28 #check if script files exists, and delete if it does
29 if { [file exists $script] } {
33 #create script file and write run line out to it
34 set scriptFileId [open $script w 0700]
35 set testFileId [ open $test r]
36 foreach line [split [read $testFileId] \n] {
38 #see if this is our run line
39 if {[regexp {RUN:(.+)} $line match runline]} {
43 #replace %s with filename
44 regsub -all {%s} $runline $test new_runline
46 #replace %t with temp filenames
47 regsub -all {%t} $new_runline [file join Output $tmpFile] new_runline
49 #replace %llvmgcc with actual path to llvmgcc
50 regsub -all {%llvmgcc} $new_runline $llvmgcc new_runline
52 #replace %llvmgxx with actual path to llvmg++
53 regsub -all {%llvmgxx} $new_runline $llvmgxx new_runline
55 #replace %prcontext with actual path to llvmg++ (Goes away when we remove qmtest)
56 regsub -all {%prcontext} $new_runline "python $prcontext" new_runline
58 puts $scriptFileId $new_runline
59 } elseif {[regexp {XFAIL:[ *](.+)} $line match targets]} {
63 #split up target if more then 1 specified
64 foreach target [split $targets ,] {
65 if { [regexp {\*} $target match] } {
67 } elseif { [regexp $target $target_triplet match] } {
80 if { $hasRunline == 0 } {
81 fail "$test: \nDoes not have a RUN line\n"
84 #run script and catch errors
85 set retval [ catch {exec /bin/sh $script >& $output} ]
89 set outputFile [open $output {RDONLY}]
90 set result [read $outputFile]
92 file delete $outputFile
97 fail "$test: \n$result"
100 xfail "$test: \n$result"
104 fail "$test: $result"