2004-11-19 23:46:23 +01:00
|
|
|
proc llvm-runtest { programs objdir srcdir subdir target_triplet llvmgcc llvmgxx prcontext} {
|
2004-11-06 22:07:41 +01:00
|
|
|
|
2004-11-30 07:29:45 +01:00
|
|
|
set timeout 60
|
|
|
|
|
2004-11-07 23:04:21 +01:00
|
|
|
set path [file join $objdir $subdir]
|
2004-11-06 22:07:41 +01:00
|
|
|
|
|
|
|
#Make Output Directory if it does not exist already
|
2004-11-08 00:21:50 +01:00
|
|
|
if { [file exists path] } {
|
|
|
|
cd $path
|
|
|
|
} else {
|
|
|
|
file mkdir $path
|
|
|
|
cd $path
|
|
|
|
}
|
2004-11-06 22:07:41 +01:00
|
|
|
|
|
|
|
file mkdir Output
|
|
|
|
|
|
|
|
foreach test $programs {
|
|
|
|
|
2004-11-19 23:46:23 +01:00
|
|
|
#Should figure out best way to set the timeout
|
|
|
|
#set timeout 40
|
|
|
|
|
2004-11-06 22:07:41 +01: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
|
|
|
|
|
|
|
|
#replace %s with filename
|
2004-11-07 23:04:21 +01:00
|
|
|
regsub -all {%s} $runline $test new_runline
|
2004-11-07 06:02:56 +01:00
|
|
|
|
|
|
|
#replace %t with temp filenames
|
2004-11-06 22:07:41 +01:00
|
|
|
regsub -all {%t} $new_runline [file join Output $tmpFile] new_runline
|
2004-11-07 06:02:56 +01:00
|
|
|
|
2004-11-19 23:46:23 +01:00
|
|
|
#replace %prcontext with prcontext.tcl (Must replace before %p)
|
|
|
|
regsub -all {%prcontext} $new_runline $prcontext new_runline
|
|
|
|
|
|
|
|
#replace %p with path to source,
|
2004-11-20 00:00:19 +01:00
|
|
|
regsub -all {%p} $new_runline [file join $srcdir $subdir] new_runline
|
2004-11-19 23:46:23 +01:00
|
|
|
|
2004-11-07 06:02:56 +01:00
|
|
|
#replace %llvmgcc with actual path to llvmgcc
|
|
|
|
regsub -all {%llvmgcc} $new_runline $llvmgcc new_runline
|
|
|
|
|
|
|
|
#replace %llvmgxx with actual path to llvmg++
|
|
|
|
regsub -all {%llvmgxx} $new_runline $llvmgxx new_runline
|
|
|
|
|
2004-11-06 22:07:41 +01: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
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
close $testFileId
|
|
|
|
close $scriptFileId
|
|
|
|
|
|
|
|
|
|
|
|
if { $hasRunline == 0 } {
|
|
|
|
fail "$test: \nDoes not have a RUN line\n"
|
|
|
|
} else {
|
|
|
|
|
|
|
|
#run script and catch errors
|
|
|
|
set retval [ catch {exec /bin/sh $script >& $output} ]
|
|
|
|
|
|
|
|
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
|
|
|
|
fail "$test: \n$result"
|
|
|
|
}
|
|
|
|
XFAIL {
|
|
|
|
xfail "$test: \n$result"
|
|
|
|
}
|
|
|
|
default {
|
|
|
|
file delete $output
|
|
|
|
fail "$test: $result"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
switch $outcome {
|
|
|
|
XFAIL {
|
|
|
|
xpass "$test"
|
|
|
|
}
|
|
|
|
default {
|
|
|
|
pass "$test"}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-11-07 23:04:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|