1 # This file defines a tcl proc to assist with testing the llvm2cpp. There are
2 # no llvm2cpp specific test cases. Instead, it utilizes all the existing test
3 # cases and makes sure llvm2cpp can run them. The basic idea is that we find
4 # all the LLVM Assembly (*.ll) files, run llvm2cpp on them to generate a C++
5 # program, compile those programs, run them and see if what they produce matches
6 # the original input to llvm2cpp.
8 proc llvm2cpp-test { files } {
9 # if { $env(LLVM_RUNLLVM2CPP_TEST) == 1 } {
10 global subdir tooldir libdir objdir srcdir objroot srcroot
12 set path [file join $objdir $subdir]
13 set llvm2cpp [file join $tooldir llvm2cpp ]
14 set llvmas [file join $tooldir llvm-as ]
15 set llvmdis [file join $tooldir llvm-dis ]
17 #Make Output Directory if it does not exist already
18 if { [file exists path] } {
29 set filename [file tail $test]
30 set generated [file join Output $filename.cpp]
31 set executable [file join Output $filename.exe]
32 set output [file join Output $filename.gen]
33 set assembly [file join Output $filename.asm]
36 exec -keepnewline $llvmas $test -o - | $llvmdis -f -o $assembly } msg ]
39 fail "$test: llvm-as/llvm-dis returned $retval\n$msg"
44 exec -keepnewline $llvm2cpp -f -o $generated $test } msg]
47 fail "$test: llvm2cpp returned $retval\n$msg"
52 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 ]
55 fail "$test: gcc returned $retval\n$msg"
60 exec -keepnewline $executable > $output } msg ]
63 fail "$test: $filename returned $retval\n$msg"
68 exec -keepnewline diff -u $assembly $generated } msg ]
71 fail "$test: diff returned $retval\n$msg"