1 proc llvm-runtest { programs objdir srcdir subdir target_triplet llvmgcc llvmgxx prcontext llvmgcc_version} {
6 set path [file join $objdir $subdir]
8 #Make Output Directory if it does not exist already
9 if { [file exists path] } {
18 foreach test $programs {
20 #Should figure out best way to set the timeout
23 set filename [file tail $test]
24 set output [file join Output $filename.out]
25 set script $output.script
27 set tmpFile testscript.
28 append tmpFile $filename .tmp
30 #set hasRunline bool to check if testcase has a runline
33 #check if script files exists, and delete if it does
34 if { [file exists $script] } {
38 #create script file and write run line out to it
39 set scriptFileId [open $script w 0700]
40 set testFileId [ open $test r]
41 foreach line [split [read $testFileId] \n] {
43 #see if this is our run line
44 if {[regexp {RUN:(.+)} $line match runline]} {
48 #replace %s with filename
49 regsub -all {%s} $runline $test new_runline
51 #replace %t with temp filenames
52 regsub -all {%t} $new_runline [file join Output $tmpFile] new_runline
54 #replace %prcontext with prcontext.tcl (Must replace before %p)
55 regsub -all {%prcontext} $new_runline $prcontext new_runline
57 #replace %p with path to source,
58 regsub -all {%p} $new_runline [file join $srcdir $subdir] new_runline
60 #replace %llvmgcc with actual path to llvmgcc
61 regsub -all {%llvmgcc} $new_runline "$llvmgcc -emit-llvm" new_runline
63 #replace %llvmgxx with actual path to llvmg++
64 regsub -all {%llvmgxx} $new_runline "$llvmgxx -emit-llvm" new_runline
66 puts $scriptFileId $new_runline
67 } 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] } {
76 } elseif { [regexp {llvmgcc(([0-9]+)|([0-9]+[.][0-9]+))} $target match submatch submatch2] } {
77 if { [regexp ^($submatch)$|^(($submatch)(\.)) $llvmgcc_version match] } {
91 if { $hasRunline == 0 } {
92 fail "$test: \nDoes not have a RUN line\n"
95 #run script and catch errors
96 set retval [ catch {exec /bin/sh $script >& $output} errmsg ]
100 set outputFile [open $output {RDONLY}]
101 set result [read $outputFile]
103 file delete $outputFile
108 fail "$test: \n$errmsg\n$result"
111 xfail "$test: \n$errmsg\n$result"
115 fail "$test: $result"