| #===-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-ret-zero-test { pat forceret0 } { |
| global srcdir subdir objdir tmpdir objrootdir llc llvm_ld gxx APR_lib |
| set outdir [file join $objdir $subdir] |
| 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 files [lsort [ |
| glob -nocomplain -tails -types {f r} -directory $source $pat]] |
| set dirs [lsort [ |
| glob -nocomplain -tails -types {d r} -directory $source *]] |
| |
| if { [file isdirectory $outdir] } { |
| cd $outdir |
| } else { |
| if { [file exists $outdir] } { |
| fail "identity: $outdir exists and is not a directory. Remove it" |
| exit(2) |
| } else { |
| file mkdir $outdir |
| } |
| } |
| |
| foreach test $files { |
| set output [file join $outdir ${test}.out] |
| set testname [file rootname $test] |
| set testsrc [file join $source $test] |
| 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 $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} { |
| if { ! $forceret0 } { |
| pass "$test" |
| } else { |
| fail "$test: $testexe returned $retval:\n$msg" |
| } |
| } else { |
| pass "$test" |
| } |
| } |
| } |
| } |
| } |
| } |
| } |