mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-04-13 15:37:24 +00:00
Provide an infrastructure for testing the llvm2cpp program (yet to be
committed). This infrastructure is only activated when RUNLLVM2CPP=1 is specified on the make command line. Currently it is only supported in the Feature test suite. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28525 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
2f21e07915
commit
15d4059430
3
test/Feature/llvm2cpp.exp
Normal file
3
test/Feature/llvm2cpp.exp
Normal file
@ -0,0 +1,3 @@
|
||||
load_lib llvm2cpp.exp
|
||||
|
||||
llvm2cpp-test [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,llx}]]
|
@ -27,6 +27,10 @@ CLEANED_TESTSUITE := $(patsubst %/,%,$(TESTSUITE))
|
||||
RUNTESTFLAGS := --tool $(CLEANED_TESTSUITE)
|
||||
endif
|
||||
|
||||
ifndef RUNLLVM2CPP
|
||||
RUNTESTFLAGS += --ignore llvm2cpp.exp
|
||||
endif
|
||||
|
||||
check-local:: site.exp
|
||||
PATH="$(LLVMToolDir):$(LLVMExmplDir):$(LLVM_SRC_ROOT)/test/Scripts:$(PATH)" \
|
||||
$(RUNTEST) $(RUNTESTFLAGS)
|
||||
@ -43,6 +47,10 @@ site.exp: Makefile $(LLVM_OBJ_ROOT)/Makefile.config
|
||||
@echo 'set target_triplet "$(TARGET_TRIPLE)"' >> site.tmp
|
||||
@echo 'set llvmgcc_version "$(LLVMGCC_VERSION)"' >> site.tmp
|
||||
@echo 'set prcontext "$(TCLSH) $(LLVM_SRC_ROOT)/test/Scripts/prcontext.tcl"' >> site.tmp
|
||||
@echo 'set tooldir "$(ToolDir)"' >>site.tmp
|
||||
@echo 'set libdir "$(LibDir)"' >>site.tmp
|
||||
@echo 'set srcroot "$(LLVM_SRC_ROOT)"' >>site.tmp
|
||||
@echo 'set objroot "$(LLVM_OBJ_ROOT)"' >>site.tmp
|
||||
@echo 'set srcdir "$(LLVM_SRC_ROOT)/test"' >>site.tmp
|
||||
@echo 'set objdir "$(LLVM_OBJ_ROOT)/test"' >>site.tmp
|
||||
@echo 'set llvmgcc "PATH=\"$(LLVMToolDir):$(PATH)\" \"$(LLVMGCC)\""' >> site.tmp
|
||||
|
79
test/lib/llvm2cpp.exp
Normal file
79
test/lib/llvm2cpp.exp
Normal file
@ -0,0 +1,79 @@
|
||||
# This file defines a tcl proc to assist with testing the llvm2cpp. There are
|
||||
# no llvm2cpp specific test cases. Instead, it utilizes all the existing test
|
||||
# cases and makes sure llvm2cpp can run them. The basic idea is that we find
|
||||
# all the LLVM Assembly (*.ll) files, run llvm2cpp on them to generate a C++
|
||||
# program, compile those programs, run them and see if what they produce matches
|
||||
# the original input to llvm2cpp.
|
||||
|
||||
proc llvm2cpp-test { files } {
|
||||
# if { $env(LLVM_RUNLLVM2CPP_TEST) == 1 } {
|
||||
global subdir tooldir libdir objdir srcdir objroot srcroot
|
||||
set timeout 30
|
||||
set path [file join $objdir $subdir]
|
||||
set llvm2cpp [file join $tooldir llvm2cpp ]
|
||||
set llvmas [file join $tooldir llvm-as ]
|
||||
set llvmdis [file join $tooldir llvm-dis ]
|
||||
|
||||
#Make Output Directory if it does not exist already
|
||||
if { [file exists path] } {
|
||||
cd $path
|
||||
} else {
|
||||
file mkdir $path
|
||||
cd $path
|
||||
}
|
||||
|
||||
file mkdir Output
|
||||
|
||||
foreach test $files {
|
||||
|
||||
set filename [file tail $test]
|
||||
set generated [file join Output $filename.cpp]
|
||||
set executable [file join Output $filename.exe]
|
||||
set output [file join Output $filename.gen]
|
||||
set assembly [file join Output $filename.asm]
|
||||
|
||||
set retval [ catch {
|
||||
exec -keepnewline $llvmas $test -o - | $llvmdis -f -o $assembly } msg ]
|
||||
|
||||
if { $retval != 0 } {
|
||||
fail "$test: llvm-as/llvm-dis returned $retval\n$msg"
|
||||
continue
|
||||
}
|
||||
|
||||
set retval [ catch {
|
||||
exec -keepnewline $llvm2cpp -f -o $generated $test } msg]
|
||||
|
||||
if { $retval != 0 } {
|
||||
fail "$test: llvm2cpp returned $retval\n$msg"
|
||||
continue
|
||||
}
|
||||
|
||||
set retval [ catch {
|
||||
exec -keepnewline gcc -g -D__STDC_LIMIT_MACROS -o $executable $generated -I$srcroot/include -I$objroot/include -L$libdir $libdir/LLVMCore.o -lLLVMSupport $libdir/LLVMbzip2.o -lLLVMSystem -lstdc++ } msg ]
|
||||
|
||||
if { $retval != 0 } {
|
||||
fail "$test: gcc returned $retval\n$msg"
|
||||
continue
|
||||
}
|
||||
|
||||
set retval [ catch {
|
||||
exec -keepnewline $executable > $output } msg ]
|
||||
|
||||
if { $retval != 0 } {
|
||||
fail "$test: $filename returned $retval\n$msg"
|
||||
continue
|
||||
}
|
||||
|
||||
set retval [ catch {
|
||||
exec -keepnewline diff -u $assembly $generated } msg ]
|
||||
|
||||
if { $retval != 0 } {
|
||||
fail "$test: diff returned $retval\n$msg"
|
||||
continue
|
||||
}
|
||||
pass "$test"
|
||||
}
|
||||
# }
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user