1 proc llvm-runtest { programs } {
2 global srcroot objroot srcdir objdir subdir target_triplet prcontext
3 global llvmgcc llvmgxx global llvmgcc_version llvmgccmajvers
4 global gccpath gxxpath compile_c compile_cxx link shlibext llvmlibsdir
8 set path [file join $objdir $subdir]
10 #Make Output Directory if it does not exist already
11 if { [file exists path] } {
20 foreach test $programs {
22 #Should figure out best way to set the timeout
25 set filename [file tail $test]
26 set output [file join Output $filename.out]
27 set script $output.script
29 set tmpFile testscript.
30 append tmpFile $filename .tmp
32 #set hasRunline bool to check if testcase has a runline
35 #check if script files exists, and delete if it does
36 if { [file exists $script] } {
40 #create script file and write run line out to it
41 set scriptFileId [open $script w 0700]
42 set testFileId [ open $test r]
43 foreach line [split [read $testFileId] \n] {
45 #see if this is our run line
46 if {[regexp {RUN:(.+)} $line match runline]} {
50 set new_runline $runline
51 #replace %prcontext with prcontext.tcl (Must replace before %p)
52 regsub -all {%prcontext} $new_runline $prcontext new_runline
53 #replace %llvmgcc with actual path to llvmgcc
54 regsub -all {%llvmgcc} $new_runline "$llvmgcc -emit-llvm" new_runline
55 #replace %llvmgxx with actual path to llvmg++
56 regsub -all {%llvmgxx} $new_runline "$llvmgxx -emit-llvm" new_runline
57 #replace %compile_c with C compilation command
58 regsub -all {%compile_c} $new_runline "$compile_c" new_runline
59 #replace %compile_cxx with C++ compilation command
60 regsub -all {%compile_cxx} $new_runline "$compile_cxx" new_runline
61 #replace %link with C++ link command
62 regsub -all {%link} $new_runline "$link" new_runline
63 #replace %shlibext with shared library extension
64 regsub -all {%shlibext} $new_runline "$shlibext" new_runline
65 #replace %llvmlibsdir with configure library directory
66 regsub -all {%llvmlibsdir} $new_runline "$llvmlibsdir" new_runline
67 #replace %p with path to source,
68 regsub -all {%p} $new_runline [file join $srcdir $subdir] new_runline
69 #replace %s with filename
70 regsub -all {%s} $new_runline $test new_runline
71 #replace %t with temp filenames
72 regsub -all {%t} $new_runline [file join Output $tmpFile] new_runline
73 puts $scriptFileId $new_runline
74 } elseif {[regexp {XFAIL:[ *](.+)} $line match targets]} {
77 #split up target if more then 1 specified
78 foreach target [split $targets ,] {
79 if { [regexp {\*} $target match] } {
81 } elseif { [regexp $target $target_triplet match] } {
83 } elseif { [regexp {llvmgcc(([0-9]+)|([0-9]+[.][0-9]+))} $target match submatch submatch2] } {
84 if { [regexp ^($submatch)$|^(($submatch)(\.)) $llvmgcc_version match] } {
98 if { $hasRunline == 0 } {
99 fail "$test: \nDoes not have a RUN line\n"
102 #run script and catch errors
103 set retval [ catch {exec /bin/sh $script >& $output} errmsg ]
105 if { $retval == 1 } {
107 set outputFile [open $output {RDONLY}]
108 set result [read $outputFile]
110 file delete $outputFile
115 fail "$test: \n$errmsg\n$result"
118 xfail "$test: \n$errmsg\n$result"
122 fail "$test: $result"