11e8f6fe9680c994b9c86753c3345a4579f726fc4Petr Machata# This file was written by Yao Qi <qiyao@cn.ibm.com>. 21e8f6fe9680c994b9c86753c3345a4579f726fc4Petr Machata 31e8f6fe9680c994b9c86753c3345a4579f726fc4Petr Machataset testfile "main-threaded" 41e8f6fe9680c994b9c86753c3345a4579f726fc4Petr Machataset srcfile ${testfile}.c 51e8f6fe9680c994b9c86753c3345a4579f726fc4Petr Machataset binfile ${testfile} 61e8f6fe9680c994b9c86753c3345a4579f726fc4Petr Machataset libfile "main-lib" 71e8f6fe9680c994b9c86753c3345a4579f726fc4Petr Machataset libsrc $srcdir/$subdir/$libfile.c 81e8f6fe9680c994b9c86753c3345a4579f726fc4Petr Machataset lib_sl $objdir/$subdir/lib$testfile.so 91e8f6fe9680c994b9c86753c3345a4579f726fc4Petr Machata 101e8f6fe9680c994b9c86753c3345a4579f726fc4Petr Machata 111e8f6fe9680c994b9c86753c3345a4579f726fc4Petr Machataif [get_compiler_info $binfile] { 121e8f6fe9680c994b9c86753c3345a4579f726fc4Petr Machata return -1 131e8f6fe9680c994b9c86753c3345a4579f726fc4Petr Machata} 141e8f6fe9680c994b9c86753c3345a4579f726fc4Petr Machata 151e8f6fe9680c994b9c86753c3345a4579f726fc4Petr Machataverbose "compiling source file now....." 161e8f6fe9680c994b9c86753c3345a4579f726fc4Petr Machataif { [ltrace_compile_shlib $libsrc $lib_sl debug ] != "" 171e8f6fe9680c994b9c86753c3345a4579f726fc4Petr Machata || [ltrace_compile $srcdir/$subdir/$srcfile $objdir/$subdir/$binfile executable [list debug shlib=$lib_sl ldflags=-pthread] ] != ""} { 181e8f6fe9680c994b9c86753c3345a4579f726fc4Petr Machata send_user "Testcase compile failed, so all tests in this file will automatically fail.\n" 191e8f6fe9680c994b9c86753c3345a4579f726fc4Petr Machata} 201e8f6fe9680c994b9c86753c3345a4579f726fc4Petr Machata 211e8f6fe9680c994b9c86753c3345a4579f726fc4Petr Machata# set options for ltrace. 2251e74aca71ff7e8be91c074afd4f2264f46294e9Petr Machataltrace_options "-l" "lib$testfile.so" "-f" 231e8f6fe9680c994b9c86753c3345a4579f726fc4Petr Machata 241e8f6fe9680c994b9c86753c3345a4579f726fc4Petr Machata# Run PUT for ltarce. 251e8f6fe9680c994b9c86753c3345a4579f726fc4Petr Machataset exec_output [ltrace_runtest $objdir/$subdir $objdir/$subdir/$binfile] 261e8f6fe9680c994b9c86753c3345a4579f726fc4Petr Machata 271e8f6fe9680c994b9c86753c3345a4579f726fc4Petr Machata# Check the output of this program. 281e8f6fe9680c994b9c86753c3345a4579f726fc4Petr Machataverbose "ltrace runtest output: $exec_output\n" 291e8f6fe9680c994b9c86753c3345a4579f726fc4Petr Machataif [regexp {ELF from incompatible architecture} $exec_output] { 301e8f6fe9680c994b9c86753c3345a4579f726fc4Petr Machata fail "32-bit ltrace can not perform on 64-bit PUTs and rebuild ltrace in 64 bit mode!" 311e8f6fe9680c994b9c86753c3345a4579f726fc4Petr Machata return 321e8f6fe9680c994b9c86753c3345a4579f726fc4Petr Machata} elseif [ regexp {Couldn't get .hash data} $exec_output ] { 331e8f6fe9680c994b9c86753c3345a4579f726fc4Petr Machata fail "Couldn't get .hash data!" 341e8f6fe9680c994b9c86753c3345a4579f726fc4Petr Machata return 351e8f6fe9680c994b9c86753c3345a4579f726fc4Petr Machata} 361e8f6fe9680c994b9c86753c3345a4579f726fc4Petr Machata 371e8f6fe9680c994b9c86753c3345a4579f726fc4Petr Machata# Verify the output by checking numbers of print in main-threaded.ltrace. 388cda4344bf3d23bba06e45ed065cc0a6792a1034Petr Machataset pattern "print" 391e8f6fe9680c994b9c86753c3345a4579f726fc4Petr Machataltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 30 40