2007-04-11 19:56:59 +00:00
|
|
|
proc llvm-runtest { programs } {
|
2007-04-11 20:57:39 +00:00
|
|
|
global srcroot objroot srcdir objdir subdir target_triplet prcontext
|
|
|
|
global llvmgcc llvmgxx global llvmgcc_version llvmgccmajvers
|
2007-04-12 02:49:30 +00:00
|
|
|
global gccpath gxxpath compile_c compile_cxx link shlibext llvmlibsdir
|
2004-11-06 21:07:41 +00:00
|
|
|
|
2004-11-30 06:29:45 +00:00
|
|
|
set timeout 60
|
|
|
|
|
2004-11-07 22:04:21 +00:00
|
|
|
set path [file join $objdir $subdir]
|
2004-11-06 21:07:41 +00:00
|
|
|
|
|
|
|
#Make Output Directory if it does not exist already
|
2004-11-07 23:21:50 +00:00
|
|
|
if { [file exists path] } {
|
|
|
|
cd $path
|
|
|
|
} else {
|
|
|
|
file mkdir $path
|
|
|
|
cd $path
|
|
|
|
}
|
2004-11-06 21:07:41 +00:00
|
|
|
|
|
|
|
file mkdir Output
|
|
|
|
|
|
|
|
foreach test $programs {
|
|
|
|
|
2004-11-19 22:46:23 +00:00
|
|
|
#Should figure out best way to set the timeout
|
|
|
|
#set timeout 40
|
|
|
|
|
2004-11-06 21:07:41 +00:00
|
|
|
set filename [file tail $test]
|
|
|
|
set output [file join Output $filename.out]
|
|
|
|
set script $output.script
|
|
|
|
set outcome PASS
|
|
|
|
set tmpFile testscript.
|
|
|
|
append tmpFile $filename .tmp
|
|
|
|
|
|
|
|
#set hasRunline bool to check if testcase has a runline
|
|
|
|
set hasRunline 0
|
|
|
|
|
|
|
|
#check if script files exists, and delete if it does
|
|
|
|
if { [file exists $script] } {
|
|
|
|
file delete $script
|
|
|
|
}
|
|
|
|
|
|
|
|
#create script file and write run line out to it
|
|
|
|
set scriptFileId [open $script w 0700]
|
|
|
|
set testFileId [ open $test r]
|
|
|
|
foreach line [split [read $testFileId] \n] {
|
|
|
|
|
|
|
|
#see if this is our run line
|
|
|
|
if {[regexp {RUN:(.+)} $line match runline]} {
|
|
|
|
set runline
|
|
|
|
set hasRunline 1
|
|
|
|
|
2007-04-11 20:57:39 +00:00
|
|
|
set new_runline $runline
|
2004-11-19 22:46:23 +00:00
|
|
|
#replace %prcontext with prcontext.tcl (Must replace before %p)
|
|
|
|
regsub -all {%prcontext} $new_runline $prcontext new_runline
|
2004-11-07 05:02:56 +00:00
|
|
|
#replace %llvmgcc with actual path to llvmgcc
|
2006-03-08 22:32:20 +00:00
|
|
|
regsub -all {%llvmgcc} $new_runline "$llvmgcc -emit-llvm" new_runline
|
2004-11-07 05:02:56 +00:00
|
|
|
#replace %llvmgxx with actual path to llvmg++
|
2006-03-08 22:32:20 +00:00
|
|
|
regsub -all {%llvmgxx} $new_runline "$llvmgxx -emit-llvm" new_runline
|
2007-04-11 20:57:39 +00:00
|
|
|
#replace %compile_c with C compilation command
|
|
|
|
regsub -all {%compile_c} $new_runline "$compile_c" new_runline
|
|
|
|
#replace %compile_cxx with C++ compilation command
|
|
|
|
regsub -all {%compile_cxx} $new_runline "$compile_cxx" new_runline
|
|
|
|
#replace %link with C++ link command
|
|
|
|
regsub -all {%link} $new_runline "$link" new_runline
|
2007-04-12 02:49:30 +00:00
|
|
|
#replace %shlibext with shared library extension
|
|
|
|
regsub -all {%shlibext} $new_runline "$shlibext" new_runline
|
|
|
|
#replace %llvmlibsdir with configure library directory
|
|
|
|
regsub -all {%llvmlibsdir} $new_runline "$llvmlibsdir" new_runline
|
2007-04-11 20:57:39 +00:00
|
|
|
#replace %p with path to source,
|
|
|
|
regsub -all {%p} $new_runline [file join $srcdir $subdir] new_runline
|
|
|
|
#replace %s with filename
|
|
|
|
regsub -all {%s} $new_runline $test new_runline
|
|
|
|
#replace %t with temp filenames
|
|
|
|
regsub -all {%t} $new_runline [file join Output $tmpFile] new_runline
|
2004-11-06 21:07:41 +00:00
|
|
|
puts $scriptFileId $new_runline
|
|
|
|
} elseif {[regexp {XFAIL:[ *](.+)} $line match targets]} {
|
|
|
|
set targets
|
|
|
|
|
|
|
|
#split up target if more then 1 specified
|
|
|
|
foreach target [split $targets ,] {
|
|
|
|
if { [regexp {\*} $target match] } {
|
|
|
|
set outcome XFAIL
|
|
|
|
} elseif { [regexp $target $target_triplet match] } {
|
|
|
|
set outcome XFAIL
|
2006-04-12 21:57:40 +00:00
|
|
|
} elseif { [regexp {llvmgcc(([0-9]+)|([0-9]+[.][0-9]+))} $target match submatch submatch2] } {
|
|
|
|
if { [regexp ^($submatch)$|^(($submatch)(\.)) $llvmgcc_version match] } {
|
|
|
|
set outcome XFAIL
|
|
|
|
}
|
2004-11-06 21:07:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
close $testFileId
|
|
|
|
close $scriptFileId
|
|
|
|
|
|
|
|
|
|
|
|
if { $hasRunline == 0 } {
|
|
|
|
fail "$test: \nDoes not have a RUN line\n"
|
|
|
|
} else {
|
|
|
|
|
|
|
|
#run script and catch errors
|
2006-05-18 19:42:16 +00:00
|
|
|
set retval [ catch {exec /bin/sh $script >& $output} errmsg ]
|
2004-11-06 21:07:41 +00:00
|
|
|
|
|
|
|
if { $retval == 1 } {
|
|
|
|
#Get output
|
|
|
|
set outputFile [open $output {RDONLY}]
|
|
|
|
set result [read $outputFile]
|
|
|
|
close $outputFile
|
|
|
|
file delete $outputFile
|
|
|
|
|
|
|
|
switch $outcome {
|
|
|
|
PASS {
|
|
|
|
file delete $output
|
2006-05-18 19:42:16 +00:00
|
|
|
fail "$test: \n$errmsg\n$result"
|
2004-11-06 21:07:41 +00:00
|
|
|
}
|
|
|
|
XFAIL {
|
2006-05-18 19:42:16 +00:00
|
|
|
xfail "$test: \n$errmsg\n$result"
|
2004-11-06 21:07:41 +00:00
|
|
|
}
|
|
|
|
default {
|
|
|
|
file delete $output
|
|
|
|
fail "$test: $result"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
switch $outcome {
|
|
|
|
XFAIL {
|
|
|
|
xpass "$test"
|
|
|
|
}
|
|
|
|
default {
|
|
|
|
pass "$test"}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-11-07 22:04:21 +00:00
|
|
|
}
|