llvm.org GIT mirror llvm / 15d4059
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 Reid Spencer 14 years ago
3 changed file(s) with 90 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 load_lib llvm2cpp.exp
1
2 llvm2cpp-test [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,llx}]]
2626 RUNTESTFLAGS := --tool $(CLEANED_TESTSUITE)
2727 endif
2828
29 ifndef RUNLLVM2CPP
30 RUNTESTFLAGS += --ignore llvm2cpp.exp
31 endif
32
2933 check-local:: site.exp
3034 PATH="$(LLVMToolDir):$(LLVMExmplDir):$(LLVM_SRC_ROOT)/test/Scripts:$(PATH)" \
3135 $(RUNTEST) $(RUNTESTFLAGS)
4246 @echo 'set target_triplet "$(TARGET_TRIPLE)"' >> site.tmp
4347 @echo 'set llvmgcc_version "$(LLVMGCC_VERSION)"' >> site.tmp
4448 @echo 'set prcontext "$(TCLSH) $(LLVM_SRC_ROOT)/test/Scripts/prcontext.tcl"' >> site.tmp
49 @echo 'set tooldir "$(ToolDir)"' >>site.tmp
50 @echo 'set libdir "$(LibDir)"' >>site.tmp
51 @echo 'set srcroot "$(LLVM_SRC_ROOT)"' >>site.tmp
52 @echo 'set objroot "$(LLVM_OBJ_ROOT)"' >>site.tmp
4553 @echo 'set srcdir "$(LLVM_SRC_ROOT)/test"' >>site.tmp
4654 @echo 'set objdir "$(LLVM_OBJ_ROOT)/test"' >>site.tmp
4755 @echo 'set llvmgcc "PATH=\"$(LLVMToolDir):$(PATH)\" \"$(LLVMGCC)\""' >> site.tmp
0 # This file defines a tcl proc to assist with testing the llvm2cpp. There are
1 # no llvm2cpp specific test cases. Instead, it utilizes all the existing test
2 # cases and makes sure llvm2cpp can run them. The basic idea is that we find
3 # all the LLVM Assembly (*.ll) files, run llvm2cpp on them to generate a C++
4 # program, compile those programs, run them and see if what they produce matches
5 # the original input to llvm2cpp.
6
7 proc llvm2cpp-test { files } {
8 # if { $env(LLVM_RUNLLVM2CPP_TEST) == 1 } {
9 global subdir tooldir libdir objdir srcdir objroot srcroot
10 set timeout 30
11 set path [file join $objdir $subdir]
12 set llvm2cpp [file join $tooldir llvm2cpp ]
13 set llvmas [file join $tooldir llvm-as ]
14 set llvmdis [file join $tooldir llvm-dis ]
15
16 #Make Output Directory if it does not exist already
17 if { [file exists path] } {
18 cd $path
19 } else {
20 file mkdir $path
21 cd $path
22 }
23
24 file mkdir Output
25
26 foreach test $files {
27
28 set filename [file tail $test]
29 set generated [file join Output $filename.cpp]
30 set executable [file join Output $filename.exe]
31 set output [file join Output $filename.gen]
32 set assembly [file join Output $filename.asm]
33
34 set retval [ catch {
35 exec -keepnewline $llvmas $test -o - | $llvmdis -f -o $assembly } msg ]
36
37 if { $retval != 0 } {
38 fail "$test: llvm-as/llvm-dis returned $retval\n$msg"
39 continue
40 }
41
42 set retval [ catch {
43 exec -keepnewline $llvm2cpp -f -o $generated $test } msg]
44
45 if { $retval != 0 } {
46 fail "$test: llvm2cpp returned $retval\n$msg"
47 continue
48 }
49
50 set retval [ catch {
51 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 ]
52
53 if { $retval != 0 } {
54 fail "$test: gcc returned $retval\n$msg"
55 continue
56 }
57
58 set retval [ catch {
59 exec -keepnewline $executable > $output } msg ]
60
61 if { $retval != 0 } {
62 fail "$test: $filename returned $retval\n$msg"
63 continue
64 }
65
66 set retval [ catch {
67 exec -keepnewline diff -u $assembly $generated } msg ]
68
69 if { $retval != 0 } {
70 fail "$test: diff returned $retval\n$msg"
71 continue
72 }
73 pass "$test"
74 }
75 # }
76 }
77
78