1 proc llvm-runtest { programs objdir srcdir subdir target_triplet llvmgcc llvmgxx prcontext} {
5 set path [file join $objdir $subdir]
7 #Make Output Directory if it does not exist already
8 if { [file exists path] } {
17 foreach test $programs {
19 #Should figure out best way to set the timeout
22 set filename [file tail $test]
23 set output [file join Output $filename.out]
24 set script $output.script
26 set tmpFile testscript.
27 append tmpFile $filename .tmp
29 #set hasRunline bool to check if testcase has a runline
32 #check if script files exists, and delete if it does
33 if { [file exists $script] } {
37 #create script file and write run line out to it
38 set scriptFileId [open $script w 0700]
39 set testFileId [ open $test r]
40 foreach line [split [read $testFileId] \n] {
42 #see if this is our run line
43 if {[regexp {RUN:(.+)} $line match runline]} {
47 #replace %s with filename
48 regsub -all {%s} $runline $test new_runline
50 #replace %t with temp filenames
51 regsub -all {%t} $new_runline [file join Output $tmpFile] new_runline
53 #replace %prcontext with prcontext.tcl (Must replace before %p)
54 regsub -all {%prcontext} $new_runline $prcontext new_runline
56 #replace %p with path to source,
57 regsub -all {%p} $new_runline [file join $srcdir $subdir] new_runline
59 #replace %llvmgcc with actual path to llvmgcc
60 regsub -all {%llvmgcc} $new_runline $llvmgcc new_runline
62 #replace %llvmgxx with actual path to llvmg++
63 regsub -all {%llvmgxx} $new_runline $llvmgxx new_runline
65 puts $scriptFileId $new_runline
66 } elseif {[regexp {XFAIL:[ *](.+)} $line match targets]} {
70 #split up target if more then 1 specified
71 foreach target [split $targets ,] {
72 if { [regexp {\*} $target match] } {
74 } elseif { [regexp $target $target_triplet match] } {
87 if { $hasRunline == 0 } {
88 fail "$test: \nDoes not have a RUN line\n"
91 #run script and catch errors
92 set retval [ catch {exec /bin/sh $script >& $output} ]
96 set outputFile [open $output {RDONLY}]
97 set result [read $outputFile]
99 file delete $outputFile
104 fail "$test: \n$result"
107 xfail "$test: \n$result"
111 fail "$test: $result"