Home | History | Annotate | Download | only in ltrace.minor
      1 # This file was written by Yao Qi <qiyao (at) cn.ibm.com>.
      2 
      3 set testfile "demangle"
      4 set srcfile ${testfile}.cpp
      5 set binfile ${testfile}
      6 set libfile "demangle-lib"
      7 set libsrc $srcdir/$subdir/$libfile.cpp
      8 set lib_sl $objdir/$subdir/lib$testfile.so
      9 
     10 verbose "compiling source file now....."
     11 if [get_compiler_info $binfile "c++"] {
     12   return -1
     13 }
     14 
     15 verbose "compiling source file now....."
     16 if { [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.
     22 ltrace_options "-C"
     23 
     24 # Run PUT for ltrace.
     25 set exec_output [ltrace_runtest $objdir/$subdir $objdir/$subdir/$binfile]
     26 
     27 # Check the output of this program.
     28 verbose "ltrace runtest output: $exec_output\n"
     29 if [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.
     41 set fd [ open $srcdir/$subdir/$srcfile r]
     42 while { [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 }
     47 close $fd
     48 
     49 #read member fucntions of classs from demangle-lib.cpp and verify them in demagle.ltrace.
     50 set fd [ open $srcdir/$subdir/$testfile-lib.cpp r]
     51 while { [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 }
     66 close $fd
     67