diff options
Diffstat (limited to 'testsuite')
31 files changed, 303 insertions, 75 deletions
diff --git a/testsuite/ChangeLog b/testsuite/ChangeLog index 4b5a3ce8..11af94f3 100644 --- a/testsuite/ChangeLog +++ b/testsuite/ChangeLog @@ -1,3 +1,64 @@ +2008-02-12 Frank Ch. Eigler <fche@elastic.org> + + * systemtap.context/context.exp: Build temporary modules under + build tree, to tolerate read-only source trees. + * {args,backtrace,pid}.tcl: Corresponding changes. + * systemtap_test_module2.c: Add a bunch of asm("")'s to prevent + inlining even better than noinline does. + +2008-02-12 Frank Ch. Eigler <fche@elastic.org> + + * systemtap.pass1-4/buildok.exp: No longer kfail buildok/seventeen. + +2008-02-07 Martin Hunt <hunt@redhat.com> + + * systemtap.base/debugpath.exp: Remove explicit closes. + Stap will terminate without help, and cleanup after itself. + +2008-02-06 Masami Hiramatsu <mhiramat@redhat.com> + + * systemtap.context/backtrace.tcl: Fixed regular expressions and Added + new expression for checking return probe's stacktrace on ia64. + * systemtap.context/backtrace.stp (print_all_trace_info): Added + trace point output before calling print_stack(). + +2008-02-06 Masami Hiramatsu <mhiramat@redhat.com> + + * systemtap.base/cmd_parse.exp: Added 'wait' between tests for + preventing unexpected EOF. + +2008-02-06 Masami Hiramatsu <mhiramat@redhat.com> + + * systemtap.base/procfs.exp: Added PROCFS.ko cleanup. + * systemtap.context/context.exp: Added cleanup call. + * systemtap.printf/end1b.exp: Passed evaluated command string to + as_root. + * systemtap.printf/mixed_outb.exp: Ditto. + * systemtap.printf/out1b.exp: Ditto. + * systemtap.printf/out2b.exp: Ditto. + * systemtap.printf/out3b.exp: Ditto. + +2008-02-04 David Smith <dsmith@redhat.com> + + PR 4446. + * systemtap.base/marker.exp: Added tests for marker "$format" + variable. + +2008-02-01 Martin Hunt <hunt@redhat.com> + PR4736 + * systemtap.printf/stap_merge.tcl: Copied here so + it will always be available. + +2008-01-31 Will Cohen <wcohen@redhat.com> + + * systemtap.pass1-4/buildok.exp: Add some kfails. + +2008-01-29 Frank Ch. Eigler <fche@elastic.org> + + * Makefile.am (clean-local): Allow "rm -rf" to fail due to + root-owned .ko files in the local cache. + * Makefile.in: Regenerated. + 2008-01-26 Frank Ch. Eigler <fche@elastic.org> PR 5673. diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am index 6b14bd60..edaaff3c 100644 --- a/testsuite/Makefile.am +++ b/testsuite/Makefile.am @@ -8,8 +8,8 @@ all-local: @echo Run \"make check\" or \"make installcheck\". clean-local: - @rm -f ./stap site.exp systemtap.sum systemtap.log - @rm -rf .systemtap .cache_test + -rm -f ./stap site.exp systemtap.sum systemtap.log + -rm -rf .systemtap .cache_test 2>/dev/null installcheck-local: clean site.exp $(MAKE) AM_RUNTESTFLAGS="--tool_opts install" check-DEJAGNU diff --git a/testsuite/Makefile.in b/testsuite/Makefile.in index 8907c519..99acf141 100644 --- a/testsuite/Makefile.in +++ b/testsuite/Makefile.in @@ -458,8 +458,8 @@ all-local: @echo Run \"make check\" or \"make installcheck\". clean-local: - @rm -f ./stap site.exp systemtap.sum systemtap.log - @rm -rf .systemtap .cache_test + -rm -f ./stap site.exp systemtap.sum systemtap.log + -rm -rf .systemtap .cache_test 2>/dev/null installcheck-local: clean site.exp $(MAKE) AM_RUNTESTFLAGS="--tool_opts install" check-DEJAGNU diff --git a/testsuite/parseko/probepoint04.stp b/testsuite/parseko/probepoint04.stp index 754c9e63..754c9e63 100644..100755 --- a/testsuite/parseko/probepoint04.stp +++ b/testsuite/parseko/probepoint04.stp diff --git a/testsuite/parseko/probepoint05.stp b/testsuite/parseko/probepoint05.stp index 11464ae2..11464ae2 100644..100755 --- a/testsuite/parseko/probepoint05.stp +++ b/testsuite/parseko/probepoint05.stp diff --git a/testsuite/parseko/probepoint06.stp b/testsuite/parseko/probepoint06.stp index ebe23514..ebe23514 100644..100755 --- a/testsuite/parseko/probepoint06.stp +++ b/testsuite/parseko/probepoint06.stp diff --git a/testsuite/parseko/probepoint07.stp b/testsuite/parseko/probepoint07.stp index 1f240a02..1f240a02 100644..100755 --- a/testsuite/parseko/probepoint07.stp +++ b/testsuite/parseko/probepoint07.stp diff --git a/testsuite/parseko/probepoint08.stp b/testsuite/parseko/probepoint08.stp index a0ec712f..a0ec712f 100644..100755 --- a/testsuite/parseko/probepoint08.stp +++ b/testsuite/parseko/probepoint08.stp diff --git a/testsuite/parseko/probepoint09.stp b/testsuite/parseko/probepoint09.stp index a7bf15d8..a7bf15d8 100644..100755 --- a/testsuite/parseko/probepoint09.stp +++ b/testsuite/parseko/probepoint09.stp diff --git a/testsuite/semko/fortyfour.stp b/testsuite/semko/fortyfour.stp new file mode 100755 index 00000000..8f3caeeb --- /dev/null +++ b/testsuite/semko/fortyfour.stp @@ -0,0 +1,5 @@ +#! stap -p2 + +probe foo = bar {} +probe bar = foo {} +probe foo {} diff --git a/testsuite/semko/fortythree.stp b/testsuite/semko/fortythree.stp new file mode 100755 index 00000000..cbf52a91 --- /dev/null +++ b/testsuite/semko/fortythree.stp @@ -0,0 +1,4 @@ +#! stap -p2 + +probe foo.bar = foo.* { } +probe foo.* { } diff --git a/testsuite/semko/maxactive04.stp b/testsuite/semko/maxactive04.stp index 9471fd21..9471fd21 100644..100755 --- a/testsuite/semko/maxactive04.stp +++ b/testsuite/semko/maxactive04.stp diff --git a/testsuite/semko/maxactive05.stp b/testsuite/semko/maxactive05.stp index bdc8a101..bdc8a101 100644..100755 --- a/testsuite/semko/maxactive05.stp +++ b/testsuite/semko/maxactive05.stp diff --git a/testsuite/semok/thirty.stp b/testsuite/semok/thirty.stp new file mode 100755 index 00000000..27612ed0 --- /dev/null +++ b/testsuite/semok/thirty.stp @@ -0,0 +1,9 @@ +#! stap -p2 + +probe foo.a.one = foo.b, foo.c {} // not recursive +probe foo.a.two = foo.c, foo.b {} // not recursive +probe foo.b = foo.c {} +probe foo.c = begin {} +probe foo.a.one {} +probe foo.a.two {} + diff --git a/testsuite/semok/twentynine.stp b/testsuite/semok/twentynine.stp index 05e591ce..05e591ce 100644..100755 --- a/testsuite/semok/twentynine.stp +++ b/testsuite/semok/twentynine.stp diff --git a/testsuite/systemtap.base/cmd_parse.exp b/testsuite/systemtap.base/cmd_parse.exp index 31676a6f..cf15698f 100644 --- a/testsuite/systemtap.base/cmd_parse.exp +++ b/testsuite/systemtap.base/cmd_parse.exp @@ -13,6 +13,7 @@ expect { timeout {fail "cmd_parse1: unexpected timeout"} eof {fail "cmd_parse1: unexpected EOF"} } +wait # stap -c 'echo "hello "\"world\"' -e 'probe begin {}' spawn stap -c {echo "hello "\"world\"} -e {probe begin {}} @@ -22,6 +23,7 @@ expect { timeout {fail "cmd_parse2: unexpected timeout"} eof {fail "cmd_parse2: unexpected EOF"} } +wait #stap -c '(a="hello world"; echo $a)' -e 'probe begin {}' spawn stap -c {(a="hello world"; echo $a)} -e {probe begin {}} @@ -31,6 +33,7 @@ expect { timeout {fail "cmd_parse3: unexpected timeout"} eof {fail "cmd_parse3: unexpected EOF"} } +wait #stap -c '(a="hello "\"world\"; echo $a)' -e 'probe begin {}' spawn stap -c {(a="hello "\"world\"; echo $a)} -e {probe begin {}} @@ -40,6 +43,7 @@ expect { timeout {fail "cmd_parse4: unexpected timeout"} eof {fail "cmd_parse4: unexpected EOF"} } +wait #stap -c '(a="hello "world; echo $a)' -e 'probe begin {}' spawn stap -c {(a="hello "world; echo $a)} -e {probe begin {}} @@ -49,6 +53,7 @@ expect { timeout {fail "cmd_parse5: unexpected timeout"} eof {fail "cmd_parse5: unexpected EOF"} } +wait #stap -c '(((a=42+7)); echo "The answer is $a")' -e 'probe begin {}' spawn stap -c {(((a=42+7)); echo "The answer is $a")} -e {probe begin {}} @@ -58,6 +63,7 @@ expect { timeout {fail "cmd_parse6: unexpected timeout"} eof {fail "cmd_parse6: unexpected EOF"} } +wait #stap -c '(echo "Hello World" 1>&2) > /dev/null' -e 'probe begin {}' spawn stap -c {(echo "Hello World" 1>&2) > /dev/null} -e {probe begin {}} @@ -67,3 +73,4 @@ expect { timeout {fail "cmd_parse7: unexpected timeout"} eof {fail "cmd_parse7: unexpected EOF"} } +wait diff --git a/testsuite/systemtap.base/debugpath.exp b/testsuite/systemtap.base/debugpath.exp index 67b9eb70..b0b12207 100644 --- a/testsuite/systemtap.base/debugpath.exp +++ b/testsuite/systemtap.base/debugpath.exp @@ -6,7 +6,8 @@ expect { timeout { fail "$test (timeout1)" } eof { fail "$test (eof)" } } -catch { close; wait } + +wait set test "debugpath-good" spawn env SYSTEMTAP_DEBUGINFO_PATH=:/usr/lib/debug stap -e "probe kernel.function(\"sys_open\") {}" -p2 @@ -15,4 +16,5 @@ expect { timeout { fail "$test (timeout2)" } eof { fail "$test (eof)" } } -catch { close ; wait } + +wait diff --git a/testsuite/systemtap.base/marker.exp b/testsuite/systemtap.base/marker.exp index bfa3b02d..59d6fd33 100644 --- a/testsuite/systemtap.base/marker.exp +++ b/testsuite/systemtap.base/marker.exp @@ -11,7 +11,7 @@ proc stap_compile { TEST_NAME compile script args } { set cmd [concat {stap -v -p4 -e} $script $args] - puts "running $cmd" + verbose -log "running $cmd" eval spawn $cmd set compile_errors 0 expect { @@ -192,3 +192,47 @@ if {$kernel_markers_found == 0} { set script [format $kernel_script_arg3 $num_marker_name {\[0\]}] stap_compile $TEST_NAME 0 $script } + +set TEST_NAME "K_MARKER11" +if {$kernel_markers_found == 0} { + untested "$TEST_NAME : no kernel markers present" +} else { + # Try compiling a script that prints the format string of a + # marker. + set script [format $kernel_script_arg \ + [lindex $kernel_marker_names 0] {\$format}] + stap_compile $TEST_NAME 1 $script +} + +set TEST_NAME "K_MARKER12" +if {$kernel_markers_found == 0} { + untested "$TEST_NAME : no kernel markers present" +} else { + # Try compiling a script that writes to a marker format string + # (which isn't allowed). + set script [format $kernel_script_arg2 \ + [lindex $kernel_marker_names 0] {\$format}] + stap_compile $TEST_NAME 0 $script +} + +set TEST_NAME "K_MARKER13" +if {$kernel_markers_found == 0} { + untested "$TEST_NAME : no kernel markers present" +} else { + # Try compiling a script that treats the marker format string as a + # structure (which isn't allowed). + set script [format $kernel_script_arg \ + [lindex $kernel_marker_names 0] {\$format->foo}] + stap_compile $TEST_NAME 0 $script +} + +set TEST_NAME "K_MARKER14" +if {$kernel_markers_found == 0} { + untested "$TEST_NAME : no kernel markers present" +} else { + # Try compiling a script that treats the marker format string like + # an array (which isn't allowed). + set script [format $kernel_script_arg \ + [lindex $kernel_marker_names 0] {\$format\[0\]}] + stap_compile $TEST_NAME 0 $script +} diff --git a/testsuite/systemtap.base/procfs.exp b/testsuite/systemtap.base/procfs.exp index ac00acc6..182f1e2e 100644 --- a/testsuite/systemtap.base/procfs.exp +++ b/testsuite/systemtap.base/procfs.exp @@ -110,3 +110,5 @@ set systemtap_script { # test procfs probes set output_string "\\mfinal value = goodbye\\M\r\n" stap_run $test proc_read_write $output_string -e $systemtap_script -m $test + +exec /bin/rm -f ${test}.ko diff --git a/testsuite/systemtap.context/args.tcl b/testsuite/systemtap.context/args.tcl index 6c14c4b7..37a43823 100644 --- a/testsuite/systemtap.context/args.tcl +++ b/testsuite/systemtap.context/args.tcl @@ -1,4 +1,4 @@ -spawn stap args.stp +spawn stap $srcdir/$subdir/args.stp expect { -timeout 240 "READY" { diff --git a/testsuite/systemtap.context/backtrace.stp b/testsuite/systemtap.context/backtrace.stp index 73781371..c14d071c 100644 --- a/testsuite/systemtap.context/backtrace.stp +++ b/testsuite/systemtap.context/backtrace.stp @@ -4,7 +4,7 @@ function print_all_trace_info(point:string) { print("--------\n") bt = backtrace() printf("the %s stack is %s\n", point, bt) - print("--------\n") + printf("--<%s>--\n", point) print_stack(bt); print("--------\n") } diff --git a/testsuite/systemtap.context/backtrace.tcl b/testsuite/systemtap.context/backtrace.tcl index e35832ee..703f0ec2 100644 --- a/testsuite/systemtap.context/backtrace.tcl +++ b/testsuite/systemtap.context/backtrace.tcl @@ -5,7 +5,13 @@ set m4 0 set m5 0 set m6 0 -spawn stap backtrace.stp +if {[istarget ia64-*-*]} { + set retexp {.*return\>--\r\n 0x[a-f0-9]+ : yyy_func3[^\[]+\[systemtap_test_module2\]\r\n} +} else { + set retexp {.*return\>--\r\n 0x[a-f0-9]+ : kretprobe_trampoline_holder[^\r\n]+\r\n} +} + +spawn stap $srcdir/$subdir/backtrace.stp #exp_internal 1 expect { -timeout 240 @@ -36,7 +42,7 @@ expect { incr m2 expect { -timeout 5 - -re {.*---\r\n 0x[a-f0-9]+ : yyy_func3[^\[]+\[systemtap_test_module2\]\r\n} { + -re {.*call\>--\r\n 0x[a-f0-9]+ : yyy_func3[^\[]+\[systemtap_test_module2\]\r\n} { if {$m2 == 1} {incr m2} exp_continue } @@ -76,7 +82,7 @@ expect { incr m4 expect { -timeout 5 - -re {.*0x[a-f0-9]+ : kretprobe_trampoline_holder[^\[]+\[\]\r\n} { + -re $retexp { if {$m4 == 1} {incr m4} exp_continue } @@ -104,7 +110,7 @@ expect { incr m6 expect { -timeout 5 - -re {.*---\r\n 0x[a-f0-9]+[^\r\n]+\r\n} { + -re {.*profile>--\r\n 0x[a-f0-9]+[^\r\n]+\r\n} { if {$m6 == 1} {incr m6} } } diff --git a/testsuite/systemtap.context/context.exp b/testsuite/systemtap.context/context.exp index bc5f8ebe..11c0f2fc 100644 --- a/testsuite/systemtap.context/context.exp +++ b/testsuite/systemtap.context/context.exp @@ -21,20 +21,21 @@ proc cleanup {} { proc build_modules {} { global build_dir + global srcdir subdir if {[catch {exec mktemp -d staptestXXXXX} build_dir]} { puts stderr "Failed to create temporary directory: $build_dir" return 0 } - foreach f [glob systemtap_test_module*.c] { + foreach f [glob $srcdir/$subdir/systemtap_test_module*.c] { exec cp $f $build_dir } set old_dir [pwd] cd $build_dir foreach n {2 1} { - exec cp $old_dir/makefile$n Makefile + exec cp $srcdir/$subdir/makefile$n Makefile if {[catch {exec make clean} res]} { puts $res cd $old_dir @@ -61,7 +62,13 @@ proc build_modules {} { } # first build the modules -cd $srcdir/$subdir + +# NB: We cannot "cd" on behalf the whole dejagnu process, especially +# without going back to the build tree, and especially not to the +# source tree expecting to be able to write there. +# +# cd $srcdir/$subdir + set uname [exec /bin/uname -r] if {[build_modules] == 0} { @@ -73,9 +80,8 @@ if {[build_modules] == 0} { } foreach test $testlist { - source $test.tcl + source $srcdir/$subdir/$test.tcl } - - +cleanup diff --git a/testsuite/systemtap.context/pid.tcl b/testsuite/systemtap.context/pid.tcl index c96d922f..a2c091f1 100644 --- a/testsuite/systemtap.context/pid.tcl +++ b/testsuite/systemtap.context/pid.tcl @@ -1,5 +1,5 @@ set tests [list execname pexecname pid ppid tid uid euid gid egid] -spawn stap pid.stp +spawn stap $srcdir/$subdir/pid.stp #exp_internal 1 expect { -timeout 240 diff --git a/testsuite/systemtap.context/systemtap_test_module2.c b/testsuite/systemtap.context/systemtap_test_module2.c index 51cb58bb..b0d47428 100644 --- a/testsuite/systemtap.context/systemtap_test_module2.c +++ b/testsuite/systemtap.context/systemtap_test_module2.c @@ -22,19 +22,23 @@ /* some nested functions to test backtraces */ int noinline yyy_func4 (int foo) { + asm (""); return foo + 1; } int noinline yyy_func3 (int foo) { foo = yyy_func4(foo); + asm (""); return foo + 1; } int noinline yyy_func2 (int foo) { foo = yyy_func3(foo); + asm (""); return foo + 1; } int noinline yyy_func1 (int foo) { foo = yyy_func2(foo); + asm (""); return foo + 1; } EXPORT_SYMBOL(yyy_func1); @@ -42,31 +46,37 @@ EXPORT_SYMBOL(yyy_func1); /* 1. int argument testing */ int noinline yyy_int(int a, int b, int c) { + asm (""); return a+b+c; } /* 2. uint argument testing */ unsigned noinline yyy_uint(unsigned a, unsigned b, unsigned c) { + asm (""); return a+b+c; } /* 3. long argument testing */ long noinline yyy_long(long a, long b, long c) { + asm (""); return a+b+c; } /* 4. int64_t argument testing */ int noinline yyy_int64(int64_t a, int64_t b, int64_t c) { + asm (""); return a+b+c; } /* 5. char argument testing */ char noinline yyy_char(char a, char b, char c) { + asm (""); return 'Q'; } /* 5. string argument testing */ char * noinline yyy_str(char *a, char *b, char *c) { + asm (""); return "XYZZY"; } diff --git a/testsuite/systemtap.printf/end1b.exp b/testsuite/systemtap.printf/end1b.exp index 6168f66e..e28dce5b 100644 --- a/testsuite/systemtap.printf/end1b.exp +++ b/testsuite/systemtap.printf/end1b.exp @@ -3,13 +3,7 @@ set TEST_NAME "$subdir/end1b" if {![installtest_p]} { untested $TEST_NAME; return } -# Look for stap_merge in the toplevel build directory -# and if that fails, use "which" to try to find a copy -# in the path. -set stap_merge_path "$srcdir/../runtime/staprun/stap_merge.tcl" -if (![file executable $stap_merge_path]) { - catch {exec which stap_merge} stap_merge_path -} +set stap_merge_path "$srcdir/$subdir/stap_merge.tcl" if (![file executable $stap_merge_path]) { fail "$TEST_NAME : could not find stap_merge" return @@ -24,24 +18,24 @@ if {[catch {exec mktemp -t staptestXXXXX} tmpfile]} { if {[catch {exec stap -b -o $tmpfile $test} res]} { untested $TEST_NAME puts "stap failed: $res" - as_root {/bin/rm -f [glob ${tmpfile}*]} + as_root "/bin/rm -f [glob ${tmpfile}*]" return } if {[catch {eval [list exec $stap_merge_path -o $tmpfile] [glob "${tmpfile}_*"]} res]} { puts "merge failed: $res" fail "$TEST_NAME failed" - as_root {/bin/rm -f [glob ${tmpfile}*]} + as_root "/bin/rm -f [glob ${tmpfile}*]" return } if {[catch {exec cmp $tmpfile $srcdir/$subdir/large_output} res]} { puts "$res" fail "$TEST_NAME failed" - as_root {/bin/rm -f [glob ${tmpfile}*]} + as_root "/bin/rm -f [glob ${tmpfile}*]" return } pass "$TEST_NAME passed" -as_root {/bin/rm -f [glob ${tmpfile}*]} +as_root "/bin/rm -f [glob ${tmpfile}*]" diff --git a/testsuite/systemtap.printf/mixed_outb.exp b/testsuite/systemtap.printf/mixed_outb.exp index 6d352dd4..748dd0f2 100644 --- a/testsuite/systemtap.printf/mixed_outb.exp +++ b/testsuite/systemtap.printf/mixed_outb.exp @@ -3,13 +3,7 @@ set TEST_NAME "$subdir/mixed_outb" if {![installtest_p]} { untested $TEST_NAME; return } -# Look for stap_merge in the toplevel build directory -# and if that fails, use "which" to try to find a copy -# in the path. -set stap_merge_path "$srcdir/../runtime/staprun/stap_merge.tcl" -if (![file executable $stap_merge_path]) { - catch {exec which stap_merge} stap_merge_path -} +set stap_merge_path "$srcdir/$subdir/stap_merge.tcl" if (![file executable $stap_merge_path]) { fail "$TEST_NAME : could not find stap_merge" return @@ -24,24 +18,24 @@ if {[catch {exec mktemp -t staptestXXXXX} tmpfile]} { if {[catch {exec stap -DMAXACTION=100000 -b -o $tmpfile $test} res]} { untested $TEST_NAME puts "stap failed: $res" - as_root {/bin/rm -f [glob ${tmpfile}*]} + as_root "/bin/rm -f [glob ${tmpfile}*]" return } if {[catch {eval [list exec $stap_merge_path -o $tmpfile] [glob "${tmpfile}_*"]} res]} { puts "merge failed: $res" fail "$TEST_NAME failed" - as_root {/bin/rm -f [glob ${tmpfile}*]} + as_root "/bin/rm -f [glob ${tmpfile}*]" return } if {[catch {exec cmp $tmpfile $srcdir/$subdir/large_output} res]} { puts "$res" fail "$TEST_NAME failed" - as_root {/bin/rm -f [glob ${tmpfile}*]} + as_root "/bin/rm -f [glob ${tmpfile}*]" return } pass "$TEST_NAME passed" -as_root {/bin/rm -f [glob ${tmpfile}*]} +as_root "/bin/rm -f [glob ${tmpfile}*]" diff --git a/testsuite/systemtap.printf/out1b.exp b/testsuite/systemtap.printf/out1b.exp index 723238c5..6edb8772 100644 --- a/testsuite/systemtap.printf/out1b.exp +++ b/testsuite/systemtap.printf/out1b.exp @@ -3,13 +3,7 @@ set TEST_NAME "$subdir/out1b" if {![installtest_p]} { untested $TEST_NAME; return } -# Look for stap_merge in the toplevel build directory -# and if that fails, use "which" to try to find a copy -# in the path. -set stap_merge_path "$srcdir/../runtime/staprun/stap_merge.tcl" -if (![file executable $stap_merge_path]) { - catch {exec which stap_merge} stap_merge_path -} +set stap_merge_path "$srcdir/$subdir/stap_merge.tcl" if (![file executable $stap_merge_path]) { fail "$TEST_NAME : could not find stap_merge" return @@ -24,24 +18,24 @@ if {[catch {exec mktemp -t staptestXXXXX} tmpfile]} { if {[catch {exec stap -b -o $tmpfile $test} res]} { untested $TEST_NAME puts "stap failed: $res" - as_root {/bin/rm -f [glob ${tmpfile}*]} + as_root "/bin/rm -f [glob ${tmpfile}*]" return } if {[catch {eval [list exec $stap_merge_path -o $tmpfile] [glob "${tmpfile}_*"]} res]} { puts "merge failed: $res" fail "$TEST_NAME failed" - as_root {/bin/rm -f [glob ${tmpfile}*]} + as_root "/bin/rm -f [glob ${tmpfile}*]" return } if {[catch {exec cmp $tmpfile $srcdir/$subdir/large_output} res]} { puts "$res" fail "$TEST_NAME failed" - as_root {/bin/rm -f [glob ${tmpfile}*]} + as_root "/bin/rm -f [glob ${tmpfile}*]" return } pass "$TEST_NAME passed" -as_root {/bin/rm -f [glob ${tmpfile}*]} +as_root "/bin/rm -f [glob ${tmpfile}*]" diff --git a/testsuite/systemtap.printf/out2b.exp b/testsuite/systemtap.printf/out2b.exp index 085cfa14..fc3301ab 100644 --- a/testsuite/systemtap.printf/out2b.exp +++ b/testsuite/systemtap.printf/out2b.exp @@ -3,13 +3,7 @@ set TEST_NAME "$subdir/out2b" if {![installtest_p]} { untested $TEST_NAME; return } -# Look for stap_merge in the toplevel build directory -# and if that fails, use "which" to try to find a copy -# in the path. -set stap_merge_path "$srcdir/../runtime/staprun/stap_merge.tcl" -if (![file executable $stap_merge_path]) { - catch {exec which stap_merge} stap_merge_path -} +set stap_merge_path "$srcdir/$subdir/stap_merge.tcl" if (![file executable $stap_merge_path]) { fail "$TEST_NAME : could not find stap_merge" return @@ -24,24 +18,24 @@ if {[catch {exec mktemp -t staptestXXXXX} tmpfile]} { if {[catch {exec stap -b -o $tmpfile $test} res]} { untested $TEST_NAME puts "stap failed: $res" - as_root {/bin/rm -f [glob ${tmpfile}*]} + as_root "/bin/rm -f [glob ${tmpfile}*]" return } if {[catch {eval [list exec $stap_merge_path -o $tmpfile] [glob "${tmpfile}_*"]} res]} { puts "merge failed: $res" fail "$TEST_NAME failed" - as_root {/bin/rm -f [glob ${tmpfile}*]} + as_root "/bin/rm -f [glob ${tmpfile}*]" return } if {[catch {exec cmp $tmpfile $srcdir/$subdir/large_output} res]} { puts "$res" fail "$TEST_NAME failed" - as_root {/bin/rm -f [glob ${tmpfile}*]} + as_root "/bin/rm -f [glob ${tmpfile}*]" return } pass "$TEST_NAME passed" -as_root {/bin/rm -f [glob ${tmpfile}*]} +as_root "/bin/rm -f [glob ${tmpfile}*]" diff --git a/testsuite/systemtap.printf/out3b.exp b/testsuite/systemtap.printf/out3b.exp index 395363fc..af0d6be7 100644 --- a/testsuite/systemtap.printf/out3b.exp +++ b/testsuite/systemtap.printf/out3b.exp @@ -3,13 +3,7 @@ set TEST_NAME "$subdir/out3b" if {![installtest_p]} { untested $TEST_NAME; return } -# Look for stap_merge in the toplevel build directory -# and if that fails, use "which" to try to find a copy -# in the path. -set stap_merge_path "$srcdir/../runtime/staprun/stap_merge.tcl" -if (![file executable $stap_merge_path]) { - catch {exec which stap_merge} stap_merge_path -} +set stap_merge_path "$srcdir/$subdir/stap_merge.tcl" if (![file executable $stap_merge_path]) { fail "$TEST_NAME : could not find stap_merge" return @@ -24,24 +18,24 @@ if {[catch {exec mktemp -t staptestXXXXX} tmpfile]} { if {[catch {exec stap -DMAXACTION=100000 -b -o $tmpfile $test} res]} { untested $TEST_NAME puts "stap failed: $res" - as_root {/bin/rm -f [glob ${tmpfile}*]} + as_root "/bin/rm -f [glob ${tmpfile}*]" return } if {[catch {eval [list exec $stap_merge_path -o $tmpfile] [glob "${tmpfile}_*"]} res]} { puts "merge failed: $res" fail "$TEST_NAME failed" - as_root {/bin/rm -f [glob ${tmpfile}*]} + as_root "/bin/rm -f [glob ${tmpfile}*]" return } if {[catch {exec cmp $tmpfile $srcdir/$subdir/large_output} res]} { puts "$res" fail "$TEST_NAME failed" - as_root {/bin/rm -f [glob ${tmpfile}*]} + as_root "/bin/rm -f [glob ${tmpfile}*]" return } pass "$TEST_NAME passed" -as_root {/bin/rm -f [glob ${tmpfile}*]} +as_root "/bin/rm -f [glob ${tmpfile}*]" diff --git a/testsuite/systemtap.printf/stap_merge.tcl b/testsuite/systemtap.printf/stap_merge.tcl new file mode 100755 index 00000000..47d419ce --- /dev/null +++ b/testsuite/systemtap.printf/stap_merge.tcl @@ -0,0 +1,102 @@ +#!/usr/bin/env tclsh +# +# stap_merge.tcl - systemtap merge program +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# Copyright (C) Red Hat Inc, 2007 +# +# + +proc usage {} { + puts stderr "$::argv0 \[-v\] \[-o output_filename\] input_files ...\n" + exit 1 +} + +set outfile "stdout" +set verbose 0 +set index 0 +while {[string match -* [lindex $argv $index]]} { + switch -glob -- [lindex $argv $index] { + -v {set verbose 1} + -o {incr index; set outfile [lindex $argv $index]} + default {usage} + } + incr index +} + +if {$tcl_platform(byteOrder) == "littleEndian"} { + set int_format i +} else { + set int_format I +} + +set files [lrange $argv $index end] + +set n 0 +foreach file $files { + if {[catch {open $file} fd($n)]} { + puts stderr $fd($n) + exit 1 + } + fconfigure $fd($n) -translation binary + if {![binary scan [read $fd($n) 4] $int_format timestamp($n)]} { + continue + } + set timestamp($n) [expr $timestamp($n) & 0xFFFFFFFF] + incr n +} +set ncpus $n + +if {$outfile != "stdout"} { + if {[catch {open $outfile w} outfile]} { + puts stderr $outfile + exit 1 + } +} +fconfigure $outfile -translation binary + +while {1} { + set mincpu -1 + for {set n 0} {$n < $ncpus} {incr n} { + if {[info exists fd($n)] && (![info exists min] || $timestamp($n) <= $min)} { + set min $timestamp($n) + set mincpu $n + } + } + + if {![info exists min]} {break} + + if {![binary scan [read $fd($mincpu) 4] $int_format len]} { + puts stderr "Error reading length from channel $mincpu" + exit 1 + } + + if {$verbose == 1} { + puts stderr "\[CPU:$mincpu, seq=$min, length=$len\]" + } + + set data [read $fd($mincpu) $len] + puts -nonewline $outfile $data + + set data [read $fd($mincpu) 4] + if {$data == ""} { + unset fd($mincpu) + } else { + binary scan $data $int_format timestamp($mincpu) + set timestamp($mincpu) [expr $timestamp($mincpu) & 0xFFFFFFFF] + } + unset min +} |