1 # This file was written by Steve Fink <sphink (at) gmail.com>. 2 # Based on main.c by Yao Qi <qiyao (at) cn.ibm.com>. 3 4 set testfile "parameters" 5 set srcfile ${testfile}.c 6 set binfile ${testfile} 7 set libfile "parameters-lib" 8 set libsrc $srcdir/$subdir/$libfile.c 9 set lib_sl $objdir/$subdir/lib$testfile.so 10 11 12 if [get_compiler_info $binfile] { 13 return -1 14 } 15 16 verbose "compiling source file now....." 17 if { [ltrace_compile_shlib $libsrc $lib_sl debug ] != "" 18 || [ltrace_compile $srcdir/$subdir/$srcfile $objdir/$subdir/$binfile executable [list debug shlib=$lib_sl] ] != ""} { 19 send_user "Testcase compile failed, so all tests in this file will automatically fail.\n" 20 } 21 22 # set options for ltrace. 23 ltrace_options "-l" "libparameters.so" "-F" "$srcdir/$subdir/parameters.conf" 24 25 # Run PUT for ltarce. 26 set exec_output [ltrace_runtest $objdir/$subdir $objdir/$subdir/$binfile] 27 28 # Check the output of this program. 29 verbose "ltrace runtest output: $exec_output\n" 30 if [regexp {ELF from incompatible architecture} $exec_output] { 31 fail "32-bit ltrace can not perform on 64-bit PUTs and rebuild ltrace in 64 bit mode!" 32 return 33 } elseif [ regexp {Couldn't get .hash data} $exec_output ] { 34 fail "Couldn't get .hash data!" 35 return 36 } 37 38 # Verify the output 39 set pattern "func_intptr(17)" 40 ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 1 41 set pattern "func_intptr_ret(42)" 42 ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 1 43 set pattern "func_strlen(\\\"Hello world\\\") *= *11" 44 ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 1 45 set pattern "func_arg0(\\\"Hello another world!\\\") *= *20" 46 ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 1 47 set pattern "func_strfixed(\\\"Hell\\\")" 48 ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 1 49 set pattern "func_ppp(80)" 50 ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 1 51 set pattern "func_stringp(\\\"Dude\\\")" 52 ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 1 53 set pattern "func_string(\\\"zero\\\")" 54 ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 1 55 set pattern "func_enum(BLUE)" 56 ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 1 57 set pattern "func_short(-8, -9)" 58 ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 1 59 set pattern "func_ushort(33, 34)" 60 ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 1 61 set pattern "func_float(3.40*, -3.40*).*= 3.40*" 62 ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 1 63 set pattern "func_double(3.40*, -3.40*).*= -3.40*" 64 ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 1 65 set pattern "func_typedef(BLUE)" 66 ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 1 67 set pattern "func_arrayi(. 10, 11, 12, 13\\.\\.\\. ., 8)" 68 ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 1 69 set pattern "func_arrayi(. 10, 11 ., 2)" 70 ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 1 71 set pattern "func_arrayf(. 10.10*, 11.10*, 12.10*, 13.10*\\.\\.\\. ., 8)" 72 ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 1 73 set pattern "func_arrayf(. 10.10*, 11.10* ., 2)" 74 ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 1 75 set pattern "exited (status 0)" 76 ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 1 77 set pattern "func_struct({ 89, 2, 3, . { 1, 10 }, { 3, 30 } ., . { 4, 40 }, { 5, 50 }, { 6, 60 } ., \\\"123\\\" })" 78 ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 1 79 set pattern "func_call( <unfinished ...>" 80 ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 1 81 set pattern "func_work(\\\"x\\\")" 82 ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 1 83 set pattern "func_struct_2(17, { \\\"ABCDE\\\\\\\\0\\\", 0.250* }, 0.50*).*= { 0.250*, 'B', 'C' }" 84 ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 1 85 set pattern "<... func_call resumed> \\\"x\\\", \\\"y\\\")" 86 ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 1 87 88 set pattern "func_struct_large({ 1, 2, 3, 4 }, { 5, 6, 7, 8 }).*= { 6, 8, 10, 12 }" 89 ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 1 90 91 set pattern "func_struct_large2({ '0', '1', 3, 4 }, { '2', '3', 7, 8 }).*= { 'b', 'd', 10, 12 }" 92 ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 1 93 94 set pattern "func_struct_large3({ 3, 4, '0', '1' }, { 7, 8, '2', '3' }).*= { 10, 12, 'b', 'd' }" 95 ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 1 96 97 set pattern "func_many_args(1, 2, 3, 4.00*, '5', 6, 7.00*, '8', 9, 10.00*, 11, 12.00*, 'A', 14, 15, 16, 'B', 18.00*, 19.00*, 20.00*, 21, 22.00*, 23.00*, 24.00*, 25.00*)" 98 ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 1 99 100 set pattern "func_printf(\\\"sotnuh %d %ld %g %c.n\\\", 5, 6, 1.500*, 'X')" 101 ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 1 102 103 set pattern "func_printf(\\\"sotnuh1 %d %ld %hd.n\\\", 5, 6, 7)" 104 ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 1 105 106 set pattern "func_printf(\\\"sotnuh2 %s %10s %10s.n\\\", \\\"a string\\\", \\\"a trimmed \\\", \\\"short\\\")" 107 ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 1 108 109 set pattern "func_printf(\\\"sotnuh3 %.s.n\\\", 4, \\\"a tr\\\")" 110 ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 1 111 112 set pattern "func_printf(\\\"many_args%d %d %ld %g %c %d %g .*, 1, 2, 3, 4.00*, '5', 6, 7.00*, '8', 9, 10.00*, 11, 12.00*, 'A', 14, 15, 16, 'B', 18.00*, 19.00*, 20.00*, 21, 22.00*, 23.00*, 24.00*, 25.00*)" 113 ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 1 114 115 set pattern "func_sprintf(nil, \\\"test %d %d %d %d.n\\\", 1, 2, 3, 4)" 116 ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 1 117 118 set pattern "func_lens(026, 027, 0x18, 0x19)" 119 ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 1 120 121 set pattern "func_bool(1, true).*= false" 122 ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 1 123 124 set pattern "func_bool(2, false).*= true" 125 ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 1 126 127 set pattern "func_hide(2, 5, 7)" 128 ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 1 129 130 set pattern "func_hide_struct({ 2, 5, 7 })" 131 ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 1 132 133 set pattern "func_short_enums(. A, B, A, A .).*= . A, B, A, A ." 134 ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 1 135 136 set pattern "func_negative_enum(A, A, A, A, A, A).*= A" 137 ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 1 138 139 set pattern "func_charp_string(\\\"null-terminated string\\\")" 140 ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 1 141 142 set pattern "func_struct_empty({ *}).*= { *}" 143 ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 1 144 145 set pattern "func_struct_size1({ '5' }).*= { '5' }" 146 ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 1 147 148 set pattern "func_struct_size2({ 5 }).*= { 5 }" 149 ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 1 150 151 set pattern "func_struct_size4({ 5 }).*= { 5 }" 152 ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 1 153 154 set pattern "func_struct_size8({ 5, 6 }).*= { 5, 6 }" 155 ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 1 156