1# This file was written by Yao Qi <qiyao@cn.ibm.com>. 2 3set testfile "demangle" 4set srcfile ${testfile}.cpp 5set binfile ${testfile} 6set libfile "demangle-lib" 7set libsrc $srcdir/$subdir/$libfile.cpp 8set lib_sl $objdir/$subdir/lib$testfile.so 9 10verbose "compiling source file now....." 11if [get_compiler_info $binfile "c++"] { 12 return -1 13} 14 15verbose "compiling source file now....." 16if { [ltrace_compile_shlib $libsrc $lib_sl [list debug c++]] != "" 17 || [ltrace_compile $srcdir/$subdir/$srcfile $objdir/$subdir/$binfile executable [list debug shlib=$lib_sl c++] ] != ""} { 18 send_user "Testcase compile failed, so all tests in this file will automatically fail.\n" 19} 20 21# set options for ltrace. 22ltrace_options "-C" 23 24# Run PUT for ltrace. 25set exec_output [ltrace_runtest $objdir/$subdir $objdir/$subdir/$binfile] 26 27# Check the output of this program. 28verbose "ltrace runtest output: $exec_output\n" 29if [regexp {ELF from incompatible architecture} $exec_output] { 30 fail "32-bit ltrace can not perform on 64-bit PUTs and rebuild ltrace in 64 bit mode!" 31 return 32} elseif [ regexp {Couldn't get .hash data} $exec_output ] { 33 fail "Couldn't get .hash data!" 34 return 35} elseif [ regexp {invalid option} $exec_output ] { 36 unsupported "Demangle support not compiled in." 37 return 38} 39 40# read function declarations from demangle.cpp and verify them in demangle.ltrace. 41set fd [ open $srcdir/$subdir/$srcfile r] 42while { [gets $fd line] >= 0 } { 43 if [regexp {extern (double|float|void|char|int|short|long|void \*|void \*\*) ([^ ])\(} $line match type fun] { 44 ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $fun 45 } 46} 47close $fd 48 49#read member fucntions of classs from demangle-lib.cpp and verify them in demagle.ltrace. 50set fd [ open $srcdir/$subdir/$testfile-lib.cpp r] 51while { [gets $fd line] >= 0 } { 52 if [ regexp {((myclass|nested)::[^\(]*)\(} $line match fun] { 53 # For Debug purpose. 54 verbose "fun = $fun" 55 # Extract new/delete for remove extra SPACE in $fun, for example, 56 # $fun = "myclass::operator delete" will confuse ltrace_verify_output if it 57 # was an argument to it. 58 if [regexp {(new|delete)} $fun match sub_fun] { 59 ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $sub_fun 60 } else { 61 # Verify class member functions without SPACE. 62 ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $fun 63 } 64 } 65} 66close $fd 67