From fafd79e3a65854c8e7b3c0048e044af9741a0fff Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Fri, 13 Mar 2009 14:44:54 +0100 Subject: Introduce stap_run3 for distinct test names. * testsuite/lib/stap_run2.exp: Add stap_run3, called from stap_run2. * testsuite/systemtap.base/sdt.exp: Use stap_run3, for distinct test names. --- testsuite/systemtap.base/sdt.exp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/sdt.exp b/testsuite/systemtap.base/sdt.exp index 74818beb..9e5dfc37 100644 --- a/testsuite/systemtap.base/sdt.exp +++ b/testsuite/systemtap.base/sdt.exp @@ -33,8 +33,7 @@ if { $res != "" } { } if {[installtest_p]} { -# XXX: we need distinct test names for these - stap_run2 $srcdir/$subdir/$test.stp -c ./$test.prog + stap_run3 "$test $extra_flag" $srcdir/$subdir/$test.stp -c ./$test.prog } else { untested "$test $extra_flag" } @@ -56,8 +55,7 @@ if { $res != "" } { } if {[installtest_p]} { -# XXX: we need distinct test names for these - stap_run2 $srcdir/$subdir/$test.stp -c ./$test.prog + stap_run3 "$test c++ $extra_flag" $srcdir/$subdir/$test.stp -c ./$test.prog } else { untested "$test c++ $extra_flag" } -- cgit From b16858f1452b4f111beb80875a5967dc8dff30fe Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Fri, 13 Mar 2009 14:49:55 +0100 Subject: Add -O2 and -O3 as extra test flags to sdt. * testsuite/systemtap.base/sdt.exp: Add -O2, -O3. --- testsuite/systemtap.base/sdt.exp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/sdt.exp b/testsuite/systemtap.base/sdt.exp index 9e5dfc37..a0220202 100644 --- a/testsuite/systemtap.base/sdt.exp +++ b/testsuite/systemtap.base/sdt.exp @@ -10,7 +10,7 @@ set ::result_string {1 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 10} -set extra_flags {{""} {additional_flags=-std=gnu89} {additional_flags=-ansi} {additional_flags=-pedantic}} +set extra_flags {{""} {additional_flags=-std=gnu89} {additional_flags=-ansi} {additional_flags=-pedantic} {additional_flags=-O2} {additional_flags="-O3"}} # Iterate extra_flags, trying each with C and C++ for {set i 0} {$i < [llength $extra_flags]} {incr i} { -- cgit From 2497c78e8aa704366683dad56fc8d749a5e92f52 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Fri, 13 Mar 2009 14:54:26 +0100 Subject: Add -ansi -pedantic pair to sdt test. * testsuite/systemtap.base/sdt.exp: Add additional_flags -ansi together with -pedantic. --- testsuite/systemtap.base/sdt.exp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/sdt.exp b/testsuite/systemtap.base/sdt.exp index a0220202..21b94810 100644 --- a/testsuite/systemtap.base/sdt.exp +++ b/testsuite/systemtap.base/sdt.exp @@ -10,7 +10,7 @@ set ::result_string {1 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 10} -set extra_flags {{""} {additional_flags=-std=gnu89} {additional_flags=-ansi} {additional_flags=-pedantic} {additional_flags=-O2} {additional_flags="-O3"}} +set extra_flags {{""} {additional_flags=-std=gnu89} {additional_flags=-ansi} {additional_flags=-pedantic} {additional_flags=-ansi additional_flags=-pedantic} {additional_flags=-O2} {additional_flags="-O3"}} # Iterate extra_flags, trying each with C and C++ for {set i 0} {$i < [llength $extra_flags]} {incr i} { -- cgit From 67aada05e69728327de1c7b8aeeaa0193668bed8 Mon Sep 17 00:00:00 2001 From: Stan Cox Date: Tue, 17 Mar 2009 11:38:08 -0400 Subject: Improve static_uprobes.exp * systemtap.base/static_uprobes.exp: Compile with -x c++. Test .probes absence. --- testsuite/systemtap.base/static_uprobes.exp | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/static_uprobes.exp b/testsuite/systemtap.base/static_uprobes.exp index a4bd5e2c..b4214436 100644 --- a/testsuite/systemtap.base/static_uprobes.exp +++ b/testsuite/systemtap.base/static_uprobes.exp @@ -1,5 +1,4 @@ - -set test "sduprobes" +set test "static_uprobes" # Compile a C program to use as the user-space probing target set sup_srcpath "[pwd]/static_uprobes.c" @@ -115,9 +114,7 @@ if { $res != "" } { pass "$test compiling C -g" } -spawn mv $sup_srcpath "[pwd]/static_uprobes.cc" -set sup_srcpath "[pwd]/static_uprobes.cc" -set sup_flags "$sup_flags c++" +set sup_flags "$sup_flags additional_flags=-x additional_flags=c++" set res [target_compile $sup_srcpath $supcplus_exepath executable $sup_flags] if { $res != "" } { verbose "target_compile failed: $res" 2 @@ -163,9 +160,9 @@ if {$ok == 5} { pass "$test C" } { fail "$test C ($ok)" } set ok 0 -# spawn objcopy -R .probes $supcplus_exepath $sup_exepath -verbose -log "cp $supcplus_exepath $sup_exepath" -spawn cp $supcplus_exepath $sup_exepath +# Test setting a probe without .probes using only dwarf label info +verbose -log "objcopy -R .probes $supcplus_exepath $sup_exepath" +spawn objcopy -R .probes $supcplus_exepath $sup_exepath verbose -log "spawn stap -c $sup_exepath $sup_stppath" spawn stap -c $sup_exepath $sup_stppath expect { @@ -182,7 +179,4 @@ wait if {$ok == 5} { pass "$test C++" } { fail "$test C++ ($ok)" } -# catch {exec rm -f $sup_srcpath $sup_exepath $supcplus_exepath $sup_hpath $sup_stppath} - -# It's not so important to clean up, and it's unhelpful if -# one needs to diagnose a test failure. +catch {exec rm -f $sup_srcpath $sup_exepath $supcplus_exepath $sup_dpath $sup_hpath $sup_stppath} -- cgit From 0afb7073fa08980ecf9a80018d18a5148c2f686e Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Thu, 19 Mar 2009 11:32:48 -0400 Subject: rename process().itrace -> process().insn introduce process().insn.block --- testsuite/systemtap.base/itrace.exp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/itrace.exp b/testsuite/systemtap.base/itrace.exp index f19af977..e215bfe7 100644 --- a/testsuite/systemtap.base/itrace.exp +++ b/testsuite/systemtap.base/itrace.exp @@ -1,8 +1,5 @@ # itrace test -# temporarily disabled -return - # Initialize variables set utrace_support_found 0 @@ -11,7 +8,7 @@ set exepath "[pwd]/ls_[pid]" set itrace1_script { global instrs = 0 probe begin { printf("systemtap starting probe\n") } - probe process("%s").itrace + probe process("%s").insn { instrs += 1 if (instrs == 5) @@ -28,7 +25,7 @@ set itrace1_script_output "itraced = 5\r\n" set itrace2_script { global instrs = 0, itrace_on = 0, start_timer = 0 probe begin { start_timer = 1; printf("systemtap starting probe\n") } - probe process("%s").itrace if (itrace_on) + probe process("%s").insn if (itrace_on) { instrs += 1 if (instrs == 5) -- cgit From 422735b3ec857e812097566e28950aa3313892b4 Mon Sep 17 00:00:00 2001 From: Stan Cox Date: Fri, 20 Mar 2009 16:30:19 -0400 Subject: Define static user probe point using asm instead of c. * includes/sys/sdt.h (STAP_PROBE_DATA): New. Define the probe point using asm instead of c. (STAP_PROBEN): Use it. * testsuite/systemtap.base/sdt.exp: Continue if a compile fails. * testsuite/systemtap.base/static_uprobes.exp: Don't test setting probe without .probes section. --- testsuite/systemtap.base/sdt.exp | 6 ++++-- testsuite/systemtap.base/static_uprobes.exp | 12 ++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/sdt.exp b/testsuite/systemtap.base/sdt.exp index 21b94810..a398d795 100644 --- a/testsuite/systemtap.base/sdt.exp +++ b/testsuite/systemtap.base/sdt.exp @@ -27,7 +27,8 @@ set res [target_compile $srcdir/$subdir/$test.c $test.prog executable "$test_fla if { $res != "" } { verbose "target_compile failed: $res" 2 fail "compiling $test.c $extra_flag" - return + untested "$test $extra_flag" + continue } else { pass "compiling $test.c $extra_flag" } @@ -49,7 +50,8 @@ set res [target_compile $srcdir/$subdir/$test.c $test.prog executable "$test_fla if { $res != "" } { verbose "target_compile failed: $res" 2 fail "compiling $test.c c++ $extra_flag" - return + untested "$test $extra_flag" + continue } else { pass "compiling $test.c c++ $extra_flag" } diff --git a/testsuite/systemtap.base/static_uprobes.exp b/testsuite/systemtap.base/static_uprobes.exp index b4214436..e407440e 100644 --- a/testsuite/systemtap.base/static_uprobes.exp +++ b/testsuite/systemtap.base/static_uprobes.exp @@ -103,7 +103,11 @@ if {[installtest_p]} { set sdtdir $srcdir/../includes } -set sup_flags "additional_flags=-I$sdtdir additional_flags=-g additional_flags=-O additional_flags=-I." +set sup_flags "additional_flags=-I$srcdir/../includes/sys" +set sup_flags "$sup_flags additional_flags=-I$sdtdir" +set sup_flags "$sup_flags additional_flags=-g" +set sup_flags "$sup_flags additional_flags=-O" +set sup_flags "$sup_flags additional_flags=-I." set res [target_compile $sup_srcpath $sup_exepath executable $sup_flags] if { $res != "" } { verbose "target_compile failed: $res" 2 @@ -177,6 +181,10 @@ expect { wait -if {$ok == 5} { pass "$test C++" } { fail "$test C++ ($ok)" } +# we now generate the probes via asm so there is no label debug info +if {$ok == 5} { pass "$test C++" } { xfail "$test C++ ($ok)" } +if { $verbose == 0 } { catch {exec rm -f $sup_srcpath $sup_exepath $supcplus_exepath $sup_dpath $sup_hpath $sup_stppath} +} + -- cgit From a99eea4f68db917268b83ab75574c832b646bd65 Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Sat, 21 Mar 2009 08:39:57 -0400 Subject: sdt.exp: save intermediate sdt.h-client executables for analysis * testsuite/lib/stap_run2.exp (stap_run3): Put supplied stap extra arguments after the .stp script name, not before, so that @1/such arguments can be substituted within. --- testsuite/systemtap.base/sdt.exp | 14 +++++++++----- testsuite/systemtap.base/sdt.stp | 20 ++++++++++---------- 2 files changed, 19 insertions(+), 15 deletions(-) (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/sdt.exp b/testsuite/systemtap.base/sdt.exp index a398d795..46fa5a28 100644 --- a/testsuite/systemtap.base/sdt.exp +++ b/testsuite/systemtap.base/sdt.exp @@ -15,6 +15,7 @@ set extra_flags {{""} {additional_flags=-std=gnu89} {additional_flags=-ansi} {ad # Iterate extra_flags, trying each with C and C++ for {set i 0} {$i < [llength $extra_flags]} {incr i} { set extra_flag [lindex $extra_flags $i] +set testprog "sdt.c.exe.$i" # C set test_flags "additional_flags=-g" @@ -23,7 +24,9 @@ set test_flags "$test_flags additional_flags=-Wall" set test_flags "$test_flags additional_flags=-Wextra" set test_flags "$test_flags additional_flags=-Werror" -set res [target_compile $srcdir/$subdir/$test.c $test.prog executable "$test_flags $extra_flag"] +set saveidx 0 + +set res [target_compile $srcdir/$subdir/$test.c $testprog executable "$test_flags $extra_flag"] if { $res != "" } { verbose "target_compile failed: $res" 2 fail "compiling $test.c $extra_flag" @@ -34,19 +37,21 @@ if { $res != "" } { } if {[installtest_p]} { - stap_run3 "$test $extra_flag" $srcdir/$subdir/$test.stp -c ./$test.prog + stap_run3 "$test $extra_flag" $srcdir/$subdir/$test.stp $testprog -c ./$testprog } else { untested "$test $extra_flag" } # C++ +set testprog "sdt.cxx.exe.$i" + set test_flags "additional_flags=-g" set test_flags "$test_flags additional_flags=-I$srcdir/../includes/sys" set test_flags "$test_flags additional_flags=-Wall" set test_flags "$test_flags additional_flags=-Werror" set test_flags "$test_flags additional_flags=-x additional_flags=c++" -set res [target_compile $srcdir/$subdir/$test.c $test.prog executable "$test_flags $extra_flag"] +set res [target_compile $srcdir/$subdir/$test.c $testprog executable "$test_flags $extra_flag"] if { $res != "" } { verbose "target_compile failed: $res" 2 fail "compiling $test.c c++ $extra_flag" @@ -57,10 +62,9 @@ if { $res != "" } { } if {[installtest_p]} { - stap_run3 "$test c++ $extra_flag" $srcdir/$subdir/$test.stp -c ./$test.prog + stap_run3 "$test c++ $extra_flag" $srcdir/$subdir/$test.stp $testprog -c ./$testprog } else { untested "$test c++ $extra_flag" } } -catch {exec rm -f $test.prog} diff --git a/testsuite/systemtap.base/sdt.stp b/testsuite/systemtap.base/sdt.stp index 1f075bca..5df1fdc9 100644 --- a/testsuite/systemtap.base/sdt.stp +++ b/testsuite/systemtap.base/sdt.stp @@ -1,49 +1,49 @@ -probe process("sdt.prog").mark("mark_a") +probe process(@1).mark("mark_a") { printf("%d\n", $arg1); } -probe process("sdt.prog").mark("mark_b") +probe process(@1).mark("mark_b") { printf("%d %d\n", $arg1, $arg2); } -probe process("sdt.prog").mark("mark_c") +probe process(@1).mark("mark_c") { printf("%d %d %d\n", $arg1, $arg2, $arg3); } -probe process("sdt.prog").mark("mark_d") +probe process(@1).mark("mark_d") { printf("%d %d %d %d\n", $arg1, $arg2, $arg3, $arg4); } -probe process("sdt.prog").mark("mark_e") +probe process(@1).mark("mark_e") { printf("%d %d %d %d %d\n", $arg1, $arg2, $arg3, $arg4, $arg5); } -probe process("sdt.prog").mark("mark_f") +probe process(@1).mark("mark_f") { printf("%d %d %d %d %d %d\n", $arg1, $arg2, $arg3, $arg4, $arg5, $arg6); } -probe process("sdt.prog").mark("mark_g") +probe process(@1).mark("mark_g") { printf("%d %d %d %d %d %d %d\n", $arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7); } -probe process("sdt.prog").mark("mark_h") +probe process(@1).mark("mark_h") { printf("%d %d %d %d %d %d %d %d\n", $arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7, $arg8); } -probe process("sdt.prog").mark("mark_i") +probe process(@1).mark("mark_i") { printf("%d %d %d %d %d %d %d %d %d\n", $arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7, $arg8, $arg9); } -probe process("sdt.prog").mark("mark_j") +probe process(@1).mark("mark_j") { printf("%d %d %d %d %d %d %d %d %d %d\n", $arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7, $arg8, $arg9, $arg10); } -- cgit From 3c1b3d06ef3134b30e804d189d346c5f83c6f3a6 Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Tue, 24 Mar 2009 12:53:17 -0400 Subject: PR9993: tracepoint toleration for undeclared types in trace/*.h headers * tapsets.cxx (tracepoint_extra_headers): New function to return needed header file names. (emit_module_decls): Emit them. * buildrun.cxx (make_tracequery): Emit them. * testsuite/systemtap.base/tracepoints.exp: Rewrite to exercise building each tracepoint. --- testsuite/systemtap.base/tracepoints.exp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/tracepoints.exp b/testsuite/systemtap.base/tracepoints.exp index bea461c4..cd033908 100644 --- a/testsuite/systemtap.base/tracepoints.exp +++ b/testsuite/systemtap.base/tracepoints.exp @@ -1,3 +1,26 @@ + +set tracepoints {} +spawn stap -l {kernel.trace("*")} +expect { + -re {^kernel.trace[^\r\n]*\r\n} { + append tracepoints $expect_out(0,string) + exp_continue + } + timeout {} + eof {} +} +catch {close}; catch { wait } + +foreach tp $tracepoints { + set test "tracepoint $tp -p4" + if {[catch {exec stap -w -p4 -e "probe $tp {}"} res]} { + fail "$test $res" + } else { + pass "$test" + } +} + set test "tracepoints" +if {![installtest_p]} { untested $test; return } set ::result_string {tracepoints OK} stap_run2 $srcdir/$subdir/$test.stp -- cgit From b84e888167b9ecc22497730078759ee3a7c4914e Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Tue, 24 Mar 2009 21:37:30 +0100 Subject: Add testcase for uprobe on shared library (PR9940). * testsuite/systemtap.base/uprobes_exe.c: New file. * testsuite/systemtap.base/uprobes_lib.c: New file. * testsuite/systemtap.base/uprobes_lib.exp: New file. * testsuite/systemtap.base/uprobes_lib.stp: New file. --- testsuite/systemtap.base/uprobes_exe.c | 27 +++++++++++++++++++++++ testsuite/systemtap.base/uprobes_lib.c | 20 +++++++++++++++++ testsuite/systemtap.base/uprobes_lib.exp | 38 ++++++++++++++++++++++++++++++++ testsuite/systemtap.base/uprobes_lib.stp | 9 ++++++++ 4 files changed, 94 insertions(+) create mode 100644 testsuite/systemtap.base/uprobes_exe.c create mode 100644 testsuite/systemtap.base/uprobes_lib.c create mode 100644 testsuite/systemtap.base/uprobes_lib.exp create mode 100644 testsuite/systemtap.base/uprobes_lib.stp (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/uprobes_exe.c b/testsuite/systemtap.base/uprobes_exe.c new file mode 100644 index 00000000..447434c6 --- /dev/null +++ b/testsuite/systemtap.base/uprobes_exe.c @@ -0,0 +1,27 @@ +/* uprobes_lib test case + * Copyright (C) 2009, Red Hat Inc. + * + * This file is part of systemtap, and is free software. You can + * redistribute it and/or modify it under the terms of the GNU General + * Public License (GPL); either version 2, or (at your option) any + * later version. + */ + +#include + +// function from our library +int lib_main (void); + +void +main_func (int foo) +{ + ; // nothing here... +} + +int +main (int argc, char *argv[], char *envp[]) +{ + main_func(1); + lib_main(); + return 0; +} diff --git a/testsuite/systemtap.base/uprobes_lib.c b/testsuite/systemtap.base/uprobes_lib.c new file mode 100644 index 00000000..c9d70625 --- /dev/null +++ b/testsuite/systemtap.base/uprobes_lib.c @@ -0,0 +1,20 @@ +/* uprobes_lib test case - library helper + * Copyright (C) 2009, Red Hat Inc. + * + * This file is part of systemtap, and is free software. You can + * redistribute it and/or modify it under the terms of the GNU General + * Public License (GPL); either version 2, or (at your option) any + * later version. + */ + +void +lib_func (int bar) +{ + ; // nothing here... +} + +void +lib_main () +{ + lib_func (3); +} diff --git a/testsuite/systemtap.base/uprobes_lib.exp b/testsuite/systemtap.base/uprobes_lib.exp new file mode 100644 index 00000000..ae1b72e8 --- /dev/null +++ b/testsuite/systemtap.base/uprobes_lib.exp @@ -0,0 +1,38 @@ +set test "uprobes_lib" +set testpath "$srcdir/$subdir" +set testsrc "$testpath/uprobes_exe.c" +set testsrclib "$testpath/uprobes_lib.c" +set testexe "./uprobes_exe" +set testlibname "uprobes_lib" +set testlibdir "." +set testso "$testlibdir/lib${testlibname}.so" +set testflags "additional_flags=-g additional_flags=-O" +set testlibflags "$testflags additional_flags=-fPIC additional_flags=-shared" +set maintestflags "$testflags additional_flags=-L$testlibdir additional_flags=-l$testlibname additional_flags=-Wl,-rpath,$testlibdir" + +# Only run on make installcheck +if {! [installtest_p]} { untested "$test"; return } + +# Compile our test program and library. +set res [target_compile $testsrclib $testso executable $testlibflags] +if { $res != "" } { + verbose "target_compile for $testso failed: $res" 2 + fail "unable to compile $testsrclib" + return +} +set res [target_compile $testsrc $testexe executable $maintestflags] +if { $res != "" } { + verbose "target_compile failed: $res" 2 + fail "unable to compile $testsrc" + return +} + +# XXX main_func needs another/extra test. Disabled for now. +# Enable (and in uprobes_lib.stp) after PR9940 is fixed. +# set ::result_string {main_func +# lib_func} +set ::result_string {lib_func} + +stap_run2 $srcdir/$subdir/$test.stp -c $testexe + +#exec rm -f $testexe $testso diff --git a/testsuite/systemtap.base/uprobes_lib.stp b/testsuite/systemtap.base/uprobes_lib.stp new file mode 100644 index 00000000..bc6cc249 --- /dev/null +++ b/testsuite/systemtap.base/uprobes_lib.stp @@ -0,0 +1,9 @@ +/* - Not activated probe... Seems always skipped? +probe process("uprobes_exe").function("main_func") { + printf("main_func\n"); +} +*/ + +probe process("libuprobes_lib.so").function("lib_func") { + printf("lib_func\n"); +} -- cgit From 267a544424be10825c57ea3eaa4d908c818211c7 Mon Sep 17 00:00:00 2001 From: Stan Cox Date: Mon, 30 Mar 2009 10:23:27 -0400 Subject: Test marker probe parameter types. * testsuite/systemtap.base/sdt_types.c: New file. * testsuite/systemtap.base/sdt_types.stp: New file. * testsuite/systemtap.base/static_uprobes.exp: Use sdt_types for type testing. --- testsuite/systemtap.base/sdt_types.c | 168 +++++++++++++ testsuite/systemtap.base/sdt_types.stp | 371 ++++++++++++++++++++++++++++ testsuite/systemtap.base/static_uprobes.exp | 47 ++-- 3 files changed, 561 insertions(+), 25 deletions(-) create mode 100644 testsuite/systemtap.base/sdt_types.c create mode 100644 testsuite/systemtap.base/sdt_types.stp (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/sdt_types.c b/testsuite/systemtap.base/sdt_types.c new file mode 100644 index 00000000..2e04ec7e --- /dev/null +++ b/testsuite/systemtap.base/sdt_types.c @@ -0,0 +1,168 @@ +#include "sdt.h" /* Really , but pick current source version. */ +#include +#include + +int +main (int argc, char **argv) +{ + char char_var = '~'; + STAP_PROBE1(provider,char_var,char_var); + const char const_char_var = '!'; + STAP_PROBE1(provider,const_char_var,const_char_var); + volatile char volatile_char_var = '!'; + STAP_PROBE1(provider,volatile_char_var,volatile_char_var); + char *ptr_char_var = &char_var; + STAP_PROBE2(provider,ptr_char_var,ptr_char_var,&char_var); + const char *ptr_const_char_var = &char_var; + STAP_PROBE2(provider,ptr_const_char_var,ptr_const_char_var,&char_var); + char * const char_ptr_const_var = &char_var; + STAP_PROBE2(provider,char_ptr_const_var,char_ptr_const_var,&char_var); + volatile char *ptr_volatile_char_var = &char_var; + STAP_PROBE2(provider,ptr_volatile_char_var,ptr_volatile_char_var,&char_var); + char * volatile char_ptr_volatile_var = &char_var; + STAP_PROBE2(provider,char_ptr_volatile_var,char_ptr_volatile_var,&char_var); + short int short_int_var = 32767; + STAP_PROBE1(provider,short_int_var,short_int_var); + const short int const_short_int_var = -32767; + STAP_PROBE1(provider,const_short_int_var,const_short_int_var); + volatile short int volatile_short_int_var = -32767; + STAP_PROBE1(provider,volatile_short_int_var,volatile_short_int_var); + short int *ptr_short_int_var = &short_int_var; + STAP_PROBE2(provider,ptr_short_int_var,ptr_short_int_var,&short_int_var); + const short int *ptr_const_short_int_var = &short_int_var; + STAP_PROBE2(provider,ptr_const_short_int_var,ptr_const_short_int_var,&short_int_var); + short int * const short_int_ptr_const_var = &short_int_var; + STAP_PROBE2(provider,short_int_ptr_const_var,short_int_ptr_const_var,&short_int_var); + volatile short int *ptr_volatile_short_int_var = &short_int_var; + STAP_PROBE2(provider,ptr_volatile_short_int_var,ptr_volatile_short_int_var,&short_int_var); + short int * volatile short_int_ptr_volatile_var = &short_int_var; + STAP_PROBE2(provider,short_int_ptr_volatile_var,short_int_ptr_volatile_var,&short_int_var); + int int_var = 65536; + STAP_PROBE1(provider,int_var,int_var); + const int const_int_var = -65536; + STAP_PROBE1(provider,const_int_var,const_int_var); + volatile int volatile_int_var = -65536; + STAP_PROBE1(provider,volatile_int_var,volatile_int_var); + int *ptr_int_var = &int_var; + STAP_PROBE2(provider,ptr_int_var,ptr_int_var,&int_var); + const int *ptr_const_int_var = &int_var; + STAP_PROBE2(provider,ptr_const_int_var,ptr_const_int_var,&int_var); + int * const int_ptr_const_var = &int_var; + STAP_PROBE2(provider,int_ptr_const_var,int_ptr_const_var,&int_var); + volatile int *ptr_volatile_int_var = &int_var; + STAP_PROBE2(provider,ptr_volatile_int_var,ptr_volatile_int_var,&int_var); + int * volatile int_ptr_volatile_var = &int_var; + STAP_PROBE2(provider,int_ptr_volatile_var,int_ptr_volatile_var,&int_var); + long int long_int_var = 65536; + STAP_PROBE1(provider,long_int_var,long_int_var); + const long int const_long_int_var = -65536; + STAP_PROBE1(provider,const_long_int_var,const_long_int_var); + volatile long int volatile_long_int_var = -65536; + STAP_PROBE1(provider,volatile_long_int_var,volatile_long_int_var); + long int *ptr_long_int_var = &long_int_var; + STAP_PROBE2(provider,ptr_long_int_var,ptr_long_int_var,&long_int_var); + const long int *ptr_const_long_int_var = &long_int_var; + STAP_PROBE2(provider,ptr_const_long_int_var,ptr_const_long_int_var,&long_int_var); + long int * const long_int_ptr_const_var = &long_int_var; + STAP_PROBE2(provider,long_int_ptr_const_var,long_int_ptr_const_var,&long_int_var); + volatile long int *ptr_volatile_long_int_var = &long_int_var; + STAP_PROBE2(provider,ptr_volatile_long_int_var,ptr_volatile_long_int_var,&long_int_var); + long int * volatile long_int_ptr_volatile_var = &long_int_var; + STAP_PROBE2(provider,long_int_ptr_volatile_var,long_int_ptr_volatile_var,&long_int_var); + long long int long_long_int_var = 65536; + STAP_PROBE1(provider,long_long_int_var,long_long_int_var); + const long long int const_long_long_int_var = -65536; + STAP_PROBE1(provider,const_long_long_int_var,const_long_long_int_var); + volatile long long int volatile_long_long_int_var = -65536; + STAP_PROBE1(provider,volatile_long_long_int_var,volatile_long_long_int_var); + long long int *ptr_long_long_int_var = &long_long_int_var; + STAP_PROBE2(provider,ptr_long_long_int_var,ptr_long_long_int_var,&long_long_int_var); + const long long int *ptr_const_long_long_int_var = &long_long_int_var; + STAP_PROBE2(provider,ptr_const_long_long_int_var,ptr_const_long_long_int_var,&long_long_int_var); + long long int * const long_long_int_ptr_const_var = &long_long_int_var; + STAP_PROBE2(provider,long_long_int_ptr_const_var,long_long_int_ptr_const_var,&long_long_int_var); + volatile long long int *ptr_volatile_long_long_int_var = &long_long_int_var; + STAP_PROBE2(provider,ptr_volatile_long_long_int_var,ptr_volatile_long_long_int_var,&long_long_int_var); + long long int * volatile long_long_int_ptr_volatile_var = &long_long_int_var; + STAP_PROBE2(provider,long_long_int_ptr_volatile_var,long_long_int_ptr_volatile_var,&long_long_int_var); + + char arr_char [2] = "!~"; + STAP_PROBE1(provider,arr_char,&arr_char); + struct { + int int_var; + } arr_struct [2] = {{ + .int_var=1, + },{ + .int_var=2, + }}; + STAP_PROBE1(provider,arr_struct,&arr_struct); + struct { + unsigned int bit1_0:1; + unsigned int bit1_1:1; + char char_2; + unsigned int bit1_6:1; + unsigned int bit1_7:1; + char char_8; + unsigned int bit1_9:1; + unsigned int bit1_10:1; + } bitfields_small_var = { + .bit1_0=1, + .bit1_1=0, + .char_2='a', + .bit1_6=1, + .bit1_7=0, + .char_8='z', + .bit1_9=1, + .bit1_10=0, + }; + STAP_PROBE8(provider,bitfields_small_var, + (int)bitfields_small_var.bit1_0, + (int)bitfields_small_var.bit1_1, + bitfields_small_var.char_2, + (int)bitfields_small_var.bit1_6, + (int)bitfields_small_var.bit1_7, + bitfields_small_var.char_8, + (int)bitfields_small_var.bit1_9, + (int)bitfields_small_var.bit1_10); + struct { + unsigned char char_0; + int bit1_4:1; + unsigned int bit1_5:1; + int bit2_6:2; + unsigned int bit2_8:2; + int bit3_10:3; + unsigned int bit3_13:3; + int bit9_16:9; + unsigned int bit9_25:9; + char char_34; + } bitfields_bit_var = { + .char_0='A', + .bit1_4=-1, + .bit1_5=1, + .bit2_6=1, + .bit2_8=3, + .bit3_10=3, + .bit3_13=7, + .bit9_16=255, + .bit9_25=511, + .char_34='Z', + }; + STAP_PROBE10(provider,bitfields_bit_var,bitfields_bit_var.char_0, + (int)bitfields_bit_var.bit1_4, + (int)bitfields_bit_var.bit1_5, + (int)bitfields_bit_var.bit2_6, + (int)bitfields_bit_var.bit2_8, + (int)bitfields_bit_var.bit3_10, + (int)bitfields_bit_var.bit3_13, + (int)bitfields_bit_var.bit9_16, + (int)bitfields_bit_var.bit9_25, + bitfields_bit_var.char_34); + enum { + red = 0, + green = 1, + blue = 2 + } primary_colors_var = green; + STAP_PROBE1(provider,primary_colors_var,primary_colors_var); + return 0; +} + diff --git a/testsuite/systemtap.base/sdt_types.stp b/testsuite/systemtap.base/sdt_types.stp new file mode 100644 index 00000000..654b0d18 --- /dev/null +++ b/testsuite/systemtap.base/sdt_types.stp @@ -0,0 +1,371 @@ +probe process(@1).mark("char_var") { + if ($arg1 != 126) + printf("FAIL: char_var\n") + else + printf("PASS: char_var\n") +} + +probe process(@1).mark("const_char_var") { + if ($arg1 != 33) + printf("FAIL: const_char_var\n") + else + printf("PASS: const_char_var\n") +} + +probe process(@1).mark("volatile_char_var") { + if ($arg1 != 33) + printf("FAIL: volatile_char_var\n") + else + printf("PASS: volatile_char_var\n") +} + +probe process(@1).mark("ptr_char_var") { + if ($arg1 != $arg2) + printf("FAIL: ptr_char_var\n") + else + printf("PASS: ptr_char_var\n") +} + +probe process(@1).mark("ptr_const_char_var") +{ + if ($arg1 != $arg2) + printf("FAIL: ptr_const_char_var\n") + else + printf("PASS: ptr_const_char_var\n") +} + +probe process(@1).mark("char_ptr_const_var") +{ + if ($arg1 != $arg2) + printf("FAIL: char_ptr_const_var\n") + else + printf("PASS: char_ptr_const_var\n") +} + +probe process(@1).mark("ptr_volatile_char_var") +{ + if ($arg1 != $arg2) + printf("FAIL: ptr_volatile_char_var\n") + else + printf("PASS: ptr_volatile_char_var\n") +} + +probe process(@1).mark("char_ptr_volatile_var") +{ + if ($arg1 != $arg2) + printf("FAIL: char_ptr_volatile_var\n") + else + printf("PASS: char_ptr_volatile_var\n") +} + +probe process(@1).mark("short_int_var") +{ + if ($arg1 != 32767) + printf("FAIL: short_int_var\n") + else + printf("PASS: short_int_var\n") +} + +probe process(@1).mark("const_short_int_var") +{ + if ($arg1 != -32767) + printf("FAIL: const_short_int_var\n") + else + printf("PASS: const_short_int_var\n") +} + +probe process(@1).mark("volatile_short_int_var") +{ + if ($arg1 != -32767) + printf("FAIL: volatile_short_int_var\n") + else + printf("PASS: volatile_short_int_var\n") +} + +probe process(@1).mark("ptr_short_int_var") +{ + if ($arg1 != $arg2) + printf("FAIL: ptr_short_int_var\n") + else + printf("PASS: ptr_short_int_var\n") +} + +probe process(@1).mark("ptr_const_short_int_var") +{ + if ($arg1 != $arg2) + printf("FAIL: ptr_const_short_int_var\n") + else + printf("PASS: ptr_const_short_int_var\n") +} + +probe process(@1).mark("short_int_ptr_const_var") +{ + if ($arg1 != $arg2) + printf("FAIL: short_int_ptr_const_var\n") + else + printf("PASS: short_int_ptr_const_var\n") +} + +probe process(@1).mark("ptr_volatile_short_int_var") +{ + if ($arg1 != $arg2) + printf("FAIL: ptr_volatile_short_int_var\n") + else + printf("PASS: ptr_volatile_short_int_var\n") +} + +probe process(@1).mark("short_int_ptr_volatile_var") +{ + if ($arg1 != $arg2) + printf("FAIL: short_int_ptr_volatile_var\n") + else + printf("PASS: short_int_ptr_volatile_var\n") +} + +probe process(@1).mark("int_var") +{ + if ($arg1 != 65536) + printf("FAIL: int_var") + else + printf("PASS: int_var") +} + +probe process(@1).mark("const_int_var") +{ + if ($arg1 != -65536) + printf("FAIL: const_int_var\n") + else + printf("PASS: const_int_var\n") +} + +probe process(@1).mark("volatile_int_var") +{ + if ($arg1 != -65536) + printf("FAIL: volatile_int_var\n") + else + printf("PASS: volatile_int_var\n") +} + +probe process(@1).mark("ptr_int_var") +{ + if ($arg1 != $arg2) + printf("FAIL: ptr_const_int_var\n") + else + printf("PASS: ptr_const_int_var\n") +} + +probe process(@1).mark("ptr_const_int_var") +{ + if ($arg1 != $arg2) + printf("FAIL: ptr_const_int_var\n") + else + printf("PASS: ptr_const_int_var\n") +} + +probe process(@1).mark("int_ptr_const_var") +{ + if ($arg1 != $arg2) + printf("FAIL: int_ptr_const_var\n") + else + printf("PASS: int_ptr_const_var\n") +} + +probe process(@1).mark("ptr_volatile_int_var") +{ + if ($arg1 != $arg2) + printf("FAIL: ptr_volatile_int_var\n") + else + printf("PASS: ptr_volatile_int_var\n") +} + +probe process(@1).mark("int_ptr_volatile_var") +{ + if ($arg1 != $arg2) + printf("FAIL: int_ptr_volatile_var\n") + else + printf("PASS: int_ptr_volatile_var\n") +} + +probe process(@1).mark("long_int_var") +{ + if ($arg1 != 65536) + printf("FAIL: long_int_var\n") + else + printf("PASS: long_int_var\n") +} + +probe process(@1).mark("const_long_int_var") +{ + if ($arg1 != -65536) + printf("FAIL: const_long_int_var\n") + else + printf("PASS: const_long_int_var\n") +} + +probe process(@1).mark("volatile_long_int_var") +{ + if ($arg1 != -65536) + printf("FAIL: volatile_long_int_var\n") + else + printf("PASS: volatile_long_int_var\n") +} + +probe process(@1).mark("ptr_long_int_var") +{ + if ($arg1 != $arg2) + printf("FAIL: ptr_long_int_var\n") + else + printf("PASS: ptr_long_int_var\n") +} + +probe process(@1).mark("ptr_const_long_int_var") +{ + if ($arg1 != $arg2) + printf("FAIL: ptr_const_long_int_var\n") + else + printf("PASS: ptr_const_long_int_var\n") +} + +probe process(@1).mark("long_int_ptr_const_var") +{ + if ($arg1 != $arg2) + printf("FAIL: long_int_ptr_const_var\n") + else + printf("PASS: long_int_ptr_const_var\n") +} + +probe process(@1).mark("ptr_volatile_long_int_var") +{ + if ($arg1 != $arg2) + printf("FAIL: ptr_volatile_long_int_var\n") + else + printf("PASS: ptr_volatile_long_int_var\n") +} + +probe process(@1).mark("long_int_ptr_volatile_var") +{ + if ($arg1 != $arg2) + printf("FAIL: long_int_ptr_volatile_var\n") + else + printf("PASS: long_int_ptr_volatile_var\n") +} + +probe process(@1).mark("long_long_int_var") +{ + if ($arg1 != 65536) + printf("FAIL: long_long_int_var\n") + else + printf("PASS: long_long_int_var\n") +} + +probe process(@1).mark("const_long_long_int_var") +{ + if ($arg1 != -65536) + printf("FAIL: const_long_long_int_var\n") + else + printf("PASS: const_long_long_int_var\n") +} + +probe process(@1).mark("volatile_long_long_int_var") +{ + if ($arg1 != -65536) + printf("FAIL: volatile_long_long_int_var\n") + else + printf("PASS: volatile_long_long_int_var\n") +} + +probe process(@1).mark("ptr_long_long_int_var") +{ + if ($arg1 != $arg2) + printf("FAIL: ptr_long_long_int_var\n") + else + printf("PASS: ptr_long_long_int_var\n") +} + +probe process(@1).mark("ptr_const_long_long_int_var") +{ + if ($arg1 != $arg2) + printf("FAIL: ptr_const_long_long_int_var\n") + else + printf("PASS: ptr_const_long_long_int_var\n") +} + +probe process(@1).mark("long_long_int_ptr_const_var") +{ + if ($arg1 != $arg2) + printf("FAIL: long_long_int_ptr_const_var\n") + else + printf("PASS: long_long_int_ptr_const_var\n") +} + +probe process(@1).mark("ptr_volatile_long_long_int_var") +{ + if ($arg1 != $arg2) + printf("FAIL: ptr_volatile_long_long_int_var\n") + else + printf("PASS: ptr_volatile_long_long_int_var\n") +} + +probe process(@1).mark("long_long_int_ptr_volatile_var") +{ + if ($arg1 != $arg2) + printf("FAIL: long_long_int_ptr_volatile_var\n") + else + printf("PASS: long_long_int_ptr_volatile_var\n") +} + +probe process(@1).mark("arr_char") +{ + arr_char = user_string ($arg1); + if (arr_char != "!~") + printf("FAIL: arr_char_var\n") + else + printf("PASS: arr_char_var\n") +} + +probe process(@1).mark("arr_struct") +{ + arr_struct_int_var = user_int ($arg1) + if (arr_struct_int_var != 1) + printf("FAIL: arr_struct_var\n") + else + printf("PASS: arr_struct_var\n") +} + +probe process(@1).mark("bitfields_small_var") +{ + if ($arg1 != 1 || $arg2 != 0 || $arg3 != 97 || $arg4 != 1 + || $arg5 != 0 || $arg6 != 122 || $arg7 != 1 || $arg8 != 0) + printf("FAIL: bitfields_small_var\n") + +} + +probe process(@1).mark("bitfields_bit_var") +{ + if ($arg1 != 65 || $arg2 != -1 || $arg3 != 1 || $arg4 != 1 + || $arg5 != 3 || $arg6 != 3 || $arg7 != 7 || $arg8 != 255 + || $arg9 != 511 || $arg10 != 90) + printf("FAIL: bitfields_bit_var\n") + else + printf("PASS: bitfields_bit_var\n") +} + + +probe process(@1).mark("primary_colors_var") +{ + if ($arg1 != 1) + printf("FAIL: primary_colors_var\n") + else + printf("PASS: primary_colors_var\n") +} + + + + + + + + + + + diff --git a/testsuite/systemtap.base/static_uprobes.exp b/testsuite/systemtap.base/static_uprobes.exp index e407440e..620d5576 100644 --- a/testsuite/systemtap.base/static_uprobes.exp +++ b/testsuite/systemtap.base/static_uprobes.exp @@ -118,17 +118,6 @@ if { $res != "" } { pass "$test compiling C -g" } -set sup_flags "$sup_flags additional_flags=-x additional_flags=c++" -set res [target_compile $sup_srcpath $supcplus_exepath executable $sup_flags] -if { $res != "" } { - verbose "target_compile failed: $res" 2 - fail "$test compiling C++ -g" - catch {exec rm -f $sup_srcpath $sup_exepath $sup_hpath $sup_stppath} - return -} else { - pass "$test compiling C++ -g" -} - if {![installtest_p]} {untested $test; return} # Try to find utrace_attach symbol in /proc/kallsyms @@ -162,29 +151,37 @@ wait if {$ok == 5} { pass "$test C" } { fail "$test C ($ok)" } -set ok 0 +set sup_flags "$sup_flags additional_flags=-O0" +set res [target_compile $srcdir/$subdir/sdt_types.c sdt_types.x executable $sup_flags] +if { $res != "" } { + verbose "target_compile failed: $res" 2 + fail "$test compiling -g" + return +} else { + pass "$test compiling -g" +} -# Test setting a probe without .probes using only dwarf label info -verbose -log "objcopy -R .probes $supcplus_exepath $sup_exepath" -spawn objcopy -R .probes $supcplus_exepath $sup_exepath -verbose -log "spawn stap -c $sup_exepath $sup_stppath" -spawn stap -c $sup_exepath $sup_stppath +set ok 0 +set fail "types" +verbose -log "spawn stap -c ./sdt_types.x $srcdir/$subdir/sdt_types.stp ./sdt_types.x" +spawn stap -c ./sdt_types.x $srcdir/$subdir/sdt_types.stp ./sdt_types.x expect { -timeout 180 - -re {In test_probe_2 probe 0x2} { incr ok; exp_continue } - -re {In test_probe_0 probe 0x3} { incr ok; exp_continue } - -re {In test_probe_3 probe 0x3 0x[0-9a-f][0-9a-f]} { incr ok; exp_continue } - -re {In test_probe_4 dtrace probe 0x4} { incr ok; exp_continue } - timeout { fail "$test C++ (timeout)" } + -re {FAIL: [a-z_]+var} { regexp " .*$" $expect_out(0,string) s; + incr ok; set fail "$fail $s"; exp_continue } + timeout { fail "$test C (timeout)" } eof { } } wait -# we now generate the probes via asm so there is no label debug info -if {$ok == 5} { pass "$test C++" } { xfail "$test C++ ($ok)" } +if { $ok != 0 } { + fail $fail +} else { + pass types +} if { $verbose == 0 } { -catch {exec rm -f $sup_srcpath $sup_exepath $supcplus_exepath $sup_dpath $sup_hpath $sup_stppath} +catch {exec rm -f $sup_srcpath $sup_exepath $supcplus_exepath $sup_dpath $sup_hpath $sup_stppath sdt_types.x} } -- cgit From bd0b450c6327b1666385f4e5fb5d23382cbffc86 Mon Sep 17 00:00:00 2001 From: Wenji Huang Date: Mon, 30 Mar 2009 17:29:20 -0400 Subject: PR9998: new config and test files * runtime/autoconf-x86-gs.c : New file. * testsuite/systemtap.base/x86_gs.exp : New test case. * testsuite/systemtap.base/x86_gs.stp : Ditto. --- testsuite/systemtap.base/x86_gs.exp | 12 ++++++++++++ testsuite/systemtap.base/x86_gs.stp | 10 ++++++++++ 2 files changed, 22 insertions(+) create mode 100644 testsuite/systemtap.base/x86_gs.exp create mode 100644 testsuite/systemtap.base/x86_gs.stp (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/x86_gs.exp b/testsuite/systemtap.base/x86_gs.exp new file mode 100644 index 00000000..98ab3051 --- /dev/null +++ b/testsuite/systemtap.base/x86_gs.exp @@ -0,0 +1,12 @@ +set test "x86_gs" +if {![installtest_p]} { untested $test; return } +set arch [exec uname -m] +if {$arch!="i686"} { untested $test; return } +spawn stap $srcdir/$subdir/x86_gs.stp +expect { + -timeout 60 + -re "0\r\n" { pass $test } + -re "140\r\n" { pass $test } + eof { fail $test } + timeout { fail "$test unexpected timeout" } +} diff --git a/testsuite/systemtap.base/x86_gs.stp b/testsuite/systemtap.base/x86_gs.stp new file mode 100644 index 00000000..68b58512 --- /dev/null +++ b/testsuite/systemtap.base/x86_gs.stp @@ -0,0 +1,10 @@ +#! stap + +# test x86 gs register + +probe begin { + if (!_stp_regs_registered) + _stp_register_regs() + printf("%d\n",test_x86_gs() * 100 + _reg_offsets["gs"]) /* 0 or 140 */ + exit() +} -- cgit From c5746f91b1ba8f374b4230e16cb33e1b9206ca2b Mon Sep 17 00:00:00 2001 From: Stan Cox Date: Tue, 31 Mar 2009 11:54:26 -0400 Subject: Customize .mark -l output. * tapsets.cxx (dwarf_builder::build): Add .mark name wildcard check. Customize -l handling. * testsuite/systemtap.base/static_uprobes.exp: Test .mark name wildcard. --- testsuite/systemtap.base/static_uprobes.exp | 38 ++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 6 deletions(-) (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/static_uprobes.exp b/testsuite/systemtap.base/static_uprobes.exp index 620d5576..820626b8 100644 --- a/testsuite/systemtap.base/static_uprobes.exp +++ b/testsuite/systemtap.base/static_uprobes.exp @@ -1,5 +1,7 @@ set test "static_uprobes" +# Test miscellaneous features of .mark probes + # Compile a C program to use as the user-space probing target set sup_srcpath "[pwd]/static_uprobes.c" set sup_exepath "[pwd]/static_uprobes.x" @@ -80,6 +82,9 @@ provider static_uprobes { }; " close $fp + +# Test dtrace + if {[installtest_p]} { set dtrace $env(SYSTEMTAP_PATH)/dtrace } else { @@ -90,9 +95,9 @@ if {[catch {exec $dtrace -h -s $sup_dpath} res]} { } catch {exec rm -f $sup_dpath} if {[file exists $sup_hpath]} then { - pass "$test generating header" + pass "$test dtrace" } else { - fail "$test generating header" + fail "$test dtrace" catch {exec rm -f $sup_srcpath $sup_hpath $sup_stppath} return } @@ -133,6 +138,8 @@ if {$utrace_support_found == 0} { return } +# Run stap on executable built with dtrace generated header file + set ok 0 verbose -log "spawn stap -c $sup_exepath $sup_stppath" @@ -151,14 +158,16 @@ wait if {$ok == 5} { pass "$test C" } { fail "$test C ($ok)" } +# Test passing various C types to .mark probes + set sup_flags "$sup_flags additional_flags=-O0" set res [target_compile $srcdir/$subdir/sdt_types.c sdt_types.x executable $sup_flags] if { $res != "" } { verbose "target_compile failed: $res" 2 - fail "$test compiling -g" + fail "$test compiling types -g" return } else { - pass "$test compiling -g" + pass "$test compiling types -g" } set ok 0 @@ -176,9 +185,26 @@ expect { wait if { $ok != 0 } { - fail $fail + fail "$test $fail" +} else { + pass "$test types" +} + +# Test .mark probe wildcard matching + +set ok 0 +spawn stap -l "process(\"./sdt_types.x\").mark(\"*\")" +expect { + -timeout 180 + -re {mark\(\".*\"\)} { incr ok; exp_continue } + timeout { fail "$test C (timeout)" } + eof { } +} + +if { $ok == 45 } { + pass "$test wildcard" } else { - pass types + fail "$test wildcard ($ok)" } if { $verbose == 0 } { -- cgit From 952ce18c9672046c052fc77d5da8f98e8ae75735 Mon Sep 17 00:00:00 2001 From: Stan Cox Date: Wed, 1 Apr 2009 15:48:24 -0400 Subject: Use alloca trick to keep argN active on GCC 4.1. * includes/sys/sdt.h (STAP_UNINLINE): New. (STAP_UNINLINE_LABEL): New. static_uprobes.exp: Match using charset instead of .* --- testsuite/systemtap.base/static_uprobes.exp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/static_uprobes.exp b/testsuite/systemtap.base/static_uprobes.exp index 820626b8..d6b6e1e3 100644 --- a/testsuite/systemtap.base/static_uprobes.exp +++ b/testsuite/systemtap.base/static_uprobes.exp @@ -196,7 +196,7 @@ set ok 0 spawn stap -l "process(\"./sdt_types.x\").mark(\"*\")" expect { -timeout 180 - -re {mark\(\".*\"\)} { incr ok; exp_continue } + -re {mark\(\"[a-z_]+\"\)} { incr ok; exp_continue } timeout { fail "$test C (timeout)" } eof { } } -- cgit From 055f682bed95348cabb20868d62c4e575b84d02a Mon Sep 17 00:00:00 2001 From: Maynard Johnson Date: Wed, 1 Apr 2009 11:22:53 -0500 Subject: Add insn.block testcase to itrace.exp in testsuite Earlier today, I posted a runtime patch for the insn.block probe point. Once that patch is committed, the insn.block probe can be safely tested on any architecture. The attached patch adds such a testcase to the testsuite. Regards, -Maynard --- testsuite/systemtap.base/itrace.exp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/itrace.exp b/testsuite/systemtap.base/itrace.exp index e215bfe7..d330a337 100644 --- a/testsuite/systemtap.base/itrace.exp +++ b/testsuite/systemtap.base/itrace.exp @@ -48,6 +48,27 @@ set itrace2_script { } set itrace2_script_output "itraced = 5\r\n" +set itrace3_script { + global branches = 0 + probe begin + { + printf("systemtap starting probe\n") + printf("ATTENTION: if arch_has_block_step is not defined for this arch, this testcase will fail\n") + } + probe process("%s").insn.block + { + branches += 1 + if (branches == 5) + exit() + } + + + probe end { printf("systemtap ending probe\n") + printf("itraced block mode = %%d\n", branches) + } +} +set itrace3_script_output "itraced block mode = 5\r\n" + # Set up our own copy of /bin/ls, to make testing for a particular # executable easy. We can't use 'ln' here, since we might be creating @@ -99,5 +120,15 @@ if {$utrace_support_found == 0} { stap_run $TEST_NAME run_ls_5_sec $itrace2_script_output -e $script } +set TEST_NAME "itrace3" +if {$utrace_support_found == 0} { + untested "$TEST_NAME : no kernel utrace support found" +} elseif {![installtest_p]} { + untested $TEST_NAME +} else { + set script [format $itrace3_script $exepath] + stap_run $TEST_NAME run_ls_5_sec $itrace3_script_output -e $script +} + # Cleanup exec rm -f $exepath -- cgit From 1fd65aa57e608b544122b4aacdfae9cce6cb89dc Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Wed, 1 Apr 2009 17:01:53 -0700 Subject: Move testcase itrace3's warning into expect As it was, the ATTENTION was causing expect mismatches even when the test worked fine. The warning is served just as well from the expect script before starting the test. --- testsuite/systemtap.base/itrace.exp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/itrace.exp b/testsuite/systemtap.base/itrace.exp index d330a337..504253fe 100644 --- a/testsuite/systemtap.base/itrace.exp +++ b/testsuite/systemtap.base/itrace.exp @@ -53,7 +53,6 @@ set itrace3_script { probe begin { printf("systemtap starting probe\n") - printf("ATTENTION: if arch_has_block_step is not defined for this arch, this testcase will fail\n") } probe process("%s").insn.block { @@ -126,6 +125,7 @@ if {$utrace_support_found == 0} { } elseif {![installtest_p]} { untested $TEST_NAME } else { + send_log "ATTENTION: if arch_has_block_step is not defined for this arch, this testcase will fail\n" set script [format $itrace3_script $exepath] stap_run $TEST_NAME run_ls_5_sec $itrace3_script_output -e $script } -- cgit From 83ff01c2f669c66100a5cf7531dda9410a8ff6ce Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Wed, 1 Apr 2009 20:33:51 -0400 Subject: introduce [utrace_p] as dejagnu check for utrace presence in kernel * testsuite/lib/systemtap.exp: Define here. * testsuite/systemtap.*/*.exp: Use it here. Eliminate duplicated utrace_support_present logic. --- testsuite/systemtap.base/bz5274.exp | 9 +------- testsuite/systemtap.base/bz6850.exp | 9 +------- testsuite/systemtap.base/itrace.exp | 11 ++-------- testsuite/systemtap.base/labels.exp | 10 +-------- testsuite/systemtap.base/static_uprobes.exp | 10 +-------- testsuite/systemtap.base/uprobes.exp | 9 +------- testsuite/systemtap.base/uprobes_lib.exp | 15 ++++++++----- testsuite/systemtap.base/utrace_p4.exp | 34 +++++++++++------------------ testsuite/systemtap.base/utrace_p5.exp | 21 ++++++------------ 9 files changed, 37 insertions(+), 91 deletions(-) (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/bz5274.exp b/testsuite/systemtap.base/bz5274.exp index 92441e9e..2f76a43f 100755 --- a/testsuite/systemtap.base/bz5274.exp +++ b/testsuite/systemtap.base/bz5274.exp @@ -17,14 +17,7 @@ if {! [installtest_p]} { return } -# Try to find utrace_attach symbol in /proc/kallsyms -# copy from utrace_p5.exp -set utrace_support_found 0 -set path "/proc/kallsyms" -if {! [catch {exec grep -q utrace_attach $path} dummy]} { - set utrace_support_found 1 -} -if {$utrace_support_found == 0} { +if {![utrace_p]} { catch {exec rm -f $test} untested "$test -p5" return diff --git a/testsuite/systemtap.base/bz6850.exp b/testsuite/systemtap.base/bz6850.exp index b96ed95c..32ecdaf5 100644 --- a/testsuite/systemtap.base/bz6850.exp +++ b/testsuite/systemtap.base/bz6850.exp @@ -3,14 +3,7 @@ set test bz6850 catch {exec gcc -g -o bz6850 $srcdir/$subdir/bz6850.c} err if {$err == "" && [file exists bz6850]} then { pass "$test compile" } else { fail "$test compile" } -# Try to find utrace_attach symbol in /proc/kallsyms -# copy from utrace_p5.exp -set utrace_support_found 0 -set path "/proc/kallsyms" -if {! [catch {exec grep -q utrace_attach $path} dummy]} { - set utrace_support_found 1 -} -if {$utrace_support_found == 0} { +if {![utrace_p]} { catch {exec rm -f $test} untested "$test -p4" untested "$test -p5" diff --git a/testsuite/systemtap.base/itrace.exp b/testsuite/systemtap.base/itrace.exp index 504253fe..c7da39c8 100644 --- a/testsuite/systemtap.base/itrace.exp +++ b/testsuite/systemtap.base/itrace.exp @@ -2,7 +2,6 @@ # Initialize variables -set utrace_support_found 0 set exepath "[pwd]/ls_[pid]" set itrace1_script { @@ -92,14 +91,8 @@ proc run_ls_5_sec {} { } -# Try to find utrace_attach symbol in /proc/kallsyms -set path "/proc/kallsyms" -if {! [catch {exec grep -q utrace_attach $path} dummy]} { - set utrace_support_found 1 -} - set TEST_NAME "itrace1" -if {$utrace_support_found == 0} { +if {![utrace_p]} { untested "$TEST_NAME : no kernel utrace support found" } elseif {![installtest_p]} { untested $TEST_NAME @@ -110,7 +103,7 @@ if {$utrace_support_found == 0} { set TEST_NAME "itrace2" -if {$utrace_support_found == 0} { +if {![utrace_p]} { untested "$TEST_NAME : no kernel utrace support found" } elseif {![installtest_p]} { untested $TEST_NAME diff --git a/testsuite/systemtap.base/labels.exp b/testsuite/systemtap.base/labels.exp index 6db81c54..2f79a502 100644 --- a/testsuite/systemtap.base/labels.exp +++ b/testsuite/systemtap.base/labels.exp @@ -1,14 +1,6 @@ set test "labels" if {![installtest_p]} {untested $test; return} - -# Try to find utrace_attach symbol in /proc/kallsyms -# copy from utrace_p5.exp -set utrace_support_found 0 -set path "/proc/kallsyms" -if {! [catch {exec grep -q utrace_attach $path} dummy]} { - set utrace_support_found 1 -} -if {$utrace_support_found == 0} { untested "$test"; return } +if {![utrace_p]} { untested $test; return } # Compile a C program to use as the user-space probing target set label_srcpath "[pwd]/labels.c" diff --git a/testsuite/systemtap.base/static_uprobes.exp b/testsuite/systemtap.base/static_uprobes.exp index d6b6e1e3..07ff83e9 100644 --- a/testsuite/systemtap.base/static_uprobes.exp +++ b/testsuite/systemtap.base/static_uprobes.exp @@ -124,15 +124,7 @@ if { $res != "" } { } if {![installtest_p]} {untested $test; return} - -# Try to find utrace_attach symbol in /proc/kallsyms -# copy from utrace_p5.exp -set utrace_support_found 0 -set path "/proc/kallsyms" -if {! [catch {exec grep -q utrace_attach $path} dummy]} { - set utrace_support_found 1 -} -if {$utrace_support_found == 0} { +if {![utrace_p]} { untested "$test" catch {exec rm -f $sup_srcpath} return diff --git a/testsuite/systemtap.base/uprobes.exp b/testsuite/systemtap.base/uprobes.exp index 89250e7b..6344cbf0 100644 --- a/testsuite/systemtap.base/uprobes.exp +++ b/testsuite/systemtap.base/uprobes.exp @@ -18,14 +18,7 @@ if [file exists $path] then { pass "$test prep" } else { fail "$test prep" } catch {exec gcc -g -o jennie jennie.c} err if {$err == "" && [file exists jennie]} then { pass "$test compile" } else { fail "$test compile" } -# Try to find utrace_attach symbol in /proc/kallsyms -# copy from utrace_p5.exp -set utrace_support_found 0 -set path "/proc/kallsyms" -if {! [catch {exec grep -q utrace_attach $path} dummy]} { - set utrace_support_found 1 -} -if {$utrace_support_found == 0} { +if {![utrace_p]} { untested "$test -p4"; untested "$test -p5" catch {exec rm -f jennie.c jennie} return diff --git a/testsuite/systemtap.base/uprobes_lib.exp b/testsuite/systemtap.base/uprobes_lib.exp index ae1b72e8..63ef957a 100644 --- a/testsuite/systemtap.base/uprobes_lib.exp +++ b/testsuite/systemtap.base/uprobes_lib.exp @@ -10,21 +10,23 @@ set testflags "additional_flags=-g additional_flags=-O" set testlibflags "$testflags additional_flags=-fPIC additional_flags=-shared" set maintestflags "$testflags additional_flags=-L$testlibdir additional_flags=-l$testlibname additional_flags=-Wl,-rpath,$testlibdir" -# Only run on make installcheck -if {! [installtest_p]} { untested "$test"; return } - # Compile our test program and library. set res [target_compile $testsrclib $testso executable $testlibflags] if { $res != "" } { verbose "target_compile for $testso failed: $res" 2 - fail "unable to compile $testsrclib" + fail "$test compile $testsrclib" return +} else { + pass "$test compile $testsrclib" } + set res [target_compile $testsrc $testexe executable $maintestflags] if { $res != "" } { verbose "target_compile failed: $res" 2 - fail "unable to compile $testsrc" + fail "$test compile $testsrc" return +} else { + pass "$test compile $testsrc" } # XXX main_func needs another/extra test. Disabled for now. @@ -33,6 +35,9 @@ if { $res != "" } { # lib_func} set ::result_string {lib_func} +# Only run on make installcheck +if {! [installtest_p]} { untested "$test"; return } +if {! [utrace_p]} { untested $test; return } stap_run2 $srcdir/$subdir/$test.stp -c $testexe #exec rm -f $testexe $testso diff --git a/testsuite/systemtap.base/utrace_p4.exp b/testsuite/systemtap.base/utrace_p4.exp index 1467d9c8..8d323a8a 100644 --- a/testsuite/systemtap.base/utrace_p4.exp +++ b/testsuite/systemtap.base/utrace_p4.exp @@ -7,8 +7,6 @@ # utrace doesn't exist in the kernel, marks the tests as 'untested'. # Initialize variables -set utrace_support_found 0 - set begin_script {"probe process(\"/bin/ls\").begin { print(\"ls begin\") }"} set end_script {"probe process(\"/bin/ls\").end { print(\"ls end\") }"} set syscall_script {"probe process(\"/bin/ls\").syscall { printf(\"|%d\", \$syscall) }"} @@ -24,18 +22,12 @@ set pid_syscall_return_script {"probe process(123).syscall.return { printf(\"|%d set pid_thread_begin_script {"probe process(123).thread.begin { print(\"123 thread.begin\") }"} set pid_thread_end_script {"probe process(123).thread.end { print(\"123 thread.end\") }"} -# Try to find utrace_attach symbol in /proc/kallsyms -set path "/proc/kallsyms" -if {! [catch {exec grep -q utrace_attach $path} dummy]} { - set utrace_support_found 1 -} - # # Do some utrace compile tests. # set TEST_NAME "UTRACE_P4_01" -if {$utrace_support_found == 0} { +if {![utrace_p]} { untested "$TEST_NAME : no kernel utrace support found" } else { # Try compiling a begin script using a path @@ -43,7 +35,7 @@ if {$utrace_support_found == 0} { } set TEST_NAME "UTRACE_P4_01_pid" -if {$utrace_support_found == 0} { +if {![utrace_p]} { untested "$TEST_NAME : no kernel utrace support found" } else { # Try compiling a begin script using a pid @@ -51,7 +43,7 @@ if {$utrace_support_found == 0} { } set TEST_NAME "UTRACE_P4_02" -if {$utrace_support_found == 0} { +if {![utrace_p]} { untested "$TEST_NAME : no kernel utrace support found" } else { # Try compiling a end script using a path @@ -59,7 +51,7 @@ if {$utrace_support_found == 0} { } set TEST_NAME "UTRACE_P4_02_pid" -if {$utrace_support_found == 0} { +if {![utrace_p]} { untested "$TEST_NAME : no kernel utrace support found" } else { # Try compiling a end script using a pid @@ -67,7 +59,7 @@ if {$utrace_support_found == 0} { } set TEST_NAME "UTRACE_P4_03" -if {$utrace_support_found == 0} { +if {![utrace_p]} { untested "$TEST_NAME : no kernel utrace support found" } else { # Try compiling a syscall script using a path @@ -75,7 +67,7 @@ if {$utrace_support_found == 0} { } set TEST_NAME "UTRACE_P4_03_pid" -if {$utrace_support_found == 0} { +if {![utrace_p]} { untested "$TEST_NAME : no kernel utrace support found" } else { # Try compiling a syscall script using a pid @@ -83,7 +75,7 @@ if {$utrace_support_found == 0} { } set TEST_NAME "UTRACE_P4_04" -if {$utrace_support_found == 0} { +if {![utrace_p]} { untested "$TEST_NAME : no kernel utrace support found" } else { # Try compiling a syscall return script using a path @@ -91,7 +83,7 @@ if {$utrace_support_found == 0} { } set TEST_NAME "UTRACE_P4_04_pid" -if {$utrace_support_found == 0} { +if {![utrace_p]} { untested "$TEST_NAME : no kernel utrace support found" } else { # Try compiling a syscall return script using a pid @@ -99,7 +91,7 @@ if {$utrace_support_found == 0} { } set TEST_NAME "UTRACE_P4_05" -if {$utrace_support_found == 0} { +if {![utrace_p]} { untested "$TEST_NAME : no kernel utrace support found" } else { # Try compiling an thread.begin script using a path @@ -107,7 +99,7 @@ if {$utrace_support_found == 0} { } set TEST_NAME "UTRACE_P4_05_pid" -if {$utrace_support_found == 0} { +if {![utrace_p]} { untested "$TEST_NAME : no kernel utrace support found" } else { # Try compiling an thread.begin script using a pid @@ -115,7 +107,7 @@ if {$utrace_support_found == 0} { } set TEST_NAME "UTRACE_P4_06" -if {$utrace_support_found == 0} { +if {![utrace_p]} { untested "$TEST_NAME : no kernel utrace support found" } else { # Try compiling an thread.end script using a path @@ -123,7 +115,7 @@ if {$utrace_support_found == 0} { } set TEST_NAME "UTRACE_P4_06_pid" -if {$utrace_support_found == 0} { +if {![utrace_p]} { untested "$TEST_NAME : no kernel utrace support found" } else { # Try compiling an thread.end script using a pid @@ -131,7 +123,7 @@ if {$utrace_support_found == 0} { } set TEST_NAME "UTRACE_P4_07" -if {$utrace_support_found == 0} { +if {![utrace_p]} { untested "$TEST_NAME : no kernel utrace support found" } else { # Try compiling an system-wide begin script diff --git a/testsuite/systemtap.base/utrace_p5.exp b/testsuite/systemtap.base/utrace_p5.exp index 33281350..3d432dc3 100644 --- a/testsuite/systemtap.base/utrace_p5.exp +++ b/testsuite/systemtap.base/utrace_p5.exp @@ -1,7 +1,6 @@ # Utrace run (pass 5) tests. # Initialize variables -set utrace_support_found 0 set exepath "[pwd]/cat_[pid]" set multi_srcpath "$srcdir/systemtap.base/utrace_p5_multi.c" set multi_exepath "[pwd]/utrace_p5_multi_[pid]" @@ -90,12 +89,6 @@ set bz6841_script { } set bz6841_script_output ".+ issues syscall \\d+ times\r\n" -# Try to find utrace_attach symbol in /proc/kallsyms -set path "/proc/kallsyms" -if {! [catch {exec grep -q utrace_attach $path} dummy]} { - set utrace_support_found 1 -} - # Set up our own copy of /bin/cat, to make testing for a particular # executable easy. We can't use 'ln' here, since we might be creating # a cross-device link. We can't use 'ln -s' here, since the kernel @@ -138,7 +131,7 @@ proc run_utrace_p5_multi {} { } set TEST_NAME "UTRACE_P5_01" -if {$utrace_support_found == 0} { +if {![utrace_p]} { untested "$TEST_NAME : no kernel utrace support found" } elseif {![installtest_p]} { untested "$TEST_NAME" @@ -148,7 +141,7 @@ if {$utrace_support_found == 0} { } set TEST_NAME "UTRACE_P5_02" -if {$utrace_support_found == 0} { +if {![utrace_p]} { untested "$TEST_NAME : no kernel utrace support found" } elseif {![installtest_p]} { untested "$TEST_NAME" @@ -158,7 +151,7 @@ if {$utrace_support_found == 0} { } set TEST_NAME "UTRACE_P5_03" -if {$utrace_support_found == 0} { +if {![utrace_p]} { untested "$TEST_NAME : no kernel utrace support found" } elseif {![installtest_p]} { untested "$TEST_NAME" @@ -168,7 +161,7 @@ if {$utrace_support_found == 0} { } set TEST_NAME "UTRACE_P5_04" -if {$utrace_support_found == 0} { +if {![utrace_p]} { untested "$TEST_NAME : no kernel utrace support found" } elseif {![installtest_p]} { untested "$TEST_NAME" @@ -178,7 +171,7 @@ if {$utrace_support_found == 0} { } set TEST_NAME "UTRACE_P5_05" -if {$utrace_support_found == 0} { +if {![utrace_p]} { untested "$TEST_NAME : no kernel utrace support found" } elseif {![installtest_p]} { untested "$TEST_NAME" @@ -189,7 +182,7 @@ if {$utrace_support_found == 0} { } set TEST_NAME "UTRACE_P5_06" -if {$utrace_support_found == 0} { +if {![utrace_p]} { untested "$TEST_NAME : no kernel utrace support found" } elseif {![installtest_p]} { untested "$TEST_NAME" @@ -200,7 +193,7 @@ if {$utrace_support_found == 0} { } set TEST_NAME "UTRACE_P5_07" -if {$utrace_support_found == 0} { +if {![utrace_p]} { untested "$TEST_NAME : no kernel utrace support found" } elseif {![installtest_p]} { untested "$TEST_NAME" -- cgit From ab16aae80b49823e96b31e7ab47fcdb3a199412f Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Thu, 2 Apr 2009 14:48:37 +0200 Subject: PR9995: Test for [installtest_p] && [utrace_p]. --- testsuite/systemtap.base/sdt.exp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/sdt.exp b/testsuite/systemtap.base/sdt.exp index 46fa5a28..c3aed91e 100644 --- a/testsuite/systemtap.base/sdt.exp +++ b/testsuite/systemtap.base/sdt.exp @@ -36,7 +36,7 @@ if { $res != "" } { pass "compiling $test.c $extra_flag" } -if {[installtest_p]} { +if {[installtest_p] && [utrace_p]} { stap_run3 "$test $extra_flag" $srcdir/$subdir/$test.stp $testprog -c ./$testprog } else { untested "$test $extra_flag" @@ -61,7 +61,7 @@ if { $res != "" } { pass "compiling $test.c c++ $extra_flag" } -if {[installtest_p]} { +if {[installtest_p] && [utrace_p]} { stap_run3 "$test c++ $extra_flag" $srcdir/$subdir/$test.stp $testprog -c ./$testprog } else { untested "$test c++ $extra_flag" -- cgit From 15a78144473940a4e7c685cc57ba09a92f2293c6 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Thu, 2 Apr 2009 16:26:50 +0200 Subject: itrace.exp: s/utrace_support_found/utrace_p/ --- testsuite/systemtap.base/itrace.exp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/itrace.exp b/testsuite/systemtap.base/itrace.exp index c7da39c8..5da0dfaf 100644 --- a/testsuite/systemtap.base/itrace.exp +++ b/testsuite/systemtap.base/itrace.exp @@ -113,7 +113,7 @@ if {![utrace_p]} { } set TEST_NAME "itrace3" -if {$utrace_support_found == 0} { +if {![utrace_p]} { untested "$TEST_NAME : no kernel utrace support found" } elseif {![installtest_p]} { untested $TEST_NAME -- cgit From a7d25c487ad74dc60bbbd93a2f689e0f0a047273 Mon Sep 17 00:00:00 2001 From: Stan Cox Date: Thu, 2 Apr 2009 15:15:22 -0400 Subject: Rewrite stmt_rel.exp to only rely on -l output. * testsuite/systemtap.base/stmt_rel.exp: Rewrite. --- testsuite/systemtap.base/stmt_rel.exp | 44 +++++++++++++++++++--- testsuite/systemtap.base/stmt_rel.stp | 71 ----------------------------------- 2 files changed, 38 insertions(+), 77 deletions(-) delete mode 100644 testsuite/systemtap.base/stmt_rel.stp (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/stmt_rel.exp b/testsuite/systemtap.base/stmt_rel.exp index be51fef9..ec12e484 100644 --- a/testsuite/systemtap.base/stmt_rel.exp +++ b/testsuite/systemtap.base/stmt_rel.exp @@ -1,8 +1,40 @@ -# test integer limits. Set and print variables and print constants. - set test "stmt_rel" -set ::result_string {PASS bio_init -PASS line number -PASS wildcard} -stap_run2 $srcdir/$subdir/$test.stp +set line1 "" +spawn stap -l "kernel.statement(\"bio_init@fs/bio.c+2\")" +expect { + -timeout 180 + -re {[0-9][0-9][0-9]} { regexp "\[0-9\]\[0-9\]\[0-9\]" $expect_out(0,string) line1; } + timeout { fail "$test C (timeout)" } + eof { } +} + +set line2 "" +spawn stap -l "kernel.statement(\"bio_init@fs/bio.c+3\")" +expect { + -timeout 180 + -re {[0-9][0-9][0-9]} { regexp "\[0-9\]\[0-9\]\[0-9\]" $expect_out(0,string) line2; } + timeout { fail "$test C (timeout)" } + eof { } +} + +if { $line1 < $line2 } { + pass "$test line numbers" +} else { + fail "$test line numbers" +} + +set ok 0 +spawn stap -l "kernel.statement(\"bio_init@fs/bio.c:*\")" +expect { + -timeout 180 + -re {[0-9][0-9][0-9]} { incr ok; exp_continue } + timeout { fail "$test C (timeout)" } + eof { } +} + +if { $ok == 3 } { + pass "$test wildcard" +} else { + fail "$test wildcard ($ok)" +} diff --git a/testsuite/systemtap.base/stmt_rel.stp b/testsuite/systemtap.base/stmt_rel.stp deleted file mode 100644 index cfe77317..00000000 --- a/testsuite/systemtap.base/stmt_rel.stp +++ /dev/null @@ -1,71 +0,0 @@ -global stack2pp, stack2func, stack3pp, stack3func -global wildcardpp, wild_count - -probe kernel.statement("bio_init@fs/bio.c+2") { - # stack2 = tokenize(backtrace(), " ") - stack2func = probefunc() - stack2pp = pp() -} -probe kernel.statement("bio_init@fs/bio.c+3") { - # stack3 = tokenize(backtrace(), " " ) - stack3func = probefunc() - stack3pp = pp() -} - -probe kernel.statement("bio_put@fs/bio.c:*") { - line = tokenize(pp(),":") - line = tokenize("",":") - line = substr(line,0,strlen(line)-2) - wildcardpp[strtol(line,10)]++ - - if (wild_count++ <= 10) { - next - } - - stack2pp = tokenize(stack2pp,":") - stack2pp = tokenize("",":") - stack3pp = tokenize(stack3pp,":") - stack3pp = tokenize("",":") - - stack2line = strtol (substr(stack2pp,0,strlen(stack2pp)-2), 10) - stack3line = strtol (substr(stack3pp,0,strlen(stack3pp)-2), 10) - - # Did functions for both bio_init probes match? - if (stack2func == stack3func) { - printf ("PASS %s\n", stack2func) - } - else { - printf ("FAIL %s %s\n", stack2func, stack3func) - } - - # Was line # for bio_init probe +2 < line # for bio_init probe +3? - if ((stack2line + 1) == stack3line) { - printf ("PASS line number\n") - } - else { - printf ("FAIL line number %d %d\n", stack2line, stack3line) - } - - # This test does not take optimized code into account - # Was address for bio_init probe +2 < address for bio_init probe +3? - # if (stack2 < stack3) { - # printf ("PASS address\n") - # } - # else { - # printf ("FAIL address %s %s\n", stack2, stack3) - # } - - # Did wildcard probe hit at least 4 different statements? - foreach ([i] in wildcardpp) { - statement_count += 1 - } - if (statement_count >= 4) { - printf ("PASS wildcard\n") - } - else - { - printf ("FAIL wildcard %d\n", statement_count) - } - - exit() -} -- cgit From 0b113a7a70d617c5e67807c9a897b196db4b3b7a Mon Sep 17 00:00:00 2001 From: Stan Cox Date: Wed, 8 Apr 2009 12:36:37 -0400 Subject: Do not do a partial name comparison for .label. * tapsets.cxx (dwflpp::iterate_over_cu_labels): Compare with strcmp not strncmp. --- testsuite/systemtap.base/labels.exp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/labels.exp b/testsuite/systemtap.base/labels.exp index 2f79a502..f389f08c 100644 --- a/testsuite/systemtap.base/labels.exp +++ b/testsuite/systemtap.base/labels.exp @@ -18,7 +18,7 @@ main () char *c; init_an_int: a = 2; -init_another_int: +init_an_int_again: b = 3; c = \"abc\"; ptr_inited: @@ -32,6 +32,7 @@ set fp [open $label_stppath "w"] puts $fp " probe process(\"labels.x\").function(\"main*@labels.c\").label(\"init_*\") {printf (\"VARS %s\\n\",\$\$vars)} probe process(\"labels.x\").function(\"main*@labels.c\").label(\"ptr_inited\") {printf (\"VARS %s\\n\",\$\$vars)} +probe process(\"labels.x\").function(\"main*@labels.c\").label(\"init_an_int\") {printf (\"init_an_int\\n\")} " close $fp @@ -55,12 +56,12 @@ spawn stap -c $label_exepath $label_stppath wait expect { -timeout 180 - -re {VARS a=0x0 b=0x0.*VARS a=0x2 b=0x0.*VARS a=0x2 b=0x3 c=0x[a-f01-9]} { incr ok; exp_continue } + -re {VARS a=0x0 b=0x0.*init_an_int.*VARS a=0x2 b=0x0.*VARS a=0x2 b=0x3 c=0x[a-f01-9]} { incr ok; exp_continue } timeout { fail "$test (timeout)" } eof { } } -if {$ok == 1} { pass "$test exe .label" } { fail "$test exe .label" } +if {$ok == 1} { pass "$test exe .label" } { fail "$test exe .label $ok" } # address of label in an executable @@ -68,7 +69,7 @@ set label_shpath "[pwd]/label.sh" set fp [open $label_shpath "w"] puts $fp " readelf --debug-dump $label_exepath | awk \" -/init_another_int/ {have_label=1} +/init_an_int_again/ {have_label=1} /DW_AT_low_pc/ {if (have_label) {print \$3;exit;}} \" " @@ -103,7 +104,7 @@ if { $res != "" } { # label in a shared object -spawn stap -p2 -l "process\(\"$label_sopath\"\).function\(\"\*\"\).label\(\"init_another_int\"\)" +spawn stap -p2 -l "process\(\"$label_sopath\"\).function\(\"\*\"\).label\(\"init_an_int_again\"\)" expect { -timeout 180 -re {process.*function} { incr ok; exp_continue } @@ -111,7 +112,7 @@ expect { eof { } } -if {$ok == 1} { pass "$test so .label" } { fail "$test so .label" } +if {$ok == 1} { pass "$test so .label" } { fail "$test so .label $ok" } # address of label in a shared object @@ -119,7 +120,7 @@ set label_shpath "[pwd]/label.sh" set fp [open $label_shpath "w"] puts $fp " readelf --debug-dump $label_sopath | awk \" -/init_another_int/ {have_label=1} +/init_an_int_again/ {have_label=1} /DW_AT_low_pc/ {if (have_label) {print \$3;exit;}} \" " -- cgit From e87251e16921a2d52a35212278e45f0c0af1cc5d Mon Sep 17 00:00:00 2001 From: Stan Cox Date: Wed, 8 Apr 2009 17:19:04 -0400 Subject: Consider function when handling .label * tapsets.cxx(dwflpp::iterate_over_cu_labels): New parameter function. Do wildcard match for function. * testsuite/systemtap.base/labels.exp: Test .label function handling. --- testsuite/systemtap.base/labels.exp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/labels.exp b/testsuite/systemtap.base/labels.exp index f389f08c..268bb320 100644 --- a/testsuite/systemtap.base/labels.exp +++ b/testsuite/systemtap.base/labels.exp @@ -10,9 +10,16 @@ set label_flags "additional_flags=-g" set fp [open $label_srcpath "w"] puts $fp " int +foo () +{ +init_an_int: + return 1; +} +int main () { sleep(5); + foo(); int a = 0; int b = 0; char *c; @@ -30,9 +37,9 @@ close $fp set label_stppath "[pwd]/labels.stp" set fp [open $label_stppath "w"] puts $fp " -probe process(\"labels.x\").function(\"main*@labels.c\").label(\"init_*\") {printf (\"VARS %s\\n\",\$\$vars)} -probe process(\"labels.x\").function(\"main*@labels.c\").label(\"ptr_inited\") {printf (\"VARS %s\\n\",\$\$vars)} -probe process(\"labels.x\").function(\"main*@labels.c\").label(\"init_an_int\") {printf (\"init_an_int\\n\")} +probe process(\"labels.x\").function(\"main@labels.c\").label(\"init_*\") {printf (\"VARS %s\\n\",\$\$vars)} +probe process(\"labels.x\").function(\"main@labels.c\").label(\"ptr_inited\") {printf (\"VARS %s\\n\",\$\$vars)} +probe process(\"labels.x\").function(\"main@labels.c\").label(\"init_an_int\") {printf (\"init_an_int\\n\")} " close $fp -- cgit From 30450585dd7d50224abef863ed8bae0950740fdb Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Wed, 8 Apr 2009 18:11:34 +0200 Subject: Add main executable symbol uprobe to uprobes_lib.exp test. There was nothing wrong with the probe itself, but because the body was empty the compiler optimised away the actual call... * testsuite/systemtap.base/uprobes_lib.exp: Activate main exe probe, expect more output. * testsuite/systemtap.base/uprobes_lib.stp: Also probe main and main_lib. * testsuite/systemtap.base/uprobes_exe.c: Put some code in main_func. * testsuite/systemtap.base/uprobes_lib.c: Likewise for lib_func. --- testsuite/systemtap.base/uprobes_exe.c | 8 +++++--- testsuite/systemtap.base/uprobes_lib.c | 3 ++- testsuite/systemtap.base/uprobes_lib.exp | 13 ++++++++----- testsuite/systemtap.base/uprobes_lib.stp | 10 ++++++++-- 4 files changed, 23 insertions(+), 11 deletions(-) (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/uprobes_exe.c b/testsuite/systemtap.base/uprobes_exe.c index 447434c6..b4811335 100644 --- a/testsuite/systemtap.base/uprobes_exe.c +++ b/testsuite/systemtap.base/uprobes_exe.c @@ -15,13 +15,15 @@ int lib_main (void); void main_func (int foo) { - ; // nothing here... + if (foo > 1) + main_func (foo - 1); + else + lib_main(); } int main (int argc, char *argv[], char *envp[]) { - main_func(1); - lib_main(); + main_func (3); return 0; } diff --git a/testsuite/systemtap.base/uprobes_lib.c b/testsuite/systemtap.base/uprobes_lib.c index c9d70625..25297b6b 100644 --- a/testsuite/systemtap.base/uprobes_lib.c +++ b/testsuite/systemtap.base/uprobes_lib.c @@ -10,7 +10,8 @@ void lib_func (int bar) { - ; // nothing here... + if (bar > 1) + lib_func (bar - 1); } void diff --git a/testsuite/systemtap.base/uprobes_lib.exp b/testsuite/systemtap.base/uprobes_lib.exp index 63ef957a..313c01b6 100644 --- a/testsuite/systemtap.base/uprobes_lib.exp +++ b/testsuite/systemtap.base/uprobes_lib.exp @@ -29,11 +29,14 @@ if { $res != "" } { pass "$test compile $testsrc" } -# XXX main_func needs another/extra test. Disabled for now. -# Enable (and in uprobes_lib.stp) after PR9940 is fixed. -# set ::result_string {main_func -# lib_func} -set ::result_string {lib_func} +set ::result_string {main +main_func +main_func +main_func +lib_main +lib_func +lib_func +lib_func} # Only run on make installcheck if {! [installtest_p]} { untested "$test"; return } diff --git a/testsuite/systemtap.base/uprobes_lib.stp b/testsuite/systemtap.base/uprobes_lib.stp index bc6cc249..459351a4 100644 --- a/testsuite/systemtap.base/uprobes_lib.stp +++ b/testsuite/systemtap.base/uprobes_lib.stp @@ -1,8 +1,14 @@ -/* - Not activated probe... Seems always skipped? +probe process("uprobes_exe").function("main") { + printf("main\n"); +} + probe process("uprobes_exe").function("main_func") { printf("main_func\n"); } -*/ + +probe process("libuprobes_lib.so").function("lib_main") { + printf("lib_main\n"); +} probe process("libuprobes_lib.so").function("lib_func") { printf("lib_func\n"); -- cgit From 18ac9f367a2e63335dfbdc8f5e8a97de4e40dbe4 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Thu, 9 Apr 2009 14:26:07 +0200 Subject: Add tests for probefunc(), usymname(), uaddr() versus shared libraries. * testsuite/systemtap.base/uprobes_uname.exp: New file. * testsuite/systemtap.base/uprobes_uname.stp: Likewise. --- testsuite/systemtap.base/uprobes_uname.exp | 46 ++++++++++++++++++++++++++++++ testsuite/systemtap.base/uprobes_uname.stp | 7 +++++ 2 files changed, 53 insertions(+) create mode 100644 testsuite/systemtap.base/uprobes_uname.exp create mode 100644 testsuite/systemtap.base/uprobes_uname.stp (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/uprobes_uname.exp b/testsuite/systemtap.base/uprobes_uname.exp new file mode 100644 index 00000000..65e1ff70 --- /dev/null +++ b/testsuite/systemtap.base/uprobes_uname.exp @@ -0,0 +1,46 @@ +set test "uprobes_uname" +set testpath "$srcdir/$subdir" +set testsrc "$testpath/uprobes_exe.c" +set testsrclib "$testpath/uprobes_lib.c" +set testexe "./uprobes_exe" +set testlibname "uprobes_lib" +set testlibdir "." +set testso "$testlibdir/lib${testlibname}.so" +set testflags "additional_flags=-g additional_flags=-O" +set testlibflags "$testflags additional_flags=-fPIC additional_flags=-shared" +set maintestflags "$testflags additional_flags=-L$testlibdir additional_flags=-l$testlibname additional_flags=-Wl,-rpath,$testlibdir" + +# Compile our test program and library. +set res [target_compile $testsrclib $testso executable $testlibflags] +if { $res != "" } { + verbose "target_compile for $testso failed: $res" 2 + fail "$test compile $testsrclib" + return +} else { + pass "$test compile $testsrclib" +} + +set res [target_compile $testsrc $testexe executable $maintestflags] +if { $res != "" } { + verbose "target_compile failed: $res" 2 + fail "$test compile $testsrc" + return +} else { + pass "$test compile $testsrc" +} + +set ::result_string {exe: main=main +exe: main_func=main_func +exe: main_func=main_func +exe: main_func=main_func +lib: lib_main=lib_main +lib: lib_func=lib_func +lib: lib_func=lib_func +lib: lib_func=lib_func} + +# Only run on make installcheck +if {! [installtest_p]} { untested "$test"; return } +if {! [utrace_p]} { untested $test; return } +stap_run2 $srcdir/$subdir/$test.stp -c $testexe + +#exec rm -f $testexe $testso diff --git a/testsuite/systemtap.base/uprobes_uname.stp b/testsuite/systemtap.base/uprobes_uname.stp new file mode 100644 index 00000000..a44d78d3 --- /dev/null +++ b/testsuite/systemtap.base/uprobes_uname.stp @@ -0,0 +1,7 @@ +probe process("uprobes_exe").function("*") { + printf("exe: %s=%s\n",probefunc(), usymname(uaddr())); +} + +probe process("libuprobes_lib.so").function("*") { + printf("lib: %s=%s\n",probefunc(), usymname(uaddr())); +} -- cgit From 412e8ec0dadbc0010c865f9a285a748b8d08c053 Mon Sep 17 00:00:00 2001 From: Wenji Huang Date: Thu, 9 Apr 2009 23:48:39 -0400 Subject: Make stmt_rel.exp have good compatibility --- testsuite/systemtap.base/stmt_rel.exp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/stmt_rel.exp b/testsuite/systemtap.base/stmt_rel.exp index ec12e484..619c91a5 100644 --- a/testsuite/systemtap.base/stmt_rel.exp +++ b/testsuite/systemtap.base/stmt_rel.exp @@ -33,7 +33,9 @@ expect { eof { } } -if { $ok == 3 } { +# bio_init drifts a bit in different kernels. +# maybe 3, 4 or 15 lines in it. +if { $ok >= 3 } { pass "$test wildcard" } else { fail "$test wildcard ($ok)" -- cgit From 8ca27b7dc58bf14e86cd40ae6246962fa580966d Mon Sep 17 00:00:00 2001 From: Stan Cox Date: Mon, 13 Apr 2009 17:51:58 -0400 Subject: Improve -l output for .label * tapsets.cxx (iterate_over_cu_labels): Treat -l specially so the output of a .label can be improved. * labels.stp: Test -l --- testsuite/systemtap.base/labels.exp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/labels.exp b/testsuite/systemtap.base/labels.exp index 268bb320..88ed4619 100644 --- a/testsuite/systemtap.base/labels.exp +++ b/testsuite/systemtap.base/labels.exp @@ -55,8 +55,23 @@ if { $res != "" } { pass "compiling labels.c -g" } +# list of labels + +spawn stap -l "process(\"$label_exepath\").function(\"*\").label(\"*\")" + +wait +expect { + -timeout 180 + -re {process.*function.*labels.c:5...label..init_an_int.*process.*function.*labels.c:16...label..init_an_int.*process.*function.*labels.c:18...label..init_an_int_again} { incr ok; exp_continue } + timeout { fail "$test (timeout)" } + eof { } +} + +if {$ok == 1} { pass "$test -l .label" } { fail "$test -l .label $ok" } + # label in an executable +set ok 0 verbose -log "spawn stap -c $label_exepath $label_stppath" spawn stap -c $label_exepath $label_stppath -- cgit From b9c2e81cc7a62336ec1daf374cb3411add772ab4 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Mon, 13 Apr 2009 19:50:23 -0700 Subject: PR10067: fix bitfield access * tapsets.cxx (dwflpp::translate_components): Eliminate the extra die-dereference at the end of the loop (a regression from @casts). * runtime/loc2c-runtime.h (store_bitfield): Use the target as the representative type, since the base is always int64_t. Also be a bit more aggressive with masking and parentheses. * testsuite/systemtap.base/bitfield.*: New test for R/W bitfields. --- testsuite/systemtap.base/bitfield.exp | 3 +++ testsuite/systemtap.base/bitfield.stp | 46 +++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 testsuite/systemtap.base/bitfield.exp create mode 100644 testsuite/systemtap.base/bitfield.stp (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/bitfield.exp b/testsuite/systemtap.base/bitfield.exp new file mode 100644 index 00000000..16451369 --- /dev/null +++ b/testsuite/systemtap.base/bitfield.exp @@ -0,0 +1,3 @@ +# test that bitfield r/w works correctly +set test "bitfield" +stap_run $srcdir/$subdir/$test.stp no_load $all_pass_string -g diff --git a/testsuite/systemtap.base/bitfield.stp b/testsuite/systemtap.base/bitfield.stp new file mode 100644 index 00000000..c2ff4929 --- /dev/null +++ b/testsuite/systemtap.base/bitfield.stp @@ -0,0 +1,46 @@ +%{ +#include +static struct tcphdr foo = {0}; +%} + +function get_ptr:long() %{ THIS->__retvalue = (long)&foo; /* pure */ %} +function get_ack:long() %{ THIS->__retvalue = foo.ack; /* pure */ %} +function get_urg:long() %{ THIS->__retvalue = foo.urg; /* pure */ %} + +function check:long(ack:long, urg:long) { + ptr = get_ptr() + + /* set the bits with cast */ + @cast(ptr, "tcphdr")->ack = ack + @cast(ptr, "tcphdr")->urg = urg + + /* check that reading with embedded-C is ok */ + real_ack = get_ack() + real_urg = get_urg() + errors = (ack != real_ack) + (urg != real_urg) + + /* check that reading with a cast is ok */ + cast_ack = @cast(ptr, "tcphdr")->ack + cast_urg = @cast(ptr, "tcphdr")->urg + errors += (ack != cast_ack) + (urg != cast_urg) + + if (errors) + printf("bitfield had %d errors; expect(%d%d), real(%d%d), cast(%d%d)\n", + errors, ack, urg, real_ack, real_urg, cast_ack, cast_urg) + + return errors +} + +probe begin { + println("systemtap starting probe") + + errors = check(0, 0) + errors += check(0, 1) + errors += check(1, 0) + errors += check(1, 1) + + println("systemtap ending probe") + if (errors == 0) + println("systemtap test success") + exit() +} -- cgit From bd4b874d5a57aff23809617b19501da94885da8f Mon Sep 17 00:00:00 2001 From: Stan Cox Date: Thu, 16 Apr 2009 10:25:05 -0400 Subject: Use iterate_over_srcfile_lines for function("func@file:N").label * tapsets.cxx (dwflpp::iterate_over_labels): Renamed from iterate_over_cu_labels, method signature simplified. (query_srcfile_label): New. (query_cu): Use above. * labels.exp: New tests for above. --- testsuite/systemtap.base/labels.exp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/labels.exp b/testsuite/systemtap.base/labels.exp index 88ed4619..79e3f483 100644 --- a/testsuite/systemtap.base/labels.exp +++ b/testsuite/systemtap.base/labels.exp @@ -55,11 +55,42 @@ if { $res != "" } { pass "compiling labels.c -g" } +# line number error + +set ok 0 +spawn stap -l "process(\"$label_exepath\").function(\"foo@${label_srcpath}:10\").label(\"*\")" + +wait +expect { + -timeout 180 + -re {no match while resolving probe point} { incr ok; exp_continue } + timeout { fail "$test (timeout)" } + eof { } +} + +if {$ok == 1} { pass "$test :N .label" } { fail "$test :N .label $ok" } + +# line number + +set ok 0 +spawn stap -l "process(\"$label_exepath\").function(\"foo@${label_srcpath}:4\").label(\"*\")" + +wait +expect { + -timeout 180 + -re {process.*function.*labels.c:5...label..init_an_int} { incr ok; exp_continue } + timeout { fail "$test (timeout)" } + eof { } +} + +if {$ok == 1} { pass "$test :N .label" } { fail "$test :N .label $ok" } + # list of labels spawn stap -l "process(\"$label_exepath\").function(\"*\").label(\"*\")" wait +set ok 0 expect { -timeout 180 -re {process.*function.*labels.c:5...label..init_an_int.*process.*function.*labels.c:16...label..init_an_int.*process.*function.*labels.c:18...label..init_an_int_again} { incr ok; exp_continue } -- cgit From 2a22df62a80d032e9450570c32009bfea4be7305 Mon Sep 17 00:00:00 2001 From: Stan Cox Date: Fri, 17 Apr 2009 10:15:41 -0400 Subject: Output probe calling sequence comment * dtrace: Output probe calling sequence comment --- testsuite/systemtap.base/static_uprobes.exp | 1 - 1 file changed, 1 deletion(-) (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/static_uprobes.exp b/testsuite/systemtap.base/static_uprobes.exp index 07ff83e9..1e53d5d3 100644 --- a/testsuite/systemtap.base/static_uprobes.exp +++ b/testsuite/systemtap.base/static_uprobes.exp @@ -93,7 +93,6 @@ if {[installtest_p]} { if {[catch {exec $dtrace -h -s $sup_dpath} res]} { verbose -log "unable to run $dtrace: $res" } -catch {exec rm -f $sup_dpath} if {[file exists $sup_hpath]} then { pass "$test dtrace" } else { -- cgit From be8770ce0c66eea1113c3c91682b4fdf6ae1ec77 Mon Sep 17 00:00:00 2001 From: David Smith Date: Fri, 17 Apr 2009 09:37:00 -0500 Subject: Added new utrace syscall argument test. 2009-04-17 David Smith * systemtap.base/utrace_syscall_args.c: New test file. * systemtap.base/utrace_syscall_args.exp: New test file. * systemtap.base/utrace_syscall_args.stp: New test file. --- testsuite/systemtap.base/utrace_syscall_args.c | 67 +++++ testsuite/systemtap.base/utrace_syscall_args.exp | 82 +++++ testsuite/systemtap.base/utrace_syscall_args.stp | 366 +++++++++++++++++++++++ 3 files changed, 515 insertions(+) create mode 100644 testsuite/systemtap.base/utrace_syscall_args.c create mode 100644 testsuite/systemtap.base/utrace_syscall_args.exp create mode 100644 testsuite/systemtap.base/utrace_syscall_args.stp (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/utrace_syscall_args.c b/testsuite/systemtap.base/utrace_syscall_args.c new file mode 100644 index 00000000..2d3da838 --- /dev/null +++ b/testsuite/systemtap.base/utrace_syscall_args.c @@ -0,0 +1,67 @@ +#include +#include +#include +#include +#include +#include /* For SYS_xxx definitions */ + +int main() +{ + int fd, ret; + struct stat fs; + void *r; + int rc; + + /* create a file with something in it */ + fd = open("foobar", O_WRONLY|O_CREAT|O_TRUNC, 0600); + lseek(fd, 1024, SEEK_SET); + write(fd, "abcdef", 6); + close(fd); + + fd = open("foobar", O_RDONLY); + + /* stat for file size */ + ret = fstat(fd, &fs); + + /* mmap file file, then unmap it. */ + r = mmap(NULL, fs.st_size, PROT_READ, MAP_SHARED, fd, 0); + if (r != MAP_FAILED) + munmap(r, fs.st_size); + close(fd); + + /* OK, try some system calls to see if we get the arguments + * correctly. */ +#if (__LONG_MAX__ > __INT_MAX__) + rc = syscall (__NR_dup, (unsigned long)-12345, + (unsigned long)0xffffffffffffffff, + (unsigned long)0xa5a5a5a5a5a5a5a5, + (unsigned long)0xf0f0f0f0f0f0f0f0, + (unsigned long)0x5a5a5a5a5a5a5a5a, + (unsigned long)0xe38e38e38e38e38e); +#else + rc = syscall (__NR_dup, (unsigned long)-12345, + (unsigned long)0xffffffff, + (unsigned long)0xa5a5a5a5, + (unsigned long)0xf0f0f0f0, + (unsigned long)0x5a5a5a5a, + (unsigned long)0xe38e38e3); +#endif +#if (__LONG_MAX__ > __INT_MAX__) + rc = syscall ((unsigned long)-1, + (unsigned long)0x1c71c71c71c71c71, + (unsigned long)0x0f0f0f0f0f0f0f0f, + (unsigned long)0xdb6db6db6db6db6d, + (unsigned long)0x2492492492492492, + (unsigned long)0xad6b5ad6b5ad6b5a, + (unsigned long)0xdef7ddef7ddef7dd); +#else + rc = syscall ((unsigned long)-1, + (unsigned long)0x1c71c71c, + (unsigned long)0x0f0f0f0f, + (unsigned long)0xdb6db6db, + (unsigned long)0x24924924, + (unsigned long)0xad6b5ad6, + (unsigned long)0xdef7ddef); +#endif + return 0; +} diff --git a/testsuite/systemtap.base/utrace_syscall_args.exp b/testsuite/systemtap.base/utrace_syscall_args.exp new file mode 100644 index 00000000..98bc457e --- /dev/null +++ b/testsuite/systemtap.base/utrace_syscall_args.exp @@ -0,0 +1,82 @@ +# Utrace system call argument tests. + +set flags "" +set srcpath "$srcdir/$subdir/utrace_syscall_args.c" +set exepath "[pwd]/utrace_syscall_args" +set stppath "$srcdir/$subdir/utrace_syscall_args.stp" + +set output_string "mmap\\(\[0-9\]+\\)\\(0x\[0-9a-f]+, 0x\[0-9a-f]+, 0x\[0-9a-f]+, 0x\[0-9a-f]+, 0x\[0-9a-f]+, 0x\[0-9a-f]+\\) = 0x\[0-9a-f]+\r\nmunmap\\(\[0-9\]+\\)\\(0x\[0-9a-f]+, 0x\[0-9a-f]+\\) = 0x\[0-9a-f]+\r\nclose\\(\[0-9\]+\\)\\(0x\[0-9a-f]+\\) = 0x\[0-9a-f]+\r\ndup\\(\[0-9\]+\\)\\(0x\[0-9a-f]+, 0x\[0-9a-f]+, 0x\[0-9a-f]+, 0x\[0-9a-f]+, 0x\[0-9a-f]+, 0x\[0-9a-f]+\\) = 0x\[0-9a-f]+\r\nbad_syscall\\(-?\[0-9\]+\\)\\(0x\[0-9a-f]+, 0x\[0-9a-f]+, 0x\[0-9a-f]+, 0x\[0-9a-f]+, 0x\[0-9a-f]+, 0x\[0-9a-f]+\\) = 0x\[0-9a-f]+\r\nsystemtap test success\r\n" + +# For first pass, force 64-bit compilation for 64-bit systems. Add +# any other 64-bit architecture you want tested below. +# +# To find tcl's platform name for your machine, run the following: +# echo "puts $::tcl_platform(machine)" | tclsh + +switch -regexp $::tcl_platform(machine) { + ^ia64$ { + set do_64_bit_pass 1 + set flags "" + } + ^(x86_64|ppc64|s390x)$ { + set do_64_bit_pass 1 + set flags "additional_flags=-m64" + } + default { + set do_64_bit_pass 0 + } +} + +if {$do_64_bit_pass} { + set testname "64_BIT_UTRACE_SYSCALL_ARGS" + if {![installtest_p]} { untested $testname; continue } + if {![utrace_p]} { untested $testname; continue } + send_log "Testing ${testname}\n" + + # Compile our test program. + set res [target_compile $srcpath $exepath executable $flags] + if { $res != "" } { + verbose "target_compile for $exepath failed: $res" 2 + fail "$testname: unable to compile $srcpath" + return + } + + # Run the test. + stap_run $testname no_load $output_string -g $stppath -c $exepath + + catch {exec rm -f $exepath foobar} +} + +# The second pass is for systems that support 32-bit executables +# (either exclusively or in addition to 64-bit executables). +set do_32_bit_pass 1 +switch -regexp $::tcl_platform(machine) { + ^(x86_64|ppc64)$ { + set flags "additional_flags=-m32" + } + ^s390x$ { + set flags "additional_flags=-m31" + } + ^ia64$ { + set do_32_bit_pass 0 + } +} + +if {$do_32_bit_pass} { + set testname "32_BIT_UTRACE_SYSCALL_ARGS" + if {![installtest_p]} { untested $testname; continue } + if {![utrace_p]} { untested $testname; continue } + send_log "Testing ${testname}\n" + + # Compile our test program + set res [target_compile $srcpath $exepath executable $flags] + if { $res != "" } { + verbose "target_compile for $exepath failed: $res" 2 + fail "$testname: unable to compile $srcpath" + return + } + + stap_run $testname no_load $output_string -g $stppath -c $exepath + + catch {exec rm -f $exepath foobar} +} diff --git a/testsuite/systemtap.base/utrace_syscall_args.stp b/testsuite/systemtap.base/utrace_syscall_args.stp new file mode 100644 index 00000000..166e1ace --- /dev/null +++ b/testsuite/systemtap.base/utrace_syscall_args.stp @@ -0,0 +1,366 @@ +%{ +#include "syscall.h" +%} + +function mmap_syscall_no:long () %{ + THIS->__retvalue = MMAP_SYSCALL_NO(current); /* pure */ +%} +function mmap2_syscall_no:long () %{ + THIS->__retvalue = MMAP2_SYSCALL_NO(current); /* pure */ +%} +function munmap_syscall_no:long () %{ + THIS->__retvalue = MUNMAP_SYSCALL_NO(current); /* pure */ +%} + +global syscalls_seen = 0 +global failures = 0 + +global mmap_found = 0 +global mmap_args[10] + +global munmap_found = 0 +global munmap_args[10] + +global close_found = 0 +global close_args[10] + +global dup_found = 0 +global dup_args[10] + +global bad_syscall_found = 0 +global bad_syscall_args[10] + +probe begin +{ + printf("systemtap starting probe\n") +} + +probe syscall.open { + if (filename == "foobar") { + syscalls_seen += 1 + } +} + +probe process("utrace_syscall_args").syscall { + if (syscalls_seen >= 2) { + syscalls_seen += 1 + + # We skip the fstat() syscall, which is the 1st syscall after + # the open() by not looking at 'syscalls_seen == 3'. + + if (syscalls_seen == 4 && ($syscall == mmap_syscall_no() + || $syscall == mmap2_syscall_no())) { + mmap_found = 1 + mmap_args[0] = $syscall + mmap_args[1] = $arg1 + mmap_args[2] = $arg2 + mmap_args[3] = $arg3 + mmap_args[4] = $arg4 + mmap_args[5] = $arg5 + mmap_args[6] = $arg6 + +%(arch == "s390x" %? + # s390 requires this for mmap. Verified by running: + # # strace strace utrace_syscall_args + addr = mmap_args[1] + mmap_args[1] = user_long(addr) + addr += 8 + mmap_args[2] = user_long(addr) + addr += 8 + mmap_args[3] = user_long(addr) + addr += 8 + mmap_args[4] = user_long(addr) + addr += 8 + mmap_args[5] = user_long(addr) + addr += 8 + mmap_args[6] = user_long(addr) +%) + } + else if (syscalls_seen == 5 && $syscall == munmap_syscall_no()) { + munmap_found = 1 + munmap_args[0] = $syscall + munmap_args[1] = $arg1 + munmap_args[2] = $arg2 + } + else if (syscalls_seen == 6) { + close_found = 1 + close_args[0] = $syscall + close_args[1] = $arg1 + } + else if (syscalls_seen == 7) { + dup_found = 1 + dup_args[0] = $syscall + dup_args[1] = $arg1 + dup_args[2] = $arg2 + dup_args[3] = $arg3 + dup_args[4] = $arg4 + dup_args[5] = $arg5 + dup_args[6] = $arg6 + } + else if (syscalls_seen == 8) { + bad_syscall_found = 1 + bad_syscall_args[0] = $syscall + bad_syscall_args[1] = $arg1 + bad_syscall_args[2] = $arg2 + bad_syscall_args[3] = $arg3 + bad_syscall_args[4] = $arg4 + bad_syscall_args[5] = $arg5 + bad_syscall_args[6] = $arg6 + } + } +} +probe process("utrace_syscall_args").syscall.return { + if (syscalls_seen >= 4) { + if (syscalls_seen == 4) { + mmap_args[7] = $return + } + else if (syscalls_seen == 5) { + munmap_args[3] = $return + } + else if (syscalls_seen == 6) { + close_args[2] = $return + } + else if (syscalls_seen == 7) { + dup_args[7] = $return + } + else if (syscalls_seen == 8) { + bad_syscall_args[7] = $return + syscalls_seen = 0 + } + } +} + +probe end +{ + printf("systemtap ending probe\n") + + # print mmap info + if (mmap_found == 0) { + printf("error: no mmap system call found\n") + failures += 1 + } + else { + printf("mmap(%d)(0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x) = 0x%x\n", + mmap_args[0], mmap_args[1], mmap_args[2], mmap_args[3], + mmap_args[4], mmap_args[5], mmap_args[6], mmap_args[7]) + + # Validate arguments. We can only check certain arguments. + # It is possible that mmap's 'prot' and 'flags' arguments + # could vary per platform, so we'll ignore them. + if (mmap_args[1] != 0) { + failures += 1 + printf("mmap bad arg 1: 0x%x vs 0x0\n", mmap_args[1]) + } + if (mmap_args[2] != 0x406) { + failures += 1 + printf("mmap bad arg 2: 0x%x vs 0x406\n", mmap_args[2]) + } + if (mmap_args[6] != 0) { + failures += 1 + printf("mmap bad arg 6: 0x%x vs 0x0\n", mmap_args[6]) + } + } + + # print munmap info + if (munmap_found == 0) { + printf("error: no munmap system call found\n") + failures += 1 + } + else if (munmap_found == 0 || mmap_found == 0) { + printf("error: no munmap/mmap system call found\n") + failures += 1 + } + else { + printf("munmap(%d)(0x%x, 0x%x) = 0x%x\n", + munmap_args[0], munmap_args[1], munmap_args[2], munmap_args[3]) + + # Validate arguments. munmap()'s first argument should be the + # same as the mmap() return value. + if (munmap_args[1] != mmap_args[7]) { + failures += 1 + printf("munmap bad arg 1: 0x%x vs 0x%x\n", munmap_args[1], + mmap_args[7]) + } + if (munmap_args[2] != mmap_args[2]) { + failures += 1 + printf("munmap bad arg 2: 0x%x vs 0x%x\n", munmap_args[2], + mmap_args[2]) + } + # Validate return value + if (munmap_args[7] != 0) { + failures += 1 + printf("munmap bad return value: 0x%x vs 0x0\n", munmap_args[7]) + } + } + + # print close info + if (close_found == 0) { + printf("error: no close system call found\n") + failures += 1 + } + else if (close_found == 1) { + printf("close(%d)(0x%x) = 0x%x\n", + close_args[0], close_args[1], close_args[2]) + + if (mmap_args[5] != close_args[1]) { + failures += 1 + printf("close bad arg 1: 0x%x vs 0x%x\n", + close_args[0], mmap_args[5]) + } + } + + # print dup info + if (dup_found == 0) { + printf("error: no dup system call found\n") + failures += 1 + } + else { + printf("dup(%d)(0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x) = 0x%x\n", + dup_args[0], dup_args[1], dup_args[2], dup_args[3], + dup_args[4], dup_args[5], dup_args[6], dup_args[7]) + + # Validate arguments - handle 32-bit vs. 64-bit. + if ((dup_args[1] & 0xffffffff00000000) != 0) { + if (dup_args[1] != 0xffffffffffffcfc7) { + failures += 1 + printf("dup bad arg 1: 0x%x vs 0xffffffffffffcfc7\n", + dup_args[1]) + } + if (dup_args[2] != 0xffffffffffffffff) { + failures += 1 + printf("dup bad arg 2: 0x%x vs 0xffffffffffffffff\n", + dup_args[2]) + } + if (dup_args[3] != 0xa5a5a5a5a5a5a5a5) { + failures += 1 + printf("dup bad arg 3: 0x%x vs 0xa5a5a5a5a5a5a5a5\n", + dup_args[3]) + } + if (dup_args[4] != 0xf0f0f0f0f0f0f0f0) { + failures += 1 + printf("dup bad arg 4: 0x%x vs 0xf0f0f0f0f0f0f0f0\n", + dup_args[4]) + } + if (dup_args[5] != 0x5a5a5a5a5a5a5a5a) { + failures += 1 + printf("dup bad arg 5: 0x%x vs 0x5a5a5a5a5a5a5a5a\n", + dup_args[5]) + } + if (dup_args[6] != 0xe38e38e38e38e38e) { + failures += 1 + printf("dup bad arg 6: 0x%x vs 0xe38e38e38e38d38e\n", + dup_args[6]) + } + } + else { + if (dup_args[1] != 0xffffcfc7) { + failures += 1 + printf("dup bad arg 1: 0x%x vs 0xffffcfc7\n", dup_args[1]) + } + if (dup_args[2] != 0xffffffff) { + failures += 1 + printf("dup bad arg 2: 0x%x vs 0xffffffff\n", dup_args[2]) + } + if (dup_args[3] != 0xa5a5a5a5) { + failures += 1 + printf("dup bad arg 3: 0x%x vs 0xa5a5a5a5\n", dup_args[3]) + } + if (dup_args[4] != 0xf0f0f0f0) { + failures += 4 + printf("dup bad arg 4: 0x%x vs 0xf0f0f0f0\n", dup_args[4]) + } + if (dup_args[5] != 0x5a5a5a5a) { + failures += 1 + printf("dup bad arg 5: 0x%x vs 0x5a5a5a5a\n", dup_args[5]) + } + if (dup_args[6] != 0xe38e38e3) { + failures += 1 + printf("dup bad arg 6: 0x%x vs 0xe38e38e3\n", dup_args[6]) + } + } + } + + # print bad_syscall info + if (bad_syscall_found == 0) { + printf("error: no bad_syscall system call found\n") + failures += 1 + } + else { + printf("bad_syscall(%d)(0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x) = 0x%x\n", + bad_syscall_args[0], bad_syscall_args[1], bad_syscall_args[2], bad_syscall_args[3], + bad_syscall_args[4], bad_syscall_args[5], bad_syscall_args[6], bad_syscall_args[7]) + + # Validate arguments - handle 32-bit vs. 64-bit. + if (bad_syscall_args[1] > 0xffffffff) { + if (bad_syscall_args[1] != 0x1c71c71c71c71c71) { + failures += 1 + printf("bad_syscall bad arg 1: 0x%x vs 0x1c71c71c71c71c71\n", + bad_syscall_args[1]) + } + if (bad_syscall_args[2] != 0x0f0f0f0f0f0f0f0f) { + failures += 1 + printf("bad_syscall bad arg 2: 0x%x vs 0x0f0f0f0f0f0f0f0f\n", + bad_syscall_args[2]) + } + if (bad_syscall_args[3] != 0xdb6db6db6db6db6d) { + failures += 1 + printf("bad_syscall bad arg 3: 0x%x vs 0xdb6db6db6db6db6d\n", + bad_syscall_args[3]) + } + if (bad_syscall_args[4] != 0x2492492492492492) { + failures += 1 + printf("bad_syscall bad arg 4: 0x%x vs 0x2492492492492492\n", + bad_syscall_args[4]) + } + if (bad_syscall_args[5] != 0xad6b5ad6b5ad6b5a) { + failures += 1 + printf("bad_syscall bad arg 5: 0x%x vs 0xad6b5ad6b5ad6b5a\n", + bad_syscall_args[5]) + } + if (bad_syscall_args[6] != 0xdef7ddef7ddef7dd) { + failures += 1 + printf("bad_syscall bad arg 6: 0x%x vs 0xdef7ddef7ddef7dd\n", + bad_syscall_args[6]) + } + } + else { + if (bad_syscall_args[1] != 0x1c71c71c) { + failures += 1 + printf("bad_syscall bad arg 1: 0x%x vs 0x1c71c71c\n", + bad_syscall_args[1]) + } + if (bad_syscall_args[2] != 0x0f0f0f0f) { + failures += 1 + printf("bad_syscall bad arg 2: 0x%x vs 0x0f0f0f0f\n", + bad_syscall_args[2]) + } + if (bad_syscall_args[3] != 0xdb6db6db) { + failures += 1 + printf("bad_syscall bad arg 3: 0x%x vs 0xdb6db6db\n", + bad_syscall_args[3]) + } + if (bad_syscall_args[4] != 0x24924924) { + failures += 4 + printf("bad_syscall bad arg 4: 0x%x vs 0x24924924\n", + bad_syscall_args[4]) + } + if (bad_syscall_args[5] != 0xad6b5ad6) { + failures += 1 + printf("bad_syscall bad arg 5: 0x%x vs 0xad6b5ad6\n", + bad_syscall_args[5]) + } + if (bad_syscall_args[6] != 0xdef7ddef) { + failures += 1 + printf("bad_syscall bad arg 6: 0x%x vs 0xdef7ddef\n", + bad_syscall_args[6]) + } + } + } + + if (failures == 0) { + printf("systemtap test success\n") + } + else { + printf("systemtap test failure\n") + } +} -- cgit From 436e5bf634020bcb9f98967891508db21f9e6cbd Mon Sep 17 00:00:00 2001 From: Jim Keniston Date: Mon, 20 Apr 2009 16:39:26 -0700 Subject: PR10078: uretprobes on functions returning structs/unions arch_predict_sp_at_ret() for x86_32 now accommodates ret $4. Added bz10078 regression test. --- testsuite/systemtap.base/bz10078.c | 22 ++++++++++++++++++++++ testsuite/systemtap.base/bz10078.exp | 35 +++++++++++++++++++++++++++++++++++ testsuite/systemtap.base/bz10078.stp | 4 ++++ 3 files changed, 61 insertions(+) create mode 100644 testsuite/systemtap.base/bz10078.c create mode 100644 testsuite/systemtap.base/bz10078.exp create mode 100644 testsuite/systemtap.base/bz10078.stp (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/bz10078.c b/testsuite/systemtap.base/bz10078.c new file mode 100644 index 00000000..9075fbc7 --- /dev/null +++ b/testsuite/systemtap.base/bz10078.c @@ -0,0 +1,22 @@ +#include +#include + +struct point { int x, y; }; + +struct point mkpoint2(void) +{ + struct point p = { 1, 2 }; + return p; +} + +struct point mkpoint1(void) +{ + return mkpoint2(); +} + +main() +{ + struct point p = mkpoint1(); + printf("%d,%d\n", p.x, p.y); + exit(0); +} diff --git a/testsuite/systemtap.base/bz10078.exp b/testsuite/systemtap.base/bz10078.exp new file mode 100644 index 00000000..cad3a3a8 --- /dev/null +++ b/testsuite/systemtap.base/bz10078.exp @@ -0,0 +1,35 @@ +set test bz10078 + +catch {exec gcc -g -o $test $srcdir/$subdir/$test.c} err +if {$err == "" && [file exists $test]} then { pass "$test compile" } else { fail "$test compile" } + +if {![utrace_p]} { + catch {exec rm -f $test} + untested "$test -p4" + untested "$test -p5" + return +} + +set rc [stap_run_batch $srcdir/$subdir/$test.stp] +if {$rc == 0} then { pass "$test -p4" } else { fail "$test -p4" } + +if {! [installtest_p]} { + catch {exec rm -f $test} + untested "$test -p5" + return +} + +# Pick up the stap being tested. +set stapexe [exec /usr/bin/which stap] +spawn sudo $stapexe $srcdir/$subdir/$test.stp -c ./$test +set ok 0 +expect { + -timeout 60 + -re {mkpoint[^\r\n]* returns\r\n} { incr ok; exp_continue } + -re {1,2\r\n} { incr ok; exp_continue } + timeout { fail "$test (timeout)" } + eof { } +} +wait +if {$ok == 3} then { pass "$test -p5" } else { fail "$test -p5 ($ok)" } +exec rm -f $test diff --git a/testsuite/systemtap.base/bz10078.stp b/testsuite/systemtap.base/bz10078.stp new file mode 100644 index 00000000..0318e4e9 --- /dev/null +++ b/testsuite/systemtap.base/bz10078.stp @@ -0,0 +1,4 @@ +#! stap -p4 +probe process("./bz10078").function("mkpoint*").return { + printf("%s returns\n", probefunc()) +} -- cgit From 219b3700b8603b6fe3610d6f06e353f3c041ee0b Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Mon, 20 Apr 2009 17:18:32 -0700 Subject: Add tests for @cast-generated modules --- testsuite/systemtap.base/cast.exp | 6 ++++-- testsuite/systemtap.base/cast.stp | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/cast.exp b/testsuite/systemtap.base/cast.exp index df3246e8..74c4d72a 100644 --- a/testsuite/systemtap.base/cast.exp +++ b/testsuite/systemtap.base/cast.exp @@ -1,4 +1,6 @@ set test "cast" set ::result_string {PID OK -execname OK} -stap_run2 $srcdir/$subdir/$test.stp +PID2 OK +execname OK +tv_sec OK} +stap_run2 $srcdir/$subdir/$test.stp -g diff --git a/testsuite/systemtap.base/cast.stp b/testsuite/systemtap.base/cast.stp index bec0cc9b..33a14a28 100644 --- a/testsuite/systemtap.base/cast.stp +++ b/testsuite/systemtap.base/cast.stp @@ -10,6 +10,13 @@ probe begin else printf("PID %d != %d\n", pid, cast_pid) + // Compare PIDs using a generated kernel module + cast_pid = @cast(curr, "task_struct", "kmod")->tgid + if (pid == cast_pid) + println("PID2 OK") + else + printf("PID2 %d != %d\n", pid, cast_pid) + // Compare execnames name = execname() cast_name = kernel_string(@cast(curr, "task_struct")->comm) @@ -18,5 +25,19 @@ probe begin else printf("execname \"%s\" != \"%s\"\n", name, cast_name) + // Compare tv_sec using a generated user module + sec = 42 + cast_sec = @cast(get_timeval(sec), "timeval", "umod")->tv_sec + if (sec == cast_sec) + println("tv_sec OK") + else + printf("tv_sec %d != %d\n", sec, cast_sec) + exit() } + +function get_timeval:long(sec:long) %{ + static struct timeval mytime = {0}; + mytime.tv_sec = THIS->sec; + THIS->__retvalue = (long)&mytime; +%} -- cgit From 543b26ed48ac66743ad309ac6cb848a5d377260f Mon Sep 17 00:00:00 2001 From: Ananth N Mavinakayanahalli Date: Tue, 21 Apr 2009 17:19:15 +0530 Subject: Add testcases for kprobe.function family --- testsuite/systemtap.base/kprobes.exp | 2 ++ testsuite/systemtap.base/kprobes.stp | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 testsuite/systemtap.base/kprobes.exp create mode 100644 testsuite/systemtap.base/kprobes.stp (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/kprobes.exp b/testsuite/systemtap.base/kprobes.exp new file mode 100644 index 00000000..240ecd82 --- /dev/null +++ b/testsuite/systemtap.base/kprobes.exp @@ -0,0 +1,2 @@ +set test "kprobes" +stap_run $srcdir/$subdir/$test.stp diff --git a/testsuite/systemtap.base/kprobes.stp b/testsuite/systemtap.base/kprobes.stp new file mode 100644 index 00000000..62c18347 --- /dev/null +++ b/testsuite/systemtap.base/kprobes.stp @@ -0,0 +1,21 @@ +/* + * kprobes.stp + * Probe to test the functionality of kprobe-based probes + * (Dwarfless Probing) + */ + +probe begin +{ + println("\n Systemtap starting probe"); +} + +probe kprobe.function("vfs_read") +{ + printf("\n probe point hit"); + exit(); +} + +probe end +{ + println("\n Systemtap starting probe"); +} -- cgit From d0ea46ceac2e72fe0b86269ea50c004711148158 Mon Sep 17 00:00:00 2001 From: David Smith Date: Tue, 21 Apr 2009 08:21:34 -0500 Subject: Correctly handle $syscall in process(PID_OR_PATH).syscall.return probes. 2009-04-21 David Smith * tapsets.cxx (utrace_derived_probe::utrace_derived_probe): If during target-variable-expanding the probe, we added a new block or probe, add them. (utrace_var_expanding_visitor::visit_target_symbol_cached): New function to cache target variables in a generated syscall probe to use in syscall.return probes. (utrace_var_expanding_visitor::visit_target_symbol_context): In a syscall.return probe, you can't access $syscall. So use visit_target_symbol_cached() to cache the value for use here. * testsuite/systemtap.base/utrace_syscall_args.stp: Test use of $syscall in syscall.return probes. --- testsuite/systemtap.base/utrace_syscall_args.stp | 40 ++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/utrace_syscall_args.stp b/testsuite/systemtap.base/utrace_syscall_args.stp index 166e1ace..6c9e14fc 100644 --- a/testsuite/systemtap.base/utrace_syscall_args.stp +++ b/testsuite/systemtap.base/utrace_syscall_args.stp @@ -113,18 +113,23 @@ probe process("utrace_syscall_args").syscall.return { if (syscalls_seen >= 4) { if (syscalls_seen == 4) { mmap_args[7] = $return + mmap_args[8] = $syscall } else if (syscalls_seen == 5) { munmap_args[3] = $return + munmap_args[4] = $syscall } else if (syscalls_seen == 6) { close_args[2] = $return + close_args[3] = $syscall } else if (syscalls_seen == 7) { dup_args[7] = $return + dup_args[8] = $syscall } else if (syscalls_seen == 8) { bad_syscall_args[7] = $return + bad_syscall_args[8] = $syscall syscalls_seen = 0 } } @@ -159,6 +164,13 @@ probe end failures += 1 printf("mmap bad arg 6: 0x%x vs 0x0\n", mmap_args[6]) } + + # Validate syscall number + if (mmap_args[0] != mmap_args[8]) { + failures += 1 + printf("mmap $syscall mismatch: %d vs. %d\n", + mmap_args[0], mmap_args[8]) + } } # print munmap info @@ -191,6 +203,13 @@ probe end failures += 1 printf("munmap bad return value: 0x%x vs 0x0\n", munmap_args[7]) } + + # Validate syscall number + if (munmap_args[0] != munmap_args[4]) { + failures += 1 + printf("munmap $syscall mismatch: %d vs. %d\n", + munmap_args[0], munmap_args[4]) + } } # print close info @@ -207,6 +226,13 @@ probe end printf("close bad arg 1: 0x%x vs 0x%x\n", close_args[0], mmap_args[5]) } + + # Validate syscall number + if (close_args[0] != close_args[3]) { + failures += 1 + printf("close $syscall mismatch: %d vs. %d\n", + close_args[0], close_args[3]) + } } # print dup info @@ -278,6 +304,13 @@ probe end printf("dup bad arg 6: 0x%x vs 0xe38e38e3\n", dup_args[6]) } } + + # Validate syscall number + if (dup_args[0] != dup_args[8]) { + failures += 1 + printf("dup $syscall mismatch: %d vs. %d\n", + dup_args[0], dup_args[8]) + } } # print bad_syscall info @@ -355,6 +388,13 @@ probe end bad_syscall_args[6]) } } + + # Validate syscall number + if (bad_syscall_args[0] != bad_syscall_args[8]) { + failures += 1 + printf("bad_syscall $syscall mismatch: %d vs. %d\n", + bad_syscall_args[0], bad_syscall_args[8]) + } } if (failures == 0) { -- cgit From 2f2fa6c0b102537d92a1148d8b00431077d5eb7a Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Tue, 21 Apr 2009 19:44:55 +0200 Subject: Add uprobes_ustack testcase and bug fixlet. * runtime/stack.c (_stp_stack_print): Use _stp_usymbol_print when tsk given. * testsuite/systemtap.base/uprobes_ustack.exp: New test file. * testsuite/systemtap.base/uprobes_ustack.stp: Likewise. --- testsuite/systemtap.base/uprobes_ustack.exp | 94 +++++++++++++++++++++++++++++ testsuite/systemtap.base/uprobes_ustack.stp | 35 +++++++++++ 2 files changed, 129 insertions(+) create mode 100644 testsuite/systemtap.base/uprobes_ustack.exp create mode 100644 testsuite/systemtap.base/uprobes_ustack.stp (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/uprobes_ustack.exp b/testsuite/systemtap.base/uprobes_ustack.exp new file mode 100644 index 00000000..f085fc16 --- /dev/null +++ b/testsuite/systemtap.base/uprobes_ustack.exp @@ -0,0 +1,94 @@ +set test "uprobes_ustack" +set testpath "$srcdir/$subdir" +set testsrc "$testpath/uprobes_exe.c" +set testsrclib "$testpath/uprobes_lib.c" +set testexe "./uprobes_exe" +set testlibname "uprobes_lib" +set testlibdir "." +set testso "$testlibdir/lib${testlibname}.so" +set testflags "additional_flags=-g additional_flags=-O" +set testlibflags "$testflags additional_flags=-fPIC additional_flags=-shared" +set maintestflags "$testflags additional_flags=-L$testlibdir additional_flags=-l$testlibname additional_flags=-Wl,-rpath,$testlibdir" + +# Compile our test program and library. +set res [target_compile $testsrclib $testso executable $testlibflags] +if { $res != "" } { + verbose "target_compile for $testso failed: $res" 2 + fail "$test compile $testsrclib" + return +} else { + pass "$test compile $testsrclib" +} + +set res [target_compile $testsrc $testexe executable $maintestflags] +if { $res != "" } { + verbose "target_compile failed: $res" 2 + fail "$test compile $testsrc" + return +} else { + pass "$test compile $testsrc" +} + +set ::result_string {exe: main=main +exe: main_func=main_func +exe: main_func=main_func +exe: main_func=main_func +lib: lib_main=lib_main +lib: lib_func=lib_func +lib: lib_func=lib_func +lib: lib_func=lib_func} + +# Only run on make installcheck +if {! [installtest_p]} { untested "$test"; return } +if {! [utrace_p]} { untested $test; return } + +# Output is: +#print_ubacktrace exe 0 +# 0x080484ba : main_func+0xa/0x29 [.../uprobes_exe] +# 0x080484f6 : main+0x1d/0x37 [.../uprobes_exe] +#print_ustack exe 1 +# 0x080484ba : main_func+0xa/0x29 [.../uprobes_exe] +# 0x080484c9 : main_func+0x19/0x29 [.../uprobes_exe] +# 0x080484f6 : main+0x1d/0x37 [.../uprobes_exe] +#print_ubacktrace lib 2 +# 0x00db2422 : lib_func+0x16/0x2b [.../libuprobes_lib.so] +# 0x00db2455 : lib_main+0x1e/0x29 [.../libuprobes_lib.so] +# 0x080484d0 : main_func+0x20/0x29 [.../uprobes_exe] +# 0x080484c9 : main_func+0x19/0x29 [.../uprobes_exe] +# 0x080484c9 : main_func+0x19/0x29 [.../uprobes_exe] +# 0x080484f6 : main+0x1d/0x37 [.../uprobes_exe] +#print_ustack lib 3 +# 0x00db2422 : lib_func+0x16/0x2b [.../libuprobes_lib.so] +# 0x00db2431 : lib_func+0x25/0x2b [.../libuprobes_lib.so] +# 0x00db2455 : lib_main+0x1e/0x29 [.../libuprobes_lib.so] +# 0x080484d0 : main_func+0x20/0x29 [.../uprobes_exe] +# 0x080484c9 : main_func+0x19/0x29 [.../uprobes_exe] +# 0x080484c9 : main_func+0x19/0x29 [.../uprobes_exe] +# 0x080484f6 : main+0x1d/0x37 [.../uprobes_exe] + +set print 0 +set main 0 +set main_func 0 +set lib_main 0 +set lib_func 0 +spawn stap $srcdir/$subdir/$test.stp -c $testexe + +wait +expect { + -timeout 60 + -re {^print_[^\r\n]+\r\n} {incr print; exp_continue} + -re {^ 0x[a-f0-9]+ : main\+0x[^\r\n]+\r\n} {incr main; exp_continue} + -re {^ 0x[a-f0-9]+ : main_func\+0x[^\r\n]+\r\n} {incr main_func; exp_continue} + -re {^ 0x[a-f0-9]+ : lib_main\+0x[^\r\n]+\r\n} {incr lib_main; exp_continue} + -re {^ 0x[a-f0-9]+ : lib_func\+0x[^\r\n]+\r\n} {incr lib_func; exp_continue} + timeout { fail "$test (timeout)" } + eof { } +} + +if {$print == 4} {pass "$test print"} {fail "$test print ($print)"} +if {$main == 4} {pass "$test main"} {fail "$test main ($main)"} +if {$main_func == 9} {pass "$test main_func"} {fail "$test main_func ($main_func)"} +if {$lib_main == 2} {pass "$test lib_main"} {fail "$test lib_main ($lib_main)"} +if {$lib_func == 3} {pass "$test lib_func"} {fail "$test lib_func ($lib_func)"} + +#exec rm -f $testexe $testso diff --git a/testsuite/systemtap.base/uprobes_ustack.stp b/testsuite/systemtap.base/uprobes_ustack.stp new file mode 100644 index 00000000..6de03b42 --- /dev/null +++ b/testsuite/systemtap.base/uprobes_ustack.stp @@ -0,0 +1,35 @@ +// Prints backtrace from lib through exe twice using diffent ustack functions. + +global hits = 0; + +probe process("uprobes_exe").function("main_func") +{ + if (hits == 0) + { + log("print_ubacktrace exe 0"); + print_ubacktrace(); + hits++; + } + else if (hits == 1) + { + log("print_ustack exe 1"); + print_ustack(ubacktrace()); + hits++; + } +} + +probe process("libuprobes_lib.so").function("lib_func") +{ + if (hits == 2) + { + log("print_ubacktrace lib 2"); + print_ubacktrace(); + hits++; + } + else if (hits == 3) + { + log("print_ustack lib 3"); + print_ustack(ubacktrace()); + hits++; + } +} -- cgit From 31a0ad65c838d0530b321c75c5b328828daa71ac Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Tue, 21 Apr 2009 21:33:24 +0200 Subject: Set MAXSTRINGLEN to 133 for uprobes_ustack.exp test on 64 bit. Needs extra space since on 64bit the last ubacktrace string is 7 entries * (16 hex + 2 for 0x + 1 space) = 133 chars. Default MAXSTRINGLEN is 128 chars. * testsuite/systemtap.base/uprobes_ustack.exp: Add -DMAXSTRINGLEN. --- testsuite/systemtap.base/uprobes_ustack.exp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/uprobes_ustack.exp b/testsuite/systemtap.base/uprobes_ustack.exp index f085fc16..bfc435e9 100644 --- a/testsuite/systemtap.base/uprobes_ustack.exp +++ b/testsuite/systemtap.base/uprobes_ustack.exp @@ -71,7 +71,10 @@ set main 0 set main_func 0 set lib_main 0 set lib_func 0 -spawn stap $srcdir/$subdir/$test.stp -c $testexe +# Needs extra space since on 64bit the last ubacktrace string is +# 7 entries * (16 hex + 2 for 0x + 1 space) = 133 chars. +# Default MAXSTRINGLEN is 128 chars. +spawn stap -DMAXSTRINGLEN=133 $srcdir/$subdir/$test.stp -c $testexe wait expect { -- cgit From d90053e72a515371936e10bf83ecb822aec91b17 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Tue, 21 Apr 2009 12:08:42 -0700 Subject: Refine the @cast-with-header syntax The special syntax to generate a module for type information is now: - "kernel" to use the kernel's build environment - "" to use no special build environment, and so use gcc's default parameters only (for user mode). --- testsuite/systemtap.base/cast.stp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/cast.stp b/testsuite/systemtap.base/cast.stp index 33a14a28..6298a06d 100644 --- a/testsuite/systemtap.base/cast.stp +++ b/testsuite/systemtap.base/cast.stp @@ -11,7 +11,7 @@ probe begin printf("PID %d != %d\n", pid, cast_pid) // Compare PIDs using a generated kernel module - cast_pid = @cast(curr, "task_struct", "kmod")->tgid + cast_pid = @cast(curr, "task_struct", "kernel")->tgid if (pid == cast_pid) println("PID2 OK") else @@ -27,7 +27,7 @@ probe begin // Compare tv_sec using a generated user module sec = 42 - cast_sec = @cast(get_timeval(sec), "timeval", "umod")->tv_sec + cast_sec = @cast(get_timeval(sec), "timeval", "")->tv_sec if (sec == cast_sec) println("tv_sec OK") else -- cgit From eee3e6dca7f1289ccb6795bc586fbda2dbe67188 Mon Sep 17 00:00:00 2001 From: Masami Hiramatsu Date: Wed, 22 Apr 2009 13:07:26 -0400 Subject: PR 6930: Add testcases for on-file flight recorder * testsuite/systemtap.base/flightrec1.exp: New test case for background mode. * testsuite/systemtap.base/flightrec2.exp: New test case for file switching. * testsuite/systemtap.base/flightrec2.stp: Test script for file switching. --- testsuite/systemtap.base/flightrec1.exp | 43 ++++++++++++++++++++ testsuite/systemtap.base/flightrec2.exp | 69 +++++++++++++++++++++++++++++++++ testsuite/systemtap.base/flightrec2.stp | 5 +++ 3 files changed, 117 insertions(+) create mode 100644 testsuite/systemtap.base/flightrec1.exp create mode 100644 testsuite/systemtap.base/flightrec2.exp create mode 100644 testsuite/systemtap.base/flightrec2.stp (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/flightrec1.exp b/testsuite/systemtap.base/flightrec1.exp new file mode 100644 index 00000000..c32a77f2 --- /dev/null +++ b/testsuite/systemtap.base/flightrec1.exp @@ -0,0 +1,43 @@ +set test "flightrec1" +if {![installtest_p]} { untested $test; return } + +# run stapio in background mode +spawn stap -F -o $test.out -we {probe begin {}} +# check whether stap outputs stapio pid +set pid 0 +expect { + -timeout 240 + -re {([0-9]+)\r\n} { + pass "$test (flight recorder option)" + set pid $expect_out(1,string) + exp_continue} + timeout { fail "$test (timeout)" } + eof { } +} +wait +if {$pid == 0} { + fail "$test (no pid)" + return -1 +} + +# check whether stapio is running in background +spawn ps -o cmd hc $pid +expect { + -timeout 10 + "stapio" {pass "$test (stapio in background)"} # don't contine + timeout { fail "$test (timeout)"} + eof { fail "$test (stapio was not found)" } +} +wait + +exec kill -TERM $pid + +# check output file +if {[catch {exec rm $test.out}]} { + fail "$test (no output file)" + return -1 +} else { + pass "$test (output file)" +} + + diff --git a/testsuite/systemtap.base/flightrec2.exp b/testsuite/systemtap.base/flightrec2.exp new file mode 100644 index 00000000..a22ef415 --- /dev/null +++ b/testsuite/systemtap.base/flightrec2.exp @@ -0,0 +1,69 @@ +set test "flightrec2" +if {![installtest_p]} { untested $test; return } + +# cleanup +system "rm -f flightlog.out*" + +set pid 0 +# check -S option +spawn stap -F -o flightlog.out -S 1,3 $srcdir/$subdir/$test.stp +expect { + -timeout 240 + -re {([0-9]+)\r\n} { + pass "$test (-S option)" + set pid $expect_out(1,string) + exp_continue} + timeout { fail "$test (timeout)"} + eof { } +} +wait +if {$pid == 0} { + fail "$test (no pid)" + return -1 +} + +exec sleep 4 +set scnt 0 +set cnt1 0 +# wait for log files +spawn ls -sk1 +expect { + -timeout 100 + -re {([0-9]+) flightlog\.out\.[0-9]+} { + incr cnt1; + if {$expect_out(1,string) <= 1028} {incr scnt} + # 1024 + 4(for inode blocks?) + exp_continue} + timeout { fail "$test (logfile timeout)"} +} +wait +exec sleep 3 +set cnt2 0 +# wait for log files +spawn ls -sk1 +expect { + -timeout 100 + -re {([0-9]+) flightlog\.out\.[0-9]+} { + incr cnt2; + if {$expect_out(1,string) <= 1028} {incr scnt} + exp_continue} + timeout { fail "$test (logfile timeout)"} +} +wait +# check logfile number +if {$cnt1 == 3 && $cnt2 == 3} { + pass "$test (log file numbers limitation)" +} else { + fail "$test (log file numbers ($cnt1, $cnt2))" +} +# check logfile size +if {$scnt == 6} { + pass "$test (log file size limitation)" +} else { + fail "$test (log file size ($scnt))" +} +exec kill -TERM $pid +# wait for exiting... +exec sleep 1 +system "rm -f flightlog.out*" + diff --git a/testsuite/systemtap.base/flightrec2.stp b/testsuite/systemtap.base/flightrec2.stp new file mode 100644 index 00000000..9d745f4b --- /dev/null +++ b/testsuite/systemtap.base/flightrec2.stp @@ -0,0 +1,5 @@ +probe timer.ms(1) +{ + for (j = 0; j < 100; j++) + printf("1234567890\n") +} -- cgit From 055b3e70a42e14453ad051de1a51de84b728b984 Mon Sep 17 00:00:00 2001 From: Masami Hiramatsu Date: Wed, 22 Apr 2009 13:18:01 -0400 Subject: PR 9821: Add a testcase for strftime * testsuite/systemtap.base/strftime.exp: New test case for strftime. --- testsuite/systemtap.base/strftime.exp | 49 +++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 testsuite/systemtap.base/strftime.exp (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/strftime.exp b/testsuite/systemtap.base/strftime.exp new file mode 100644 index 00000000..ad9e471d --- /dev/null +++ b/testsuite/systemtap.base/strftime.exp @@ -0,0 +1,49 @@ +set test "strftime" +if {![installtest_p]} { untested $test; return } +# cleanup +system "rm -f %*" + +# check %S and %T +set format %%%S_%T +exec stap -o $format -we {probe begin {println("hello");exit()}} + +spawn ls -1 +set ok 0 +expect { + -re {%([0-9][0-9])_[0-9][0-9]:[0-9][0-9]:\1} {incr ok} + eof { } +} +wait + +if {$ok == 1} { + pass "$test (%S and %T)" +} else { + fail "$test (%S and %T)" +} + +# check except for %S and %T +set format %%,%C,%Y,%y,%m,%d,%e,%F,%H,%I,%j,%k,%l,%M,%R,%u,%w + +set date1 [exec date +$format] +# run stapio with strftime +exec stap -o $format -we {probe begin {println("hello");exit()}} +# check whether stap outputs stapio pid +set date2 [exec date +$format] + +spawn ls -1 +set ok 0 +expect { + $date1 {incr ok} + $date2 {incr ok} + eof { } +} +wait + +if {$ok == 1} { + pass "$test (except %S and %T)" +} else { + fail "$test (except %S and %T)" +} + +# cleanup +system "rm -f %*" -- cgit From 6594f3f41e1d8d9ccb1e89d6734c0fd4da121fc0 Mon Sep 17 00:00:00 2001 From: Wenji Huang Date: Wed, 22 Apr 2009 22:44:05 -0400 Subject: Modify the output of kprobes test. * testsuite/systemtap.base/kprobes.stp: Update text. --- testsuite/systemtap.base/kprobes.stp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/kprobes.stp b/testsuite/systemtap.base/kprobes.stp index 62c18347..a3aad283 100644 --- a/testsuite/systemtap.base/kprobes.stp +++ b/testsuite/systemtap.base/kprobes.stp @@ -6,16 +6,15 @@ probe begin { - println("\n Systemtap starting probe"); + println("systemtap starting probe"); } probe kprobe.function("vfs_read") { - printf("\n probe point hit"); exit(); } probe end { - println("\n Systemtap starting probe"); + println("systemtap ending probe"); } -- cgit From 3add5ff43e63d4d4d5547a75a8b49fb6d6b99341 Mon Sep 17 00:00:00 2001 From: Wenji Huang Date: Thu, 23 Apr 2009 00:09:12 -0400 Subject: Tweak kprobes test case * testsuite/systemtap.base/kprobes.exp: Add expected message. * testsuite/systemtap.base/kprobes.stp: Ditto. --- testsuite/systemtap.base/kprobes.exp | 2 +- testsuite/systemtap.base/kprobes.stp | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/kprobes.exp b/testsuite/systemtap.base/kprobes.exp index 240ecd82..635930f8 100644 --- a/testsuite/systemtap.base/kprobes.exp +++ b/testsuite/systemtap.base/kprobes.exp @@ -1,2 +1,2 @@ set test "kprobes" -stap_run $srcdir/$subdir/$test.stp +stap_run $srcdir/$subdir/$test.stp no_load "probe point hit" diff --git a/testsuite/systemtap.base/kprobes.stp b/testsuite/systemtap.base/kprobes.stp index a3aad283..884b321c 100644 --- a/testsuite/systemtap.base/kprobes.stp +++ b/testsuite/systemtap.base/kprobes.stp @@ -3,18 +3,23 @@ * Probe to test the functionality of kprobe-based probes * (Dwarfless Probing) */ +global hit_str probe begin { println("systemtap starting probe"); + hit_str = "" } probe kprobe.function("vfs_read") { + hit_str = "probe point hit" exit(); } probe end { println("systemtap ending probe"); + println(hit_str); + delete hit_str; } -- cgit From 5badd4d0d1fc3f7dce2dc26a3ad5a69275ff07d2 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Fri, 24 Apr 2009 18:07:12 -0700 Subject: Don't terminate when a dwarfless kprobe fails All of our other kprobe types will let the script continue after a registration failure, as per PR6749. The dwarfless kprobes should be no exception. Also, the way they were exiting was causing an unclean shutdown, so I added tests to badkprobe.exp to make sure that cleanup is always allowed to run. --- testsuite/systemtap.base/badkprobe.exp | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/badkprobe.exp b/testsuite/systemtap.base/badkprobe.exp index efc06695..c0815fbe 100644 --- a/testsuite/systemtap.base/badkprobe.exp +++ b/testsuite/systemtap.base/badkprobe.exp @@ -1,14 +1,28 @@ -set script "probe kernel.statement(-1).absolute {} probe timer.s(1) { exit() }" set test "bad kprobe registration" +set script { + probe $1 {} + probe timer.s(1) { exit() } + probe end { println("cleanup ok") } +} if {! [installtest_p]} { untested $test; return } -spawn stap -g -w -e "$script" -expect { - -timeout 60 - -re "^WARNING: probe .*registration error.*" { pass $test } - eof { fail "$test (eof)" } - timeout { fail "$test (timeout)" } +set bad_kprobes { + kernel.statement(-1).absolute + kprobe.statement(-1).absolute + kprobe.function("no_such_function") + kprobe.function("no_such_function").return +} + +foreach bk $bad_kprobes { + set test "bad kprobe registration: $bk" + spawn stap -g -w -e "$script" "$bk" + expect { + -timeout 60 + -re "^WARNING: probe .*registration error.*\r\ncleanup ok" { pass $test } + eof { fail "$test (eof)" } + timeout { fail "$test (timeout)" } + } + catch {close} + catch {wait} } -catch {close} -catch {wait} -- cgit From ed82b7c902d6a2e26452ec51c9cdb9665dbf9e97 Mon Sep 17 00:00:00 2001 From: Wenji Huang Date: Mon, 27 Apr 2009 22:35:05 -0400 Subject: PR10102: tolerate mismatched optional probe * elaborate.cxx: Early return for mismatched optional probe. * testsuite/systemtap.base/optionalprobe.exp: New test case. * testsuite/systemtap.base/optionalprobe.stp: Ditto. --- testsuite/systemtap.base/optionalprobe.exp | 9 +++++++++ testsuite/systemtap.base/optionalprobe.stp | 6 ++++++ 2 files changed, 15 insertions(+) create mode 100644 testsuite/systemtap.base/optionalprobe.exp create mode 100644 testsuite/systemtap.base/optionalprobe.stp (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/optionalprobe.exp b/testsuite/systemtap.base/optionalprobe.exp new file mode 100644 index 00000000..5484003c --- /dev/null +++ b/testsuite/systemtap.base/optionalprobe.exp @@ -0,0 +1,9 @@ +set test "optionalprobe" +spawn stap -p2 -w $srcdir/$subdir/$test.stp +expect { + -timeout 60 + -re "# probes\r\n" { exp_continue } + -re "^begin" { pass $test } + eof { fail $test } + timeout { fail "$test unexpected timeout" } +} diff --git a/testsuite/systemtap.base/optionalprobe.stp b/testsuite/systemtap.base/optionalprobe.stp new file mode 100644 index 00000000..239cf6e3 --- /dev/null +++ b/testsuite/systemtap.base/optionalprobe.stp @@ -0,0 +1,6 @@ +#! stap + +# test optional probe + +probe foo ?, bar !, foo* ?, bar* !, begin { +} -- cgit From 999740348b95d993cbe36b9283c5cb7ee7bda149 Mon Sep 17 00:00:00 2001 From: Masami Hiramatsu Date: Tue, 28 Apr 2009 11:18:06 -0400 Subject: PR 6930: fix flightrec2.exp to handle filesize correctly * testsuite/systemtap.base/flightrec2.exp: Use stat instead of ls for checking file size. * testsuite/systemtap.base/flightrec2.stp: Increase timer interval for some architecture on which the minimum interval is more than 1 ms (e.g. xen) --- testsuite/systemtap.base/flightrec2.exp | 17 ++++++++--------- testsuite/systemtap.base/flightrec2.stp | 4 ++-- 2 files changed, 10 insertions(+), 11 deletions(-) (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/flightrec2.exp b/testsuite/systemtap.base/flightrec2.exp index a22ef415..d4481db4 100644 --- a/testsuite/systemtap.base/flightrec2.exp +++ b/testsuite/systemtap.base/flightrec2.exp @@ -26,13 +26,12 @@ exec sleep 4 set scnt 0 set cnt1 0 # wait for log files -spawn ls -sk1 +eval spawn stat -c %s [glob flightlog.out.*] expect { -timeout 100 - -re {([0-9]+) flightlog\.out\.[0-9]+} { + -re {[0-9]+} { incr cnt1; - if {$expect_out(1,string) <= 1028} {incr scnt} - # 1024 + 4(for inode blocks?) + if {$expect_out(buffer) <= 1048576 } {incr scnt} exp_continue} timeout { fail "$test (logfile timeout)"} } @@ -40,12 +39,12 @@ wait exec sleep 3 set cnt2 0 # wait for log files -spawn ls -sk1 +eval spawn stat -c %s [glob flightlog.out.*] expect { -timeout 100 - -re {([0-9]+) flightlog\.out\.[0-9]+} { + -re {[0-9]+} { incr cnt2; - if {$expect_out(1,string) <= 1028} {incr scnt} + if {$expect_out(buffer) <= 1048576 } {incr scnt} exp_continue} timeout { fail "$test (logfile timeout)"} } @@ -57,10 +56,10 @@ if {$cnt1 == 3 && $cnt2 == 3} { fail "$test (log file numbers ($cnt1, $cnt2))" } # check logfile size -if {$scnt == 6} { +if {$scnt == $cnt1 + $cnt2 } { pass "$test (log file size limitation)" } else { - fail "$test (log file size ($scnt))" + fail "$test (log file size ($scnt != $cnt1 + $cnt2))" } exec kill -TERM $pid # wait for exiting... diff --git a/testsuite/systemtap.base/flightrec2.stp b/testsuite/systemtap.base/flightrec2.stp index 9d745f4b..f42c9b8e 100644 --- a/testsuite/systemtap.base/flightrec2.stp +++ b/testsuite/systemtap.base/flightrec2.stp @@ -1,5 +1,5 @@ -probe timer.ms(1) +probe timer.ms(10) { - for (j = 0; j < 100; j++) + for (j = 0; j < 1000; j++) printf("1234567890\n") } -- cgit From 0904184b479723cc514db320f7cb70b8c284ea1a Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Wed, 29 Apr 2009 14:00:21 -0700 Subject: Use sockaddr instead of timeval in @cast test Using timeval had problems on big-endian multi-arch platforms (ppc64), because the user tv_sec used in the @cast didn't match the kernel tv_sec used to provide a pointer. Hopefully reading from a sockaddr should be more robust, as that type doesn't appear to need any compat wrappers for multi-archs. --- testsuite/systemtap.base/cast.exp | 2 +- testsuite/systemtap.base/cast.stp | 24 ++++++++++++++---------- 2 files changed, 15 insertions(+), 11 deletions(-) (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/cast.exp b/testsuite/systemtap.base/cast.exp index 74c4d72a..374132f0 100644 --- a/testsuite/systemtap.base/cast.exp +++ b/testsuite/systemtap.base/cast.exp @@ -2,5 +2,5 @@ set test "cast" set ::result_string {PID OK PID2 OK execname OK -tv_sec OK} +sa_data OK} stap_run2 $srcdir/$subdir/$test.stp -g diff --git a/testsuite/systemtap.base/cast.stp b/testsuite/systemtap.base/cast.stp index 6298a06d..e2505000 100644 --- a/testsuite/systemtap.base/cast.stp +++ b/testsuite/systemtap.base/cast.stp @@ -25,19 +25,23 @@ probe begin else printf("execname \"%s\" != \"%s\"\n", name, cast_name) - // Compare tv_sec using a generated user module - sec = 42 - cast_sec = @cast(get_timeval(sec), "timeval", "")->tv_sec - if (sec == cast_sec) - println("tv_sec OK") + // Compare sa_data using a generated user module + data = 42 + cast_data = @cast(get_sockaddr(data), "sockaddr", "")->sa_data[0] + if (data == cast_data) + println("sa_data OK") else - printf("tv_sec %d != %d\n", sec, cast_sec) + printf("sa_data %d != %d\n", data, cast_data) exit() } -function get_timeval:long(sec:long) %{ - static struct timeval mytime = {0}; - mytime.tv_sec = THIS->sec; - THIS->__retvalue = (long)&mytime; +%{ +#include +%} + +function get_sockaddr:long(data:long) %{ + static struct sockaddr sa = {0}; + sa.sa_data[0] = THIS->data; + THIS->__retvalue = (long)&sa; %} -- cgit From ea7d087ab3866eb99c19444b237c9586e8dc9b17 Mon Sep 17 00:00:00 2001 From: Ananth N Mavinakayanahalli Date: Thu, 30 Apr 2009 17:00:38 +0530 Subject: PR10007: Avoid probing syscall entry points in the testsuite. While there, fix minor issues with the s390x syscall tapset. --- testsuite/systemtap.base/alternatives.exp | 8 ++++---- testsuite/systemtap.base/maxactive.exp | 16 ++++++++-------- testsuite/systemtap.base/onoffprobe.stp | 4 ++-- testsuite/systemtap.base/overload.exp | 2 +- testsuite/systemtap.base/stmtvars.exp | 6 +++--- testsuite/systemtap.base/system_func.stp | 4 ++-- 6 files changed, 20 insertions(+), 20 deletions(-) (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/alternatives.exp b/testsuite/systemtap.base/alternatives.exp index deaf3bf8..fb263d7a 100644 --- a/testsuite/systemtap.base/alternatives.exp +++ b/testsuite/systemtap.base/alternatives.exp @@ -14,11 +14,11 @@ # listed, but that some alternatives are listed. set local1_script { - probe kernel.function("sys_getrlimit") { x = $z; } + probe kernel.funtion("vfs_write") { ret = $z; } } set struct1_script { - probe kernel.function("sys_getrlimit") { rlim_cur = $rlim->rlim_cud; } + probe kernel.function("vfs_write") { f_pos = $file->f_po; } } proc stap_run_alternatives {args} { @@ -38,8 +38,8 @@ proc stap_run_alternatives {args} { set test "LOCAL1" set rc [stap_run_alternatives stap -vu -p2 -e $local1_script] -if {$rc == 1} { pass $test } else { fail "$test ($rc)" } +if {$rc >= 1} { pass $test } else { fail "$test ($rc)" } set test "STRUCT1" set rc [stap_run_alternatives stap -vu -p2 -e $struct1_script] -if {$rc == 1} { pass $test } else { fail "$test ($rc)" } +if {$rc >= 1} { pass $test } else { fail "$test ($rc)" } diff --git a/testsuite/systemtap.base/maxactive.exp b/testsuite/systemtap.base/maxactive.exp index 7c03a1bf..79ede897 100644 --- a/testsuite/systemtap.base/maxactive.exp +++ b/testsuite/systemtap.base/maxactive.exp @@ -10,12 +10,12 @@ proc sleep_five_sec {} { return 0; } -# Script1. For 5 seconds, probe the return of "sys_select" and -# "sys_read". See if we skip any probes. +# Script1. For 5 seconds, probe the return of "vfs_read" and +# "do_select". See if we skip any probes. set script1 { global foo - probe kernel.function("sys_select").return, - kernel.function("sys_read").return { foo++ } + probe kernel.function("vfs_read").return, + kernel.function("do_select").return { foo++ } probe timer.ms(5000) { exit(); } probe begin { log("systemtap starting probe"); log("systemtap ending probe");} @@ -26,13 +26,13 @@ set script1 { stap_run "MAXACTIVE01" sleep_five_sec "" -e $script1 set skipped1 $skipped_probes -# Script2. For 5 seconds, probe the return of "sys_select" and -# "sys_read", with a limit of 1 probe active at a time. See if we +# Script2. For 5 seconds, probe the return of "vfs_read" and +# "do_select", with a limit of 1 probe active at a time. See if we # skip any probes. set script2 { global foo - probe kernel.function("sys_select").return.maxactive(1), - kernel.function("sys_read").return.maxactive(1) { foo++ } + probe kernel.function("vfs_read").return.maxactive(1), + kernel.function("do_select").return.maxactive(1) { foo++ } probe timer.ms(5000) { exit(); } probe begin { log("systemtap starting probe"); log("systemtap ending probe");} diff --git a/testsuite/systemtap.base/onoffprobe.stp b/testsuite/systemtap.base/onoffprobe.stp index f7169039..79c41a3c 100644 --- a/testsuite/systemtap.base/onoffprobe.stp +++ b/testsuite/systemtap.base/onoffprobe.stp @@ -10,13 +10,13 @@ probe begin if (switch==0) { } #dwarf probe (return) -probe kernel.function("sys_write").return if (switch == 1) { +probe kernel.function("vfs_write").return if (switch == 1) { log("function return probed") switch = 0 } #dwarf probe (entry) -probe kernel.function("sys_write") if (switch == 2) { +probe kernel.function("vfs_write").return if (switch == 2) { log("function entry probed") switch = 0 } diff --git a/testsuite/systemtap.base/overload.exp b/testsuite/systemtap.base/overload.exp index cbcbe817..ac9ceb24 100644 --- a/testsuite/systemtap.base/overload.exp +++ b/testsuite/systemtap.base/overload.exp @@ -8,7 +8,7 @@ set script { k["foo"] = 0 } - probe kernel.function("sys_read"), kernel.function("sys_write") { + probe kernel.function("vfs_read"), kernel.function("vfs_write") { k["foo"]++ } probe end { diff --git a/testsuite/systemtap.base/stmtvars.exp b/testsuite/systemtap.base/stmtvars.exp index 822e0d7e..c0099f2d 100644 --- a/testsuite/systemtap.base/stmtvars.exp +++ b/testsuite/systemtap.base/stmtvars.exp @@ -3,9 +3,9 @@ set test "stmtvars" set pc 0 set vars "" -spawn stap -e "probe kernel.function(\"sys_open\") {\$foo}" -p4 -vv -u +spawn stap -e "probe kernel.function(\"do_sys_open\") {\$foo}" -p4 -vv -u expect { - -re {probe sys_open[^\r\n]*pc=(0x[^\r\n]*)\r\n} { set pc $expect_out(1,string); exp_continue } + -re {probe do_sys_open[^\r\n]*pc=(0x[^\r\n]*)\r\n} { set pc $expect_out(1,string); exp_continue } -re {alternatives: ([^\r\n]*)\): identifier [^\r\n]*\r\n} { set vars $expect_out(1,string); exp_continue } timeout { fail "$test (timeout)" } eof @@ -18,7 +18,7 @@ set pc2 0 set vars2 "" spawn stap -e "probe kernel.statement($pc) {\$foo}" -p4 -vv -u expect { - -re {probe sys_open[^\r\n]*pc=(0x[^\r\n]*)\r\n} { set pc2 $expect_out(1,string); exp_continue } + -re {probe do_sys_open[^\r\n]*pc=(0x[^\r\n]*)\r\n} { set pc2 $expect_out(1,string); exp_continue } -re {alternatives: ([^\r\n]*)\): identifier [^\r\n]*\r\n} { set vars2 $expect_out(1,string); exp_continue } timeout { fail "$test (timeout)" } eof diff --git a/testsuite/systemtap.base/system_func.stp b/testsuite/systemtap.base/system_func.stp index d14fb25b..6a6bb04a 100644 --- a/testsuite/systemtap.base/system_func.stp +++ b/testsuite/systemtap.base/system_func.stp @@ -4,10 +4,10 @@ global saw_echo, did_cat -probe kernel.function("sys_open") { +probe kernel.function("do_sys_open") { if (!saw_echo) { # very inefficient. Testing only. DO NOT DO THIS - msg="echo sys_open" + msg="echo do_sys_open" system(msg) saw_echo = 1 } -- cgit From 669add55f740e904485c119de78ddb5ed06bbbc6 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Sat, 2 May 2009 17:52:50 +0200 Subject: Fix funtion -> function typo in alternatives.exp. * testsuite/systemtap.base/alternatives.exp (local1_script): Fix typo. --- testsuite/systemtap.base/alternatives.exp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/alternatives.exp b/testsuite/systemtap.base/alternatives.exp index fb263d7a..ca78479b 100644 --- a/testsuite/systemtap.base/alternatives.exp +++ b/testsuite/systemtap.base/alternatives.exp @@ -14,7 +14,7 @@ # listed, but that some alternatives are listed. set local1_script { - probe kernel.funtion("vfs_write") { ret = $z; } + probe kernel.function("vfs_write") { ret = $z; } } set struct1_script { -- cgit From 97d1fa6e24d8d4e8ceefc62f0d4a7f93a18e4125 Mon Sep 17 00:00:00 2001 From: Ananth N Mavinakayanahalli Date: Mon, 4 May 2009 15:39:23 +0530 Subject: Fix kprobes.exp. Patch from Prerna Saxena. --- testsuite/systemtap.base/kprobes.exp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/kprobes.exp b/testsuite/systemtap.base/kprobes.exp index 635930f8..9f92f14a 100644 --- a/testsuite/systemtap.base/kprobes.exp +++ b/testsuite/systemtap.base/kprobes.exp @@ -1,2 +1,7 @@ set test "kprobes" -stap_run $srcdir/$subdir/$test.stp no_load "probe point hit" +spawn stap -vv $srcdir/$subdir/$test.stp +expect { + -timeout 120 + "systemtap starting probe" { pass "$test (probe_hit)" } + timeout { fail "$test (timeout)" } + } -- cgit From 2b9c700be957b81e1c51e7199e5db77614bc025b Mon Sep 17 00:00:00 2001 From: Wenji Huang Date: Mon, 4 May 2009 16:51:41 -0400 Subject: Tweak alternatives.exp --- testsuite/systemtap.base/alternatives.exp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/alternatives.exp b/testsuite/systemtap.base/alternatives.exp index ca78479b..6cbc1e10 100644 --- a/testsuite/systemtap.base/alternatives.exp +++ b/testsuite/systemtap.base/alternatives.exp @@ -37,9 +37,9 @@ proc stap_run_alternatives {args} { } set test "LOCAL1" -set rc [stap_run_alternatives stap -vu -p2 -e $local1_script] +set rc [stap_run_alternatives stap -u -p2 -e $local1_script] if {$rc >= 1} { pass $test } else { fail "$test ($rc)" } set test "STRUCT1" -set rc [stap_run_alternatives stap -vu -p2 -e $struct1_script] +set rc [stap_run_alternatives stap -u -p2 -e $struct1_script] if {$rc >= 1} { pass $test } else { fail "$test ($rc)" } -- cgit From c4b2ebcba96721ff5bf78224825bf1b9002ca145 Mon Sep 17 00:00:00 2001 From: Ananth N Mavinakayanahalli Date: Tue, 5 May 2009 10:31:07 +0530 Subject: Revert "Fix kprobes.exp." This reverts commit 97d1fa6e24d8d4e8ceefc62f0d4a7f93a18e4125. --- testsuite/systemtap.base/kprobes.exp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/kprobes.exp b/testsuite/systemtap.base/kprobes.exp index 9f92f14a..635930f8 100644 --- a/testsuite/systemtap.base/kprobes.exp +++ b/testsuite/systemtap.base/kprobes.exp @@ -1,7 +1,2 @@ set test "kprobes" -spawn stap -vv $srcdir/$subdir/$test.stp -expect { - -timeout 120 - "systemtap starting probe" { pass "$test (probe_hit)" } - timeout { fail "$test (timeout)" } - } +stap_run $srcdir/$subdir/$test.stp no_load "probe point hit" -- cgit From 74efda8d847591a2146601ad085e6411340f3e98 Mon Sep 17 00:00:00 2001 From: Wenji Huang Date: Tue, 5 May 2009 19:26:38 -0400 Subject: PR10102: tolerate the failure related to optional probe This patch will make stap silently accept the failure related to optional probe. It puts try/catch around find_and_build which can cover most probe types. The specific treatment for dwarf_derived_probe in commit ed82b7c902d6a2e26452ec51c9cdb9665dbf9e97 is reverted. --- testsuite/systemtap.base/optionalprobe.stp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/optionalprobe.stp b/testsuite/systemtap.base/optionalprobe.stp index 239cf6e3..13918cee 100644 --- a/testsuite/systemtap.base/optionalprobe.stp +++ b/testsuite/systemtap.base/optionalprobe.stp @@ -2,5 +2,13 @@ # test optional probe -probe foo ?, bar !, foo* ?, bar* !, begin { +probe foo ?, + process("/do/not/exist").function("main") !, + kernel.mark("no such mark") ?, + kernel.trace("no trace") !, + process.foo ?, + kernel.statement("no statement") !, + module("no mod").function("*") ?, + kernel.function("no such func*") !, + begin { } -- cgit From c2b89290dc293a0c858f651f56cc0ccc38e621e2 Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Thu, 7 May 2009 11:24:04 -0400 Subject: fix permissions of some testsuite files Reported-By: Petr Muller --- testsuite/systemtap.base/bz10078.stp | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 testsuite/systemtap.base/bz10078.stp (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/bz10078.stp b/testsuite/systemtap.base/bz10078.stp old mode 100644 new mode 100755 -- cgit From f90da452b402af56c7f186798911ca5f49ee0cc4 Mon Sep 17 00:00:00 2001 From: Keiichi KII Date: Wed, 13 May 2009 16:55:11 -0400 Subject: PR 6930: Add additional testcases for flight recorder mode * testsuite/parseko/cmdline17.stp: command line check - bad combination with -D and -L * testsuite/parseko/cmdline18.stp: command line check - bad combination with -D and -d * testsuite/parseko/cmdline19.stp: command line check - bad combination with -D and -c * testsuite/parseko/cmdline20.stp: command line check - need output file with -D * testsuite/parseko/cmdline21.stp: command line check - need output file with -S * testsuite/systemtap.base/flightrec3.exp: New test case for file switching with bulk mode * testsuite/systemtap.base/flightrec3.stp: Test script for file switching per cpu --- testsuite/systemtap.base/flightrec3.exp | 79 +++++++++++++++++++++++++++++++++ testsuite/systemtap.base/flightrec3.stp | 5 +++ 2 files changed, 84 insertions(+) create mode 100644 testsuite/systemtap.base/flightrec3.exp create mode 100644 testsuite/systemtap.base/flightrec3.stp (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/flightrec3.exp b/testsuite/systemtap.base/flightrec3.exp new file mode 100644 index 00000000..5b9d8253 --- /dev/null +++ b/testsuite/systemtap.base/flightrec3.exp @@ -0,0 +1,79 @@ +set test "flightrec3" +if {![installtest_p]} { untested $test; return } + +# cleanup +system "rm -f flightlog.out*" + +set pid 0 +# check -S option with bulk(percpu file) mode +spawn stap -F -o flightlog.out -S 1,3 -b $srcdir/$subdir/$test.stp +expect { + -timeout 240 + -re {([0-9]+)\r\n} { + pass "$test (-S option with bulk mode)" + set pid $expect_out(1,string) + exp_continue} + timeout { fail "$test (timeout)"} + eof { } +} +wait +if {$pid == 0} { + fail "$test (no pid)" + return -1 +} + +exec sleep 4 +array set cpus {} +set scnt 0 +# wait for log files +exec kill -STOP $pid +exec sleep 1 +eval spawn stat -c \"%n %s\" [glob flightlog.out_cpu*] +expect { + -timeout 100 + -re {flightlog.out_cpu([0-9]+).[0-9]+ ([0-9]+)\r\n} { + set cpuid $expect_out(1,string) + set size $expect_out(2,string) + if {[array get cpus $cpuid] == ""} {set cpus($cpuid) 0} + incr cpus($cpuid); + if {$size <= 1048576 } {incr scnt} + exp_continue} + timeout { fail "$test (logfile timeout)"} +} +wait +exec kill -CONT $pid +exec sleep 3 +exec kill -STOP $pid +eval spawn stat -c \"%n %s\" [glob flightlog.out_cpu*] +expect { + -timeout 100 + -re {flightlog.out_cpu([0-9]+).[0-9]+ ([0-9]+)\r\n} { + set cpuid $expect_out(1,string) + set size $expect_out(2,string) + if {[array get cpus $cpuid] == ""} {set cpus($cpuid) 0} + incr cpus($cpuid); + if {$size <= 1048576 } {incr scnt} + exp_continue} + timeout { fail "$test (logfile timeout)"} +} +wait +exec kill -CONT $pid +# check logfile number +set cnt 0 +foreach e [array names cpus] { + if {$cpus($e) != 6} { + fail "$test (log file numbers cpu:$e, cnt:$cpus($e)))" + } + set cnt [expr $cnt + $cpus($e)] +} +# check logfile size +if {$scnt == $cnt} { + pass "$test (log file size limitation with bulk mode)" +} else { + fail "$test (log file size ($scnt != $cnt))" +} +exec kill -TERM $pid +# wait for exiting... +exec sleep 1 +system "rm -f flightlog.out*" + diff --git a/testsuite/systemtap.base/flightrec3.stp b/testsuite/systemtap.base/flightrec3.stp new file mode 100644 index 00000000..d660793f --- /dev/null +++ b/testsuite/systemtap.base/flightrec3.stp @@ -0,0 +1,5 @@ +probe kernel.function("update_process_times") +{ + for (j = 0; j < 100; j++) + printf("1234567890\n") +} -- cgit From ba66469ee107a98d95345a6d6d71cd5bb5831cdc Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Fri, 15 May 2009 11:23:23 +0200 Subject: Set explicit longer, 60 second, timeout for alternatives.exp. In an make installcheck run this is the first script that goes through the full kernel debuginfo which might take a bit. * testsuite/systemtap.base/alternatives.exp: Set timeout to 60, verbose log EOF or TIMEOUT when they occur. --- testsuite/systemtap.base/alternatives.exp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/alternatives.exp b/testsuite/systemtap.base/alternatives.exp index 6cbc1e10..f5dc4513 100644 --- a/testsuite/systemtap.base/alternatives.exp +++ b/testsuite/systemtap.base/alternatives.exp @@ -26,10 +26,11 @@ proc stap_run_alternatives {args} { verbose -log "starting $args" eval spawn $args expect { + -timeout 60 -re {semantic error: .+ \(alternatives: [a-zA-Z_]} {incr alternatives_found; exp_continue} -re {[^\r]*\r} { verbose -log $expect_out(0,string); exp_continue } - eof { } - timeout { } + eof { verbose -log "EOF" } + timeout { verbose -log "TIMEOUT" } } set results [wait] verbose -log "wait results: $results" -- cgit From dad0fddfb82f22bb384fa2f0043cbb70e51f4a1e Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Fri, 15 May 2009 11:44:42 +0200 Subject: flightrec3.exp uses cpus as array, so rename skipped.exp cpus var to nr_cpus. Works around a make installcheck issue that resulted in skipped.exp failing because of "ERROR: can't set "cpus": variable is array" * testsuite/systemtap.base/skipped.exp: Renamed cpus variable to nr_cpus. --- testsuite/systemtap.base/skipped.exp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/skipped.exp b/testsuite/systemtap.base/skipped.exp index 8c491037..f3048c8a 100644 --- a/testsuite/systemtap.base/skipped.exp +++ b/testsuite/systemtap.base/skipped.exp @@ -2,8 +2,8 @@ set test "skip tracking" if {! [installtest_p]} { untested $test; return } -set cpus [exec sh -c "grep ^processor /proc/cpuinfo | wc -l"] -if {$cpus < 2} { unsupported $test; return } +set nr_cpus [exec sh -c "grep ^processor /proc/cpuinfo | wc -l"] +if {$nr_cpus < 2} { unsupported $test; return } set ok 0 spawn stap -e "probe timer.s(5) {exit()} probe timer.profile,syscall.* {f++} global f" -DMAXTRYLOCK=0 -tu @@ -18,4 +18,4 @@ expect { catch {close} catch {wait} -if {$ok >= 3} { pass "$test ($cpus $ok)" } else { fail "$test ($cpus $ok)" } +if {$ok >= 3} { pass "$test ($nr_cpus $ok)" } else { fail "$test ($nr_cpus $ok)" } -- cgit