#===-test/lib/identity.exp - Script for identity tests ---------------------===# # # High Level Virtual Machine (HLVM) # # Copyright (C) 2006 Reid Spencer. All Rights Reserved. # # This software is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or (at # your option) any later version. # # This software is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library in the file named LICENSE.txt; if not, write to the # Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, # MA 02110-1301 USA # #===------------------------------------------------------------------------===# proc hlvm-generate-test { complexity typecomplexity size seed } { global srcdir subdir objdir tmpdir objrootdir llc llvm_ld gxx APR_lib set outdir [file join $objdir $subdir] set gentc [ file join $objrootdir tools hlvm-gentestcase hlvm-gentestcase ] set compiler [file join $objrootdir tools hlvm-compiler hlvm-compiler ] set source [file join $srcdir $subdir ] set rtlib [file join $objrootdir hlvm Runtime HLVMRuntime.bca ] set baselib [file join $objrootdir hlvm Base HLVMBase.bca ] set vmmain [file join $objrootdir tools hlvm hlvm.bc ] set test "gen-$complexity-$typecomplexity-$size-$seed" set output [file join $outdir ${test}.out] set testname [file rootname $test] set testsrc [file join $source ${test}.hlx ] set testexe [file join $outdir $testname ] set testbc [file join $outdir ${test}.bc ] set testlinked [file join $outdir ${test}.linked ] set testlinkedbc [file join $outdir ${test}.linked.bc ] set tests [file join $outdir ${test}.s ] set retval [ catch { exec $gentc -seed $seed -size $size -complexity $complexity -type-complexity $typecomplexity -bundle "$test" -o $testsrc } msg ] if { $retval != 0 } { fail "$test: hlvm-gentestcase return $retval:\n$msg" } else { set retval [ catch { exec $compiler $testsrc -llvmbc -o $testbc } msg ] if { $retval != 0 } { fail "$test: hlvm-compiler returned $retval:\n$msg" } else { set retval [ catch { exec $llvm_ld -o $testlinked $testbc $vmmain $rtlib } msg ] if { $retval != 0 } { fail "$test: llvm-ld returned $retval:\n$msg" } else { set retval [ catch { exec $llc -fast -f -o $tests $testlinkedbc } msg ] if { $retval != 0 } { fail "$test: llc returned $retval:\n$msg" } else { set retval [ catch { exec $gxx -g -o $testexe $tests -L$APR_lib -lapr-1 -laprutil-1 } msg ] if { $retval != 0 } { fail "$test: gxx returned $retval:\n$msg" } else { set retval [ catch {exec $testexe $testname } msg ] if { $retval != 0 } { set status [lindex $::errorCode 2] if {[lindex $::errorCode 0] eq "CHILDSTATUS"} { pass "$test: $testexe returned $status" } else { fail "$test: $testexe returned $status\n$msg" } } else { pass $test; } } } } } } }