1 proc llvm-runtest { programs objdir srcdir 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 {
17 #Should figure out best way to set the timeout
20 set filename [file tail $test]
21 set output [file join Output $filename.out]
22 set script $output.script
24 set tmpFile testscript.
25 append tmpFile $filename .tmp
27 #set hasRunline bool to check if testcase has a runline
30 #check if script files exists, and delete if it does
31 if { [file exists $script] } {
35 #create script file and write run line out to it
36 set scriptFileId [open $script w 0700]
37 set testFileId [ open $test r]
38 foreach line [split [read $testFileId] \n] {
40 #see if this is our run line
41 if {[regexp {RUN:(.+)} $line match runline]} {
45 #replace %s with filename
46 regsub -all {%s} $runline $test new_runline
48 #replace %t with temp filenames
49 regsub -all {%t} $new_runline [file join Output $tmpFile] new_runline
51 #replace %prcontext with prcontext.tcl (Must replace before %p)
52 regsub -all {%prcontext} $new_runline $prcontext new_runline
54 #replace %p with path to source,
55 regsub -all {%p} $new_runline [file join $srcdir $subdir] new_runline
57 #replace %llvmgcc with actual path to llvmgcc
58 regsub -all {%llvmgcc} $new_runline $llvmgcc new_runline
60 #replace %llvmgxx with actual path to llvmg++
61 regsub -all {%llvmgxx} $new_runline $llvmgxx new_runline
63 puts $scriptFileId $new_runline
64 } elseif {[regexp {XFAIL:[ *](.+)} $line match targets]} {
68 #split up target if more then 1 specified
69 foreach target [split $targets ,] {
70 if { [regexp {\*} $target match] } {
72 } elseif { [regexp $target $target_triplet match] } {
85 if { $hasRunline == 0 } {
86 fail "$test: \nDoes not have a RUN line\n"
89 #run script and catch errors
90 set retval [ catch {exec /bin/sh $script >& $output} ]
94 set outputFile [open $output {RDONLY}]
95 set result [read $outputFile]
97 file delete $outputFile
102 fail "$test: \n$result"
105 xfail "$test: \n$result"
109 fail "$test: $result"