diff options
Diffstat (limited to 'testsuite')
46 files changed, 990 insertions, 101 deletions
diff --git a/testsuite/.gitignore b/testsuite/.gitignore index 34a4e8d0..19b30bf1 100644 --- a/testsuite/.gitignore +++ b/testsuite/.gitignore @@ -1,4 +1,4 @@ -.systemtap +.systemtap-* site.exp systemtap.log systemtap.sum diff --git a/testsuite/ChangeLog b/testsuite/ChangeLog index fa6e4fad..4fda9c5f 100644 --- a/testsuite/ChangeLog +++ b/testsuite/ChangeLog @@ -1,3 +1,111 @@ +2008-06-23 Stan Cox <scox@redhat.com> + + * systemtap.base/stmt_rel.stp: Added test for + kernel.statement("Func@File:*") + +2008-06-18 Josh Stone <joshua.i.stone@intel.com> + + * systemtap.base/optim_voidstmt.stp: Add tests for various statement + optimizations that we should now be eliding. + +2008-06-16 Frank Ch. Eigler <fche@elastic.org> + + * systemtap.base/warnings.exp: Adjust warning count again (me1 and + elide were formerly duplicated). + +2008-06-16 Stan Cox <scox@redhat.com> + + * systemtap.base/warnings.stp: Added PR 6611 warning tests. + * systemtap.base/warnings.exp: Reset warning count. + +2008-06-13 Frank Ch. Eigler <fche@elastic.org> + + * lib/stap_run.exp: Remove module/cache warning boilerplate. + +2008-06-11 Mark Wielaard <mwielaard@redhat.com> + + * systemtap.base/warnings.exp: Expect 11 warning plus 1 .ko output + line. + +2008-06-11 David Smith <dsmith@redhat.com> + + * systemtap.base/utrace_p5.exp: Made changes to work when not + configured in the src directory. + * systemtap.base/utrace_p5_multi.c: Made changes to work on x86_64 + systems. + + * systemtap.base/utrace_p5.exp: Added 'process().thread.begin' and + 'process().thread.end' tests. + * systemtap.base/utrace_p5_multi.c: Added multi-threaded test + program for utrace_p5.exp. + * .gitignore: Updated. + +2008-06-10 Stan Cox <scox@redhat.com> + + * systemtap.base/warnings.exp: Adjust for duplicate warning elimination. + +2008-06-10 Frank Ch. Eigler <fche@elastic.org> + + PR 6470. + * parseko/preprocess08.stp, ...08b.stp: Revised/new test. + * systemtap.base/cmd_parse.exp: Added some argv[] tests. + +2008-06-09 Stan Cox <scox@redhat.com> + + * systemtap.base/stmt_rel.stp: New test. + * systemtap.base/stmt_rel.exp: Likewise. + +2008-06-06 David Smith <dsmith@redhat.com> + + * systemtap.base/utrace_p4.exp: Updated for utrace probe changes. + * systemtap.base/utrace_p5.exp: Ditto. + +2008-06-03 Frank Ch. Eigler <fche@elastic.org> + + * systemtap.context/backtrace.tcl: Tolerate "(inexact)" backtraces. + +2008-05-30 Wenji Huang <wenji.huang@oracle.com> + + * systemtap.base/debugpath.exp: Add path for self-built kernel. + +2008-05-28 Josh Stone <joshua.i.stone@intel.com> + + PR 6529 + * systemtap.base/error_fn.*: New tests. + +2008-05-28 Mark Wielaard <mwielaard@redhat.com> + + * testsuite/Makefile.am (clean-local): Correct redirect of stderr. + (installcheck): Don't depend on clean. + +2008-05-28 Mark Wielaard <mwielaard@redhat.com> + + * lib/systemtap.exp (setup_systemtap_environment): Create user + based cache dir. + * systemtap.base/cache.exp: Likewise. + * Makefile.am (clean-local): Try to remove all .systemtap and + .cache_test dirs. + +2008-05-26 Frank Ch. Eigler <fche@elastic.org> + + * testsuite/stmtvars.exp: Tweaked matching regexps, tested on + f7, rhel5. + +2008-05-24 Frank Ch. Eigler <fche@elastic.org> + + * configure.ac (enable-dejazilla): Add option, default off. + * Makefile.am (*check): Send systemtap.sum to dejazilla if enabled$a + * execrc: New helper script for runtest rc overriding. + * configure, Makefile.in: Regenerated. + +2008-05-23 Frank Ch. Eigler <fche@elastic.org> + + * buildok/{nfs,rpc}-all-probes.stp: Suppress warnings from empty probe + bodies. + * systemtap.pass1-4/buidok.exp: Mark above as kfail due to bug #4413. + While there, also mark the process_test kfail for #1155, though even + it fails only sporadically. + 2008-05-21 Frank Ch. Eigler <fche@elastic.org> PR 6538 diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am index edaaff3c..b66bb75f 100644 --- a/testsuite/Makefile.am +++ b/testsuite/Makefile.am @@ -3,20 +3,30 @@ AUTOMAKE_OPTIONS = dejagnu -# The stap symlink is to enable "#! stap" test scripts. all-local: @echo Run \"make check\" or \"make installcheck\". + @if test -n "$(DEJAZILLA)"; then echo Test results will be emailed to $(DEJAZILLA); fi clean-local: -rm -f ./stap site.exp systemtap.sum systemtap.log - -rm -rf .systemtap .cache_test 2>/dev/null + -rm -rf .systemtap* .cache_test* 2>/dev/null -installcheck-local: clean site.exp - $(MAKE) AM_RUNTESTFLAGS="--tool_opts install" check-DEJAGNU +DEJAZILLA=@dejazilla@ + +# automake's dejagnu library already runs check-DEJAGNU before check-local +# That's why we need to add "execrc" to $(RUNTEST) - to ensure that this +# subtarget gets run even if runtest per se exits with a failure. +check-local: + if test -n "$(DEJAZILLA)"; then mail $(DEJAZILLA) < systemtap.sum; fi + +# but installcheck does not follow an implicit check-DEJAGNU, go figure +installcheck: site.exp + -$(MAKE) $(AM_MAKEFLAGS) check-DEJAGNU RUNTESTFLAGS="$(RUNTESTFLAGS) --tool_opts install" + if test -n "$(DEJAZILLA)"; then mail $(DEJAZILLA) < systemtap.sum; fi SRCDIR = $(shell cd $(srcdir); pwd) -EXTRA_DIST = config lib systemtap \ +EXTRA_DIST = execrc config lib systemtap \ parseok parseko semok semko transok transko buildok buildok \ systemtap.syscall systemtap.stress systemtap.string \ systemtap.pass1-4 systemtap.samples systemtap.printf \ @@ -30,4 +40,6 @@ LD_LIBRARY_PATH=$(DESTDIR)$(libdir)/systemtap CRASH_LIBDIR=$(DESTDIR)$(libdir)/systemtap SYSTEMTAP_PATH=$(DESTDIR)$(bindir) -RUNTEST="env SYSTEMTAP_RUNTIME=$(SYSTEMTAP_RUNTIME) SYSTEMTAP_TAPSET=$(SYSTEMTAP_TAPSET) LD_LIBRARY_PATH=$(LD_LIBRARY_PATH) CRASH_LIBDIR=$(CRASH_LIBDIR) PATH=$(SYSTEMTAP_PATH):$$PATH runtest" +RUNTESTDEFAULTFLAGS = --tool $$tool --srcdir $$srcdir +EXPECT = expect +RUNTEST="env SYSTEMTAP_RUNTIME=$(SYSTEMTAP_RUNTIME) SYSTEMTAP_TAPSET=$(SYSTEMTAP_TAPSET) LD_LIBRARY_PATH=$(LD_LIBRARY_PATH) CRASH_LIBDIR=$(CRASH_LIBDIR) PATH=$(SYSTEMTAP_PATH):$$PATH $(srcdir)/execrc runtest" diff --git a/testsuite/Makefile.in b/testsuite/Makefile.in index 99acf141..c8b07bdc 100644 --- a/testsuite/Makefile.in +++ b/testsuite/Makefile.in @@ -49,8 +49,6 @@ CONFIG_CLEAN_FILES = SOURCES = DIST_SOURCES = DEJATOOL = $(PACKAGE) -RUNTESTDEFAULTFLAGS = --tool $$tool --srcdir $$srcdir -EXPECT = expect DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) @@ -107,6 +105,7 @@ build_alias = @build_alias@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ +dejazilla = @dejazilla@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ @@ -134,8 +133,9 @@ target_alias = @target_alias@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AUTOMAKE_OPTIONS = dejagnu +DEJAZILLA = @dejazilla@ SRCDIR = $(shell cd $(srcdir); pwd) -EXTRA_DIST = config lib systemtap \ +EXTRA_DIST = execrc config lib systemtap \ parseok parseko semok semko transok transko buildok buildok \ systemtap.syscall systemtap.stress systemtap.string \ systemtap.pass1-4 systemtap.samples systemtap.printf \ @@ -149,7 +149,9 @@ SYSTEMTAP_TAPSET = $(DESTDIR)$(pkgdatadir)/tapset LD_LIBRARY_PATH = $(DESTDIR)$(libdir)/systemtap CRASH_LIBDIR = $(DESTDIR)$(libdir)/systemtap SYSTEMTAP_PATH = $(DESTDIR)$(bindir) -RUNTEST = "env SYSTEMTAP_RUNTIME=$(SYSTEMTAP_RUNTIME) SYSTEMTAP_TAPSET=$(SYSTEMTAP_TAPSET) LD_LIBRARY_PATH=$(LD_LIBRARY_PATH) CRASH_LIBDIR=$(CRASH_LIBDIR) PATH=$(SYSTEMTAP_PATH):$$PATH runtest" +RUNTESTDEFAULTFLAGS = --tool $$tool --srcdir $$srcdir +EXPECT = expect +RUNTEST = "env SYSTEMTAP_RUNTIME=$(SYSTEMTAP_RUNTIME) SYSTEMTAP_TAPSET=$(SYSTEMTAP_TAPSET) LD_LIBRARY_PATH=$(LD_LIBRARY_PATH) CRASH_LIBDIR=$(CRASH_LIBDIR) PATH=$(SYSTEMTAP_PATH):$$PATH $(srcdir)/execrc runtest" all: all-am .SUFFIXES: @@ -351,7 +353,7 @@ distcleancheck: distclean $(distcleancheck_listfiles) ; \ exit 1; } >&2 check-am: all-am - $(MAKE) $(AM_MAKEFLAGS) check-DEJAGNU + $(MAKE) $(AM_MAKEFLAGS) check-DEJAGNU check-local check: check-am all-am: Makefile all-local installdirs: @@ -362,8 +364,6 @@ uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ @@ -414,7 +414,7 @@ install-pdf: install-pdf-am install-ps: install-ps-am -installcheck-am: installcheck-local +installcheck-am: maintainer-clean: maintainer-clean-am -rm -f $(am__CONFIG_DISTCLEAN_FILES) @@ -439,30 +439,38 @@ uninstall-am: .MAKE: install-am install-strip .PHONY: all all-am all-local am--refresh check check-DEJAGNU check-am \ - clean clean-generic clean-local dist dist-all dist-bzip2 \ - dist-gzip dist-shar dist-tarZ dist-zip distcheck distclean \ - distclean-DEJAGNU distclean-generic distcleancheck distdir \ - distuninstallcheck dvi dvi-am html html-am info info-am \ - install install-am install-data install-data-am install-dvi \ - install-dvi-am install-exec install-exec-am install-html \ - install-html-am install-info install-info-am install-man \ - install-pdf install-pdf-am install-ps install-ps-am \ - install-strip installcheck installcheck-am installcheck-local \ + check-local clean clean-generic clean-local dist dist-all \ + dist-bzip2 dist-gzip dist-shar dist-tarZ dist-zip distcheck \ + distclean distclean-DEJAGNU distclean-generic distcleancheck \ + distdir distuninstallcheck dvi dvi-am html html-am info \ + info-am install install-am install-data install-data-am \ + install-dvi install-dvi-am install-exec install-exec-am \ + install-html install-html-am install-info install-info-am \ + install-man install-pdf install-pdf-am install-ps \ + install-ps-am install-strip installcheck installcheck-am \ installdirs maintainer-clean maintainer-clean-generic \ mostlyclean mostlyclean-generic pdf pdf-am ps ps-am uninstall \ uninstall-am -# The stap symlink is to enable "#! stap" test scripts. all-local: @echo Run \"make check\" or \"make installcheck\". + @if test -n "$(DEJAZILLA)"; then echo Test results will be emailed to $(DEJAZILLA); fi clean-local: -rm -f ./stap site.exp systemtap.sum systemtap.log - -rm -rf .systemtap .cache_test 2>/dev/null - -installcheck-local: clean site.exp - $(MAKE) AM_RUNTESTFLAGS="--tool_opts install" check-DEJAGNU + -rm -rf .systemtap* .cache_test* 2>/dev/null + +# automake's dejagnu library already runs check-DEJAGNU before check-local +# That's why we need to add "execrc" to $(RUNTEST) - to ensure that this +# subtarget gets run even if runtest per se exits with a failure. +check-local: + if test -n "$(DEJAZILLA)"; then mail $(DEJAZILLA) < systemtap.sum; fi + +# but installcheck does not follow an implicit check-DEJAGNU, go figure +installcheck: site.exp + -$(MAKE) $(AM_MAKEFLAGS) check-DEJAGNU RUNTESTFLAGS="$(RUNTESTFLAGS) --tool_opts install" + if test -n "$(DEJAZILLA)"; then mail $(DEJAZILLA) < systemtap.sum; fi # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: diff --git a/testsuite/buildok/nfs-all-probes.stp b/testsuite/buildok/nfs-all-probes.stp index fb492c8c..ebff3472 100755 --- a/testsuite/buildok/nfs-all-probes.stp +++ b/testsuite/buildok/nfs-all-probes.stp @@ -1,4 +1,4 @@ -#! stap -p4 +#! stap -wp4 // Tests if all probes in nfs.stp and nfs_proc.stp are resolvable. diff --git a/testsuite/buildok/rpc-all-probes.stp b/testsuite/buildok/rpc-all-probes.stp index 2ecc42c7..c85ff80b 100755 --- a/testsuite/buildok/rpc-all-probes.stp +++ b/testsuite/buildok/rpc-all-probes.stp @@ -1,4 +1,4 @@ -#! stap -p4 +#! stap -wp4 // Tests if all probes in rpc.stp are resolvable. diff --git a/testsuite/configure b/testsuite/configure index bd8237cb..93494726 100755 --- a/testsuite/configure +++ b/testsuite/configure @@ -640,6 +640,7 @@ am__untar MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT +dejazilla LIBOBJS LTLIBOBJS' ac_subst_files='' @@ -1223,6 +1224,11 @@ Optional Features: --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-maintainer-mode enable make rules and dependencies not useful (and sometimes confusing) to the casual installer + --enable-dejazilla[=EMAIL] + enable dejazilla support to automatically email test + results to a central public collection point + (default is disabled). Optional EMAIL overrides the + default email address. Report bugs to <systemtap@sources.redhat.com>. _ACEOF @@ -2160,6 +2166,22 @@ fi +# Check whether --enable-dejazilla was given. +if test "${enable_dejazilla+set}" = set; then + enableval=$enable_dejazilla; +fi + +case "$enable_dejazilla" in + no) dejazilla= ;; + yes) dejazilla=dejazilla@elastic.org ;; + *) dejazilla="$enable_dejazilla" ;; +esac +if test -n "$dejazilla"; then + { echo "$as_me:$LINENO: A \"make *check\" will email results to $dejazilla" >&5 +echo "$as_me: A \"make *check\" will email results to $dejazilla" >&6;} +fi + + ac_config_files="$ac_config_files Makefile" cat >confcache <<\_ACEOF @@ -2861,11 +2883,12 @@ am__untar!$am__untar$ac_delim MAINTAINER_MODE_TRUE!$MAINTAINER_MODE_TRUE$ac_delim MAINTAINER_MODE_FALSE!$MAINTAINER_MODE_FALSE$ac_delim MAINT!$MAINT$ac_delim +dejazilla!$dejazilla$ac_delim LIBOBJS!$LIBOBJS$ac_delim LTLIBOBJS!$LTLIBOBJS$ac_delim _ACEOF - if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 64; then + if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 65; then break elif $ac_last_try; then { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 diff --git a/testsuite/configure.ac b/testsuite/configure.ac index 70d01e96..0fd78fe7 100644 --- a/testsuite/configure.ac +++ b/testsuite/configure.ac @@ -8,5 +8,20 @@ AC_CONFIG_AUX_DIR(..) AM_INIT_AUTOMAKE([dejagnu foreign]) AM_MAINTAINER_MODE +AC_ARG_ENABLE([dejazilla], + AS_HELP_STRING([--enable-dejazilla@<:@=EMAIL@:>@], + [enable dejazilla support to automatically email test results to a + central public collection point (default is disabled). Optional + EMAIL overrides the default email address.])) +case "$enable_dejazilla" in + no) dejazilla= ;; + yes) dejazilla=dejazilla@elastic.org ;; + *) dejazilla="$enable_dejazilla" ;; +esac +if test -n "$dejazilla"; then + AC_MSG_NOTICE([A "make *check" will email results to $dejazilla]) +fi +AC_SUBST(dejazilla) + AC_CONFIG_FILES(Makefile) AC_OUTPUT diff --git a/testsuite/execrc b/testsuite/execrc new file mode 100755 index 00000000..deff87e7 --- /dev/null +++ b/testsuite/execrc @@ -0,0 +1,5 @@ +#! /bin/sh + +# Run given program, but return a successful rc anyway. +eval $@ +exit 0 diff --git a/testsuite/lib/stap_run.exp b/testsuite/lib/stap_run.exp index 42efa4f8..43964d8e 100644 --- a/testsuite/lib/stap_run.exp +++ b/testsuite/lib/stap_run.exp @@ -33,7 +33,6 @@ proc stap_run { TEST_NAME {LOAD_GEN_FUNCTION ""} {OUTPUT_CHECK_STRING ""} args } eval spawn $cmd expect { -timeout 180 - -re {^Warning: using '-m' disables cache support.\r\n} {exp_continue} -re {^WARNING: cannot find module [^\r]*DWARF[^\r]*\r\n} {exp_continue} -re {^Pass\ ([1234]):[^\r]*\ in\ ([0-9]+)usr/([0-9]+)sys/([0-9]+)real\ ms\.\r\n} {set pass$expect_out(1,string) "\t$expect_out(2,string)\t$expect_out(3,string)\t$expect_out(4,string)"; exp_continue} diff --git a/testsuite/lib/systemtap.exp b/testsuite/lib/systemtap.exp index d458e98f..0f6a69dd 100644 --- a/testsuite/lib/systemtap.exp +++ b/testsuite/lib/systemtap.exp @@ -38,8 +38,9 @@ proc setup_systemtap_environment {} { set env(SRCDIR) $srcdir/.. } - # Use a local systemtap directory and cache - set env(SYSTEMTAP_DIR) [exec pwd]/.systemtap + # Use a local systemtap directory and cache. Add user name so + # make check and sudo make check don't clobber each other. + set env(SYSTEMTAP_DIR) [exec pwd]/.systemtap-[exec whoami] # PATH, SYSTEMTAP_TAPSET, SYSTEMTAP_RUNTIME, LD_LIBRARY_PATH are already set. foreach var {PATH STAP SRCDIR SYSTEMTAP_TAPSET SYSTEMTAP_RUNTIME SYSTEMTAP_DIR LD_LIBRARY_PATH} { diff --git a/testsuite/parseko/preprocess08.stp b/testsuite/parseko/preprocess08.stp index 6665983d..ba0d68e2 100755 --- a/testsuite/parseko/preprocess08.stp +++ b/testsuite/parseko/preprocess08.stp @@ -1,4 +1,4 @@ #! stap -p1 -# missing "then" token -%( arch == "2.6" %? +# premature EOF during THEN tokens +%( 0 == 0 %? diff --git a/testsuite/parseko/preprocess08b.stp b/testsuite/parseko/preprocess08b.stp new file mode 100755 index 00000000..a9697c28 --- /dev/null +++ b/testsuite/parseko/preprocess08b.stp @@ -0,0 +1,4 @@ +#! stap -p1 + +# premature EOF during ELSE tokens +%( 0 == 1 %? %: diff --git a/testsuite/semok/syscall_return.stp b/testsuite/semok/syscall_return.stp new file mode 100755 index 00000000..9a0ca7c4 --- /dev/null +++ b/testsuite/semok/syscall_return.stp @@ -0,0 +1,4 @@ +#!/bin/sh +# Per bz6588, this should get through the semantic pass without warnings. +stap -p2 -e 'probe syscall.*.return { printf("%s returns %s\n", name, retstr) }' 2>&1 | grep -q WARNING && exit 1 +exit 0 diff --git a/testsuite/systemtap.base/cache.exp b/testsuite/systemtap.base/cache.exp index 26d7b0ef..f7ed2786 100644 --- a/testsuite/systemtap.base/cache.exp +++ b/testsuite/systemtap.base/cache.exp @@ -65,8 +65,9 @@ proc stap_compile { TEST_NAME flags script args } { } # Since we need a clean cache directory, we'll use a temporary -# systemtap directory and cache -set local_systemtap_dir [exec pwd]/.cache_test +# systemtap directory and cache (add user name so make check and +# sudo make installcheck don't clobber each others) +set local_systemtap_dir [exec pwd]/.cache_test-[exec whoami] exec /bin/rm -rf $local_systemtap_dir if [info exists env(SYSTEMTAP_DIR)] { set old_systemtap_dir $env(SYSTEMTAP_DIR) diff --git a/testsuite/systemtap.base/cmd_parse.exp b/testsuite/systemtap.base/cmd_parse.exp index cbce0455..e33bfa85 100644 --- a/testsuite/systemtap.base/cmd_parse.exp +++ b/testsuite/systemtap.base/cmd_parse.exp @@ -84,3 +84,40 @@ expect { eof {fail "cmd_parse8: unexpected EOF"} } wait + +spawn stap -e {probe begin { printf("%d %s\n", argc, argv[$1]) exit() }} 1 +expect { + -timeout 60 + "1 1" { pass cmd_parse9 } + timeout { fail "cmd_parse9 timeout" } + eof { fail "cmd_parse9 eof" } +} +wait + +spawn stap -e {probe begin { printf("%d %s\n", argc, argv[$1]) exit() }} 5 a b c d +expect { + -timeout 60 + "5 d" { pass cmd_parse10 } + timeout { fail "cmd_parse10 timeout" } + eof { fail "cmd_parse10 eof" } +} +wait + +spawn stap -e {probe begin { printf("%d %s\n", argc, argv[$1]) exit() }} 10 a b c d +expect { + -timeout 60 + "5 " { pass cmd_parse11 } + timeout { fail "cmd_parse11 timeout" } + eof { fail "cmd_parse11 eof" } +} +wait + +spawn stap -e {probe begin { printf("%d %s\n", argc, argv[0]) exit() }} +expect { + -timeout 60 + "0 " { pass cmd_parse12 } + timeout { fail "cmd_parse12 timeout" } + eof { fail "cmd_parse12 eof" } +} +wait + diff --git a/testsuite/systemtap.base/debugpath.exp b/testsuite/systemtap.base/debugpath.exp index b0b12207..9c42295d 100644 --- a/testsuite/systemtap.base/debugpath.exp +++ b/testsuite/systemtap.base/debugpath.exp @@ -10,7 +10,8 @@ expect { wait set test "debugpath-good" -spawn env SYSTEMTAP_DEBUGINFO_PATH=:/usr/lib/debug stap -e "probe kernel.function(\"sys_open\") {}" -p2 +set uname [exec /bin/uname -r] +spawn env SYSTEMTAP_DEBUGINFO_PATH=/lib/modules/$uname/build stap -e "probe kernel.function(\"sys_open\") {}" -p2 expect { -re {kernel.function.*pc=} { pass $test } timeout { fail "$test (timeout2)" } diff --git a/testsuite/systemtap.base/error_fn.exp b/testsuite/systemtap.base/error_fn.exp new file mode 100644 index 00000000..c0de850f --- /dev/null +++ b/testsuite/systemtap.base/error_fn.exp @@ -0,0 +1,7 @@ +# check that errors in nested functions are not lost on return +# bugzilla 6529 + +set test "error_fn" + +stap_run $srcdir/$subdir/$test.stp no_load ".*synthetic error.*" + diff --git a/testsuite/systemtap.base/error_fn.stp b/testsuite/systemtap.base/error_fn.stp new file mode 100644 index 00000000..2e68026f --- /dev/null +++ b/testsuite/systemtap.base/error_fn.stp @@ -0,0 +1,17 @@ +probe begin { + println("systemtap starting probe") + println("systemtap ending probe") +} + +function generate_error:long() { + error("synthetic error") + return 1 +} + +function compute:long() { + return generate_error() +} + +probe end { + compute() +} diff --git a/testsuite/systemtap.base/optim_arridx.exp b/testsuite/systemtap.base/optim_arridx.exp index 0987dec6..f4308db5 100644 --- a/testsuite/systemtap.base/optim_arridx.exp +++ b/testsuite/systemtap.base/optim_arridx.exp @@ -9,7 +9,7 @@ arr3:long [long] fna:long (a:long) return a fnb:long (a:long, b:long) -return (a) + (b) +return ((a) + (b)) + (printf("")) exit:unknown () %{ atomic_set (&session_state, STAP_SESSION_STOPPING); diff --git a/testsuite/systemtap.base/optim_arridx.stp b/testsuite/systemtap.base/optim_arridx.stp index 20710c7f..3e4f8fd2 100644 --- a/testsuite/systemtap.base/optim_arridx.stp +++ b/testsuite/systemtap.base/optim_arridx.stp @@ -1,7 +1,7 @@ global arr1, arr2, arr3, elide_idx1, elide_global_a, elide_global_b function fna(a:long) {return a} -function fnb(a:long, b:long) {return a+b} +function fnb(a:long, b:long) {return a+b+printf("")} probe begin { // array indices diff --git a/testsuite/systemtap.base/optim_voidstmt.exp b/testsuite/systemtap.base/optim_voidstmt.exp new file mode 100644 index 00000000..186dabad --- /dev/null +++ b/testsuite/systemtap.base/optim_voidstmt.exp @@ -0,0 +1,5 @@ +# Make sure that optimization works with void statements + +set test "optim_voidstmt" + +stap_run $srcdir/$subdir/$test.stp no_load $all_pass_string -g diff --git a/testsuite/systemtap.base/optim_voidstmt.stp b/testsuite/systemtap.base/optim_voidstmt.stp new file mode 100644 index 00000000..343f81b3 --- /dev/null +++ b/testsuite/systemtap.base/optim_voidstmt.stp @@ -0,0 +1,95 @@ +/* + * optim_voidstmt.stp + * + * Verify statement optimizations in void contexts. + */ + +/* The printfs here force it not to be pure. */ +function goodL() { printf(""); return 1 } +function goodS() { printf(""); return "1" } + +/* These two functions lie about being pure, so they should be optimized out. + * If they get called, you get an error, and the test fails. + */ +function badL:long() %{ /* pure */ CONTEXT->last_error = "NOSEE"; %} +function badS:string() %{ /* pure */ CONTEXT->last_error = "NOSEE"; %} + +function fn1(x) { return x } +function fn2(x, y) { return x * y } + +probe begin { + println("systemtap starting probe") +} + +probe end { + println("systemtap ending probe") + + // most of these wouldn't have been optimized before, because part of the + // expression has an apparant side-effect in the good* calls + + // unary numeric operators + (+(goodL() + badL())) + (-(goodL() + badL())) + (!(goodL() + badL())) + (~(goodL() + badL())) + + // binary numeric operators + goodL() * badL() + goodL() / badL() + goodL() % badL() + goodL() + badL() + goodL() - badL() + goodL() >> badL() + goodL() << badL() + goodL() & badL() + goodL() ^ badL() + goodL() | badL() + goodL() < badL() + goodL() > badL() + goodL() <= badL() + goodL() >= badL() + goodL() == badL() + goodL() != badL() + + // logical operators + goodL() && badL() + badL() && badL() + goodL() || badL() + badL() || badL() + + // ternary operator + goodL() ? badL() : goodL() + goodL() ? goodL() : badL() + badL() ? badL() : badL() + + // binary string operators + goodS() . badS() + goodS() < badS() + goodS() > badS() + goodS() <= badS() + goodS() >= badS() + goodS() == badS() + goodS() != badS() + + // string-printing + sprintf("%d\n", goodL() + badL()) + sprintf("%d %d %s %s\n", goodL(), badL(), goodS(), badS()) + + // function calls + fn1(badL() + goodL()) + fn2(badL(), goodL()) + + // something complex, but harmless enough that only + // the good* calls should survive + fn1(fn2(goodL() - strlen(badL() + badL() * badL() / strlen(goodS()) ? + badS() . badS() . sprint(badL()) + : sprint(badL(), badS())), + badL() < badL() || badS() == badS()) + + goodL() % strlen(goodS())) + + println("systemtap test success") +} + +probe never { + print(goodL(), badL(), goodS(), badS(), fn1(1), fn2(1, 1)) +} diff --git a/testsuite/systemtap.base/stmt_rel.exp b/testsuite/systemtap.base/stmt_rel.exp new file mode 100644 index 00000000..25156d9b --- /dev/null +++ b/testsuite/systemtap.base/stmt_rel.exp @@ -0,0 +1,9 @@ +# 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 diff --git a/testsuite/systemtap.base/stmt_rel.stp b/testsuite/systemtap.base/stmt_rel.stp new file mode 100644 index 00000000..13066161 --- /dev/null +++ b/testsuite/systemtap.base/stmt_rel.stp @@ -0,0 +1,71 @@ +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 5 different statements? + foreach ([i] in wildcardpp) { + statement_count += 1 + } + if (statement_count >= 5) { + printf ("PASS wildcard\n") + } + else + { + printf ("FAIL wildcard %d\n", statement_count) + } + + exit() +} diff --git a/testsuite/systemtap.base/stmtvars.exp b/testsuite/systemtap.base/stmtvars.exp index 6e950ea0..822e0d7e 100644 --- a/testsuite/systemtap.base/stmtvars.exp +++ b/testsuite/systemtap.base/stmtvars.exp @@ -5,9 +5,8 @@ set pc 0 set vars "" spawn stap -e "probe kernel.function(\"sys_open\") {\$foo}" -p4 -vv -u expect { - -re {probe sys_open.*pc=(0x.*)\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 } + -re {probe 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 } @@ -19,9 +18,8 @@ set pc2 0 set vars2 "" spawn stap -e "probe kernel.statement($pc) {\$foo}" -p4 -vv -u expect { - -re {probe sys_open.*pc=(0x.*)\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 } + -re {probe 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/utrace_p4.exp b/testsuite/systemtap.base/utrace_p4.exp index eb6ea685..5544ee55 100644 --- a/testsuite/systemtap.base/utrace_p4.exp +++ b/testsuite/systemtap.base/utrace_p4.exp @@ -49,11 +49,12 @@ proc stap_compile { TEST_NAME compile script args } { # Initialize variables set utrace_support_found 0 -set clone_script {"probe process(\"/bin/ls\").clone { print(\"ls clone\") }"} -set death_script {"probe process(\"/bin/ls\").death { print(\"ls death\") }"} +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) }"} set syscall_return_script {"probe process(\"/bin/ls\").syscall.return { printf(\"|%d\", \$syscall) }"} -set exec_script {"probe process(\"/bin/ls\").exec { print(\"ls exec\") }"} +set thread_begin_script {"probe process(\"/bin/ls\").thread.begin { print(\"ls thread.begin\") }"} +set thread_end_script {"probe process(\"/bin/ls\").thread.end { print(\"ls thread.end\") }"} # Try to find utrace_attach symbol in /proc/kallsyms set path "/proc/kallsyms" @@ -69,16 +70,16 @@ set TEST_NAME "UTRACE_P4_01" if {$utrace_support_found == 0} { untested "$TEST_NAME : no kernel utrace support found" } else { - # Try compiling a clone script - stap_compile $TEST_NAME 1 $clone_script + # Try compiling a begin script + stap_compile $TEST_NAME 1 $begin_script } set TEST_NAME "UTRACE_P4_02" if {$utrace_support_found == 0} { untested "$TEST_NAME : no kernel utrace support found" } else { - # Try compiling a death script - stap_compile $TEST_NAME 1 $death_script + # Try compiling a end script + stap_compile $TEST_NAME 1 $end_script } set TEST_NAME "UTRACE_P4_03" @@ -101,6 +102,14 @@ set TEST_NAME "UTRACE_P4_05" if {$utrace_support_found == 0} { untested "$TEST_NAME : no kernel utrace support found" } else { - # Try compiling an exec script - stap_compile $TEST_NAME 1 $exec_script + # Try compiling an thread.begin script + stap_compile $TEST_NAME 1 $thread_begin_script +} + +set TEST_NAME "UTRACE_P4_06" +if {$utrace_support_found == 0} { + untested "$TEST_NAME : no kernel utrace support found" +} else { + # Try compiling an thread.end script + stap_compile $TEST_NAME 1 $thread_end_script } diff --git a/testsuite/systemtap.base/utrace_p5.exp b/testsuite/systemtap.base/utrace_p5.exp index cbb867d1..fcd617fe 100644 --- a/testsuite/systemtap.base/utrace_p5.exp +++ b/testsuite/systemtap.base/utrace_p5.exp @@ -3,24 +3,27 @@ # 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]" +set multi_flags "libs=-lpthread" -set death_script { - global death_probes_fired = 0 +set end_script { + global end_probes_fired = 0 probe begin { printf("systemtap starting probe\n") } - probe process("%s").death { death_probes_fired++ } + probe process("%s").end { end_probes_fired++ } probe end { printf("systemtap ending probe\n") - printf("deaths = %%d\n", death_probes_fired) } + printf("end probes = %%d\n", end_probes_fired) } } -set death_script_output "deaths = 1\r\n" +set end_script_output "end probes = 1\r\n" -set exec_script { - global exec_probes_fired = 0 +set begin_script { + global begin_probes_fired = 0 probe begin { printf("systemtap starting probe\n") } - probe process("%s").exec { exec_probes_fired++ } + probe process("%s").begin { begin_probes_fired++ } probe end { printf("systemtap ending probe\n") - printf("execs = %%d\n", exec_probes_fired) } + printf("begin probes = %%d\n", begin_probes_fired) } } -set exec_script_output "execs = 1\r\n" +set begin_script_output "begin probes = 1\r\n" set syscall_script { global syscall_probes_fired = 0 @@ -46,17 +49,29 @@ set syscall_return_script { } set syscall_return_script_output "syscall_returns = \\d+\r\n" -set clone_script { - global clone_probes_fired = 0 +set thread_begin_script { + global thread_begin_probes_fired = 0 probe begin { printf("systemtap starting probe\n") } - probe process(%d).clone { clone_probes_fired++ } + probe process("%s").thread.begin { thread_begin_probes_fired++ } probe end { printf("systemtap ending probe\n") - if (clone_probes_fired > 0) { - printf("clones = %%d\n", clone_probes_fired) + if (thread_begin_probes_fired > 0) { + printf("thread_begins = %%d\n", thread_begin_probes_fired) } } } -set clone_script_output "clones = \\d+\r\n" +set thread_begin_script_output "thread_begins = \\d+\r\n" + +set thread_end_script { + global thread_end_probes_fired = 0 + probe begin { printf("systemtap starting probe\n") } + probe process("%s").thread.end { thread_end_probes_fired++ } + probe end { printf("systemtap ending probe\n") + if (thread_end_probes_fired > 0) { + printf("thread_ends = %%d\n", thread_end_probes_fired) + } + } +} +set thread_end_script_output "thread_ends = \\d+\r\n" # Try to find utrace_attach symbol in /proc/kallsyms set path "/proc/kallsyms" @@ -86,14 +101,33 @@ proc run_cat_5_sec {} { return 0; } +# Compile our multi-threaded test program. +set res [target_compile $multi_srcpath $multi_exepath executable $multi_flags] +if { $res != "" } { + verbose "target_compile failed: $res" 2 + fail "unable to compile $multi_srcpath" + return +} + +# "load" generation function for stap_run. It spawns our +# multi-threaded test program and waits for it to finish. +proc run_utrace_p5_multi {} { + global multi_exepath + + if {[catch {exec $multi_exepath} res]} { + verbose "unable to run $multi_exepath: $res" + } + return 0; +} + set TEST_NAME "UTRACE_P5_01" if {$utrace_support_found == 0} { untested "$TEST_NAME : no kernel utrace support found" } elseif {![installtest_p]} { untested "$TEST_NAME" } else { - set script [format $death_script $exepath] - stap_run $TEST_NAME run_cat_5_sec $death_script_output -e $script + set script [format $end_script $exepath] + stap_run $TEST_NAME run_cat_5_sec $end_script_output -e $script } set TEST_NAME "UTRACE_P5_02" @@ -102,8 +136,8 @@ if {$utrace_support_found == 0} { } elseif {![installtest_p]} { untested "$TEST_NAME" } else { - set script [format $exec_script $exepath] - stap_run $TEST_NAME run_cat_5_sec $exec_script_output -e $script + set script [format $begin_script $exepath] + stap_run $TEST_NAME run_cat_5_sec $begin_script_output -e $script } set TEST_NAME "UTRACE_P5_03" @@ -132,9 +166,21 @@ if {$utrace_support_found == 0} { } elseif {![installtest_p]} { untested "$TEST_NAME" } else { - set script [format $clone_script [pid]] - stap_run $TEST_NAME run_cat_5_sec $clone_script_output -e $script + set script [format $thread_begin_script $multi_exepath] + stap_run $TEST_NAME run_utrace_p5_multi $thread_begin_script_output \ + -e $script +} + +set TEST_NAME "UTRACE_P5_06" +if {$utrace_support_found == 0} { + untested "$TEST_NAME : no kernel utrace support found" +} elseif {![installtest_p]} { + untested "$TEST_NAME" +} else { + set script [format $thread_end_script $multi_exepath] + stap_run $TEST_NAME run_utrace_p5_multi $thread_end_script_output \ + -e $script } # Cleanup -exec rm -f $exepath +exec rm -f $exepath $multi_exepath diff --git a/testsuite/systemtap.base/utrace_p5_multi.c b/testsuite/systemtap.base/utrace_p5_multi.c new file mode 100644 index 00000000..153243d0 --- /dev/null +++ b/testsuite/systemtap.base/utrace_p5_multi.c @@ -0,0 +1,45 @@ +#include <stdio.h> +#include <stdlib.h> +#include <pthread.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> + +void *thread_function( void *ptr ); + +struct thread_data { + int tnum; +}; + +int +main() +{ + pthread_t thread1, thread2; + int iret1, iret2; + + /* Create independent threads each of which will execute function */ + struct thread_data t1 = { 1 }; + struct thread_data t2 = { 2 }; + iret1 = pthread_create(&thread1, NULL, thread_function, (void*) &t1); + iret2 = pthread_create(&thread2, NULL, thread_function, (void*) &t2); + + /* Wait till threads are complete before main continues. Unless we + * wait we run the risk of executing an exit which will terminate + * the process and all threads before the threads have + * completed. */ + pthread_join(thread1, NULL); + pthread_join(thread2, NULL); + + printf("Thread 1 returns: %d\n", iret1); + printf("Thread 2 returns: %d\n", iret2); + exit(0); +} + +void *thread_function(void *ptr) +{ + struct thread_data *td = ptr; + if (td->tnum == 1) { + int fd = open("/dev/null", O_RDONLY); + close(fd); + } +} diff --git a/testsuite/systemtap.base/warnings.exp b/testsuite/systemtap.base/warnings.exp index 6cff723d..b56d7a98 100644 --- a/testsuite/systemtap.base/warnings.exp +++ b/testsuite/systemtap.base/warnings.exp @@ -9,7 +9,7 @@ expect { eof { } } wait -if {$ok == 22} { +if {$ok == 14} { pass $test } else { fail "$test ($ok)" diff --git a/testsuite/systemtap.base/warnings.stp b/testsuite/systemtap.base/warnings.stp index a2ac5afc..94ed57b3 100644 --- a/testsuite/systemtap.base/warnings.stp +++ b/testsuite/systemtap.base/warnings.stp @@ -1,4 +1,4 @@ -# PR 1119, 6538 +# PR 1119 global elide_me1 function elide_me2 () {} @@ -6,3 +6,12 @@ function foo:long () { elide_me3 = 1 } function bar() { print(elide+me1) ; ; ; } probe never { elide_me4 = 1; (elide_me5+5); print (foo()) } probe never { print(elide+me1) bar () } + +# PR 6611 + +probe probea = kernel.statement("bio_init@fs/bio.c:135") + { printf("%d", funca(2)); elide_me6="foo" } +probe probea { printf("%d", funcb(2,3)); printf("%s",var) } + +function funcb(a:long, b:long) {return a + b} +function funca(a:long) {a=b; elide_me7=1; return a} diff --git a/testsuite/systemtap.context/backtrace.tcl b/testsuite/systemtap.context/backtrace.tcl index 6c8aee40..aaec4cb8 100644 --- a/testsuite/systemtap.context/backtrace.tcl +++ b/testsuite/systemtap.context/backtrace.tcl @@ -20,11 +20,11 @@ expect { incr m1 expect { -timeout 5 - -re {^ 0x[a-f0-9]+ : yyy_func2[^\[]+\[systemtap_test_module2\]\r\n} { + -re {^ 0x[a-f0-9]+ : yyy_func2[^\[]+\[systemtap_test_module2\]( \(inexact\))?\r\n} { if {$m1 == 1} {incr m1} exp_continue } - -re {^ 0x[a-f0-9]+ : yyy_func1[^\[]+\[systemtap_test_module2\]\r\n} { + -re {^ 0x[a-f0-9]+ : yyy_func1[^\[]+\[systemtap_test_module2\]( \(inexact\))?\r\n} { if {$m1 == 2} {incr m1} } } @@ -34,11 +34,11 @@ expect { incr m2 expect { -timeout 5 - -re {^ 0x[a-f0-9]+ : yyy_func2[^\[]+\[systemtap_test_module2\]\r\n} { + -re {^ 0x[a-f0-9]+ : yyy_func2[^\[]+\[systemtap_test_module2\]( \(inexact\))?\r\n} { if {$m2 == 1} {incr m2} exp_continue } - -re {^ 0x[a-f0-9]+ : yyy_func1[^\[]+\[systemtap_test_module2\]\r\n} { + -re {^ 0x[a-f0-9]+ : yyy_func1[^\[]+\[systemtap_test_module2\]( \(inexact\))?\r\n} { if {$m2 == 2} {incr m2} } } @@ -50,15 +50,15 @@ expect { incr m3 expect { -timeout 5 - -re {^ 0x[a-f0-9]+ : yyy_func3[^\[]+\[systemtap_test_module2\]\r\n} { + -re {^ 0x[a-f0-9]+ : yyy_func3[^\[]+\[systemtap_test_module2\]( \(inexact\))?\r\n} { if {$m3 == 1} {incr m3} exp_continue } - -re {^ 0x[a-f0-9]+ : yyy_func2[^\[]+\[systemtap_test_module2\]\r\n} { + -re {^ 0x[a-f0-9]+ : yyy_func2[^\[]+\[systemtap_test_module2\]( \(inexact\))?\r\n} { if {$m3 == 2} {incr m3} exp_continue } - -re {^ 0x[a-f0-9]+ : yyy_func1[^\[]+\[systemtap_test_module2\]\r\n} { + -re {^ 0x[a-f0-9]+ : yyy_func1[^\[]+\[systemtap_test_module2\]( \(inexact\))?\r\n} { if {$m3 == 3} {incr m3} } } @@ -68,11 +68,11 @@ expect { incr m4 expect { -timeout 5 - -re {^ 0x[a-f0-9]+ : yyy_func3[^\[]+\[systemtap_test_module2\]\r\n} { + -re {^ 0x[a-f0-9]+ : yyy_func3[^\[]+\[systemtap_test_module2\]( \(inexact\))?\r\n} { if {$m4 == 1} {incr m4} exp_continue } - -re {^ 0x[a-f0-9]+ : yyy_func2[^\[]+\[systemtap_test_module2\]\r\n} { + -re {^ 0x[a-f0-9]+ : yyy_func2[^\[]+\[systemtap_test_module2\]( \(inexact\))?\r\n} { if {$m4 == 2} {incr m4} exp_continue } @@ -88,19 +88,19 @@ expect { incr m5 expect { -timeout 5 - -re {^ 0x[a-f0-9]+ : yyy_func4[^\[]+\[systemtap_test_module2\]\r\n} { + -re {^ 0x[a-f0-9]+ : yyy_func4[^\[]+\[systemtap_test_module2\]( \(inexact\))?\r\n} { if {$m5 == 1} {incr m5} exp_continue } - -re {^ 0x[a-f0-9]+ : yyy_func3[^\[]+\[systemtap_test_module2\]\r\n} { + -re {^ 0x[a-f0-9]+ : yyy_func3[^\[]+\[systemtap_test_module2\]( \(inexact\))?\r\n} { if {$m5 == 2} {incr m5} exp_continue } - -re {^ 0x[a-f0-9]+ : yyy_func2[^\[]+\[systemtap_test_module2\]\r\n} { + -re {^ 0x[a-f0-9]+ : yyy_func2[^\[]+\[systemtap_test_module2\]( \(inexact\))?\r\n} { if {$m5 == 3} {incr m5} exp_continue } - -re {^ 0x[a-f0-9]+ : yyy_func1[^\[]+\[systemtap_test_module2\]\r\n} { + -re {^ 0x[a-f0-9]+ : yyy_func1[^\[]+\[systemtap_test_module2\]( \(inexact\))?\r\n} { if {$m5 == 4} {incr m5} } } @@ -110,19 +110,19 @@ expect { incr m6 expect { -timeout 5 - -re {^ 0x[a-f0-9]+ : yyy_func4[^\[]+\[systemtap_test_module2\]\r\n} { + -re {^ 0x[a-f0-9]+ : yyy_func4[^\[]+\[systemtap_test_module2\]( \(inexact\))?\r\n} { if {$m6 == 1} {incr m6} exp_continue } - -re {^ 0x[a-f0-9]+ : yyy_func3[^\[]+\[systemtap_test_module2\]\r\n} { + -re {^ 0x[a-f0-9]+ : yyy_func3[^\[]+\[systemtap_test_module2\]( \(inexact\))?\r\n} { if {$m6 == 2} {incr m6} exp_continue } - -re {^ 0x[a-f0-9]+ : yyy_func2[^\[]+\[systemtap_test_module2\]\r\n} { + -re {^ 0x[a-f0-9]+ : yyy_func2[^\[]+\[systemtap_test_module2\]( \(inexact\))?\r\n} { if {$m6 == 3} {incr m6} exp_continue } - -re {^ 0x[a-f0-9]+ : yyy_func1[^\[]+\[systemtap_test_module2\]\r\n} { + -re {^ 0x[a-f0-9]+ : yyy_func1[^\[]+\[systemtap_test_module2\]( \(inexact\))?\r\n} { if {$m6 == 4} {incr m6} } } diff --git a/testsuite/systemtap.context/context.exp b/testsuite/systemtap.context/context.exp index 71201a58..010db445 100644 --- a/testsuite/systemtap.context/context.exp +++ b/testsuite/systemtap.context/context.exp @@ -1,4 +1,4 @@ -set testlist {backtrace args pid} +set testlist {backtrace args pid num_args} if {![installtest_p]} { foreach test $testlist { diff --git a/testsuite/systemtap.context/num_args.stp b/testsuite/systemtap.context/num_args.stp new file mode 100644 index 00000000..9f15bb01 --- /dev/null +++ b/testsuite/systemtap.context/num_args.stp @@ -0,0 +1,53 @@ +%( arch == "i386" %? global ir = "eax", lr = "eax" %) +%( arch == "i686" %? global ir = "eax", lr = "eax" %) +%( arch == "x86_64" %? global ir = "eax", lr = "rax" %) +%( arch == "ppc64" %? global ir = "r3", lr = "r3" %) + +probe module("systemtap_test_module2").function("yyy_int") { + printf("yyy_int %d %d %d\n", int_arg(1), int_arg(2), int_arg(3)) +} +probe module("systemtap_test_module2").function("yyy_int").return { + printf("yyy_int returns %d\n", register(ir)) +} +probe module("systemtap_test_module2").function("yyy_uint") { + printf("yyy_uint %d %d %d\n", uint_arg(1), uint_arg(2), uint_arg(3)) +} +probe module("systemtap_test_module2").function("yyy_uint").return { + printf("yyy_uint returns %d\n", u_register(ir)) +} +probe module("systemtap_test_module2").function("yyy_long") { + printf("yyy_long %d %d %d\n", long_arg(1), long_arg(2), long_arg(3)) +} +probe module("systemtap_test_module2").function("yyy_long").return { + printf("yyy_long returns %d\n", register(lr)) +} +probe module("systemtap_test_module2").function("yyy_int64") { +# On i386, kernel is built with -mregparm=3. The first arg occupies the +# first two registers. The 2nd arg is not split between the 3rd register +# and the stack, but rather passed entirely on the stack. + printf("yyy_int64 %d %d %d\n", +%( arch == "i386" %? s64_arg(1), s64_arg(4), s64_arg(6) +%: %( arch == "i686" %? s64_arg(1), s64_arg(4), s64_arg(6) + %: s64_arg(1), s64_arg(2), s64_arg(3) + %) +%) + ) +} +probe module("systemtap_test_module2").function("yyy_int64").return { + printf("yyy_int64 returns %d\n", register(ir)) +} +probe module("systemtap_test_module2").function("yyy_char") { + printf("yyy_char %1b %1b %1b\n", int_arg(1), int_arg(2), int_arg(3)) +} +probe module("systemtap_test_module2").function("yyy_char").return { + printf("yyy_char returns %1b\n", register(ir)) +} +probe module("systemtap_test_module2").function("yyy_str") { + printf("yyy_str %s-%s-%s\n", kernel_string(pointer_arg(1)), kernel_string(pointer_arg(2)), kernel_string(pointer_arg(3))) +} +probe module("systemtap_test_module2").function("yyy_str").return { + printf("yyy_str returns %s\n", kernel_string(register(lr))) +} +probe begin { + printf("READY\n") +} diff --git a/testsuite/systemtap.context/num_args.tcl b/testsuite/systemtap.context/num_args.tcl new file mode 100644 index 00000000..48e83f4d --- /dev/null +++ b/testsuite/systemtap.context/num_args.tcl @@ -0,0 +1,62 @@ +set arglists {{} {--kelf --ignore-dwarf}} +foreach arglist $arglists { +set tag [concat numeric $arglist] +eval spawn stap $arglist $srcdir/$subdir/num_args.stp +expect { + -timeout 240 + "READY" { + exec echo 1 > /proc/stap_test_cmd + expect { + -timeout 5 + "yyy_int -1 200 300\r\nyyy_int returns 499\r\n" { + pass "integer function arguments -- $tag" + } + timeout {fail "integer function arguments -- $tag"} + } + exec echo 2 > /proc/stap_test_cmd + expect { + -timeout 5 + "yyy_uint 4294967295 200 300\r\nyyy_uint returns 499\r\n" { + pass "unsigned function arguments -- $tag" + } + timeout {fail "unsigned function arguments -- $tag"} + } + exec echo 3 > /proc/stap_test_cmd + expect { + -timeout 5 + "yyy_long -1 200 300\r\nyyy_long returns 499\r\n" { + pass "long function arguments -- $tag" + } + timeout {fail "long function arguments -- $tag"} + } + exec echo 4 > /proc/stap_test_cmd + expect { + -timeout 5 + "yyy_int64 -1 200 300\r\nyyy_int64 returns 499\r\n" { + pass "int64 function arguments -- $tag" + } + timeout {fail "int64 function arguments -- $tag"} + } + exec echo 5 > /proc/stap_test_cmd + expect { + -timeout 5 + "yyy_char a b c\r\nyyy_char returns Q\r\n" { + pass "char function arguments -- $tag" + } + timeout {fail "char function arguments -- $tag"} + } + exec echo 6 > /proc/stap_test_cmd + expect { + -timeout 5 + "yyy_str Hello-System-Tap\r\nyyy_str returns XYZZY\r\n" { + pass "string function arguments -- $tag" + } + timeout {fail "string function arguments -- $tag"} + } + } + eof {fail "function arguments -- $tag: unexpected timeout"} +} +exec kill -INT -[exp_pid] +close +wait +} diff --git a/testsuite/systemtap.examples/ChangeLog b/testsuite/systemtap.examples/ChangeLog index 743e7adf..b1c34347 100644 --- a/testsuite/systemtap.examples/ChangeLog +++ b/testsuite/systemtap.examples/ChangeLog @@ -1,3 +1,23 @@ +2008-06-20 William Cohen <wcohen@redhat.com> + + * traceio2.meta: Correct test_check and test_installcheck commands. + +2008-06-20 William Cohen <wcohen@redhat.com> + + * traceio2.stp, traceio2.meta: New. + +2008-06-18 William Cohen <wcohen@redhat.com> + + * sleepingBeauties.stp, sleepingBeauties.meta: New. + +2008-06-17 William Cohen <wcohen@redhat.com> + + * graphs.stp, graphs.meta: New. + +2008-06-12 William Cohen <wcohen@redhat.com> + + * thread-times.stp, thread-times.meta: New. + 2008-05-20 William Cohen <wcohen@redhat.com> * io_submit.stp, io_submit.meta: diff --git a/testsuite/systemtap.examples/graphs.meta b/testsuite/systemtap.examples/graphs.meta new file mode 100644 index 00000000..60a522b3 --- /dev/null +++ b/testsuite/systemtap.examples/graphs.meta @@ -0,0 +1,13 @@ +title: Graphing Disk and CPU Utilization +name: graphs.stp +version: 1.0 +author: anonymous +keywords: disk cpu use graph +subsystem: disk cpu +status: production +exit: user-controlled +output: plot data +scope: system-wide +description: The script tracks the disk and CPU utilization. The resulting output of the script can be piped into gnuplot to generate a graph of disk and CPU USE. +test_check: stap -p4 graphs.stp +test_installcheck: stap graphs.stp -c "sleep 1" diff --git a/testsuite/systemtap.examples/graphs.stp b/testsuite/systemtap.examples/graphs.stp new file mode 100644 index 00000000..0c8e3796 --- /dev/null +++ b/testsuite/systemtap.examples/graphs.stp @@ -0,0 +1,60 @@ +#! stap + +# ------------------------------------------------------------------------ +# data collection + +# disk I/O stats +probe begin { qnames["ioblock"] ++; qsq_start ("ioblock") } +probe ioblock.request { qs_wait ("ioblock") qs_run("ioblock") } +probe ioblock.end { qs_done ("ioblock") } + +# CPU utilization +probe begin { qnames["cpu"] ++; qsq_start ("cpu") } +probe scheduler.cpu_on { if (!idle) {qs_wait ("cpu") qs_run ("cpu") }} +probe scheduler.cpu_off { if (!idle) qs_done ("cpu") } + + +# ------------------------------------------------------------------------ +# utilization history tracking + +global N +probe begin { N = 50 } + +global qnames, util, histidx + +function qsq_util_reset(q) { + u=qsq_utilization (q, 100) + qsq_start (q) + return u +} + +probe timer.ms(100) { # collect utilization percentages frequently + histidx = (histidx + 1) % N # into circular buffer + foreach (q in qnames) + util[histidx,q] = qsq_util_reset(q) +} + + +# ------------------------------------------------------------------------ +# general gnuplot graphical report generation + +probe timer.ms(1000) { + # emit gnuplot command to display recent history + + printf ("set yrange [0:100]\n") + printf ("plot ") + foreach (q in qnames+) + { + if (++nq >= 2) printf (", ") + printf ("'-' title \"%s\" with lines", q) + } + printf ("\n") + + foreach (q in qnames+) { + for (i = (histidx + 1) % N; i != histidx; i = (i + 1) % N) + printf("%d\n", util[i,q]) + printf ("e\n") + } + + printf ("pause 1\n") +} diff --git a/testsuite/systemtap.examples/sleepingBeauties.meta b/testsuite/systemtap.examples/sleepingBeauties.meta new file mode 100644 index 00000000..95e08361 --- /dev/null +++ b/testsuite/systemtap.examples/sleepingBeauties.meta @@ -0,0 +1,13 @@ +title: Generating Backtraces of Threads Waiting for IO Operations +name: sleepingBeauties.stp +version: 1.0 +author: anonymous +keywords: io scheduler +subsystem: scheduler +status: production +exit: user-controlled +output: trace +scope: system-wide +description: The script monitor time threads spend waiting for IO operations (in "D" state) in the wait_for_completion function. If a thread spends over 10ms wall-clock time waiting, information is printed out describing the thread number and executable name. When slow the wait_for_completion function complete, backtraces for the long duration calls are printed out. +test_check: stap -p4 sleepingBeauties.stp +test_installcheck: stap sleepingBeauties.stp -c "sleep 1" diff --git a/testsuite/systemtap.examples/sleepingBeauties.stp b/testsuite/systemtap.examples/sleepingBeauties.stp new file mode 100644 index 00000000..64c563a3 --- /dev/null +++ b/testsuite/systemtap.examples/sleepingBeauties.stp @@ -0,0 +1,58 @@ +#! /usr/bin/stap + +function time () { return gettimeofday_ms() } +global time_name = "ms" +global boredom = 10 # in time units +global name, back, backtime, bored + +/* Note: the order that the probes are listed should not matter. + However, the following order for + probe kernel.function("wait_for_completion").return and + probe kernel.function("wait_for_completion").call + avoids have the kretprobe stuff in the backtrace. + for more information see: + http://sources.redhat.com/bugzilla/show_bug.cgi?id=6436 +*/ + + +probe kernel.function("wait_for_completion").return +{ + t=tid() + + if ([t] in bored) { + patience = time() - backtime[t] + printf ("thread %d (%s) bored for %d %s\n", + t, name[t], patience, time_name) + } + + delete bored[t] + delete back[t] + delete name[t] + delete backtime[t] +} + + +probe kernel.function("wait_for_completion").call +{ + t=tid() + back[t]=backtrace() + name[t]=execname() + backtime[t]=time() + delete bored[t] +} + + +probe timer.profile { + foreach (tid+ in back) { + if ([tid] in bored) continue + + patience = time() - backtime[tid] + if (patience >= boredom) { + printf ("thread %d (%s) impatient after %d %s\n", + tid, name[tid], patience, time_name) + print_stack (back[tid]) + printf ("\n") + bored[tid] = 1 # defer further reports to wakeup + } + } +} diff --git a/testsuite/systemtap.examples/thread-times.meta b/testsuite/systemtap.examples/thread-times.meta new file mode 100644 index 00000000..fcbf062e --- /dev/null +++ b/testsuite/systemtap.examples/thread-times.meta @@ -0,0 +1,13 @@ +title: Profile kernel functions +name: thread-times.stp +version: 1.0 +author: anonymous +keywords: profiling +subsystem: kernel +status: production +exit: user-controlled +output: sorted-list +scope: system-wide +description: The thread-times.stp script sets up time-based sampling. Every five seconds it prints out a sorted list with the top twenty processes with samples broken down into percentage total time spent in user-space and kernel-space. +test_check: stap -p4 thread-times.stp +test_installcheck: stap thread-times.stp -c "sleep 1" diff --git a/testsuite/systemtap.examples/thread-times.stp b/testsuite/systemtap.examples/thread-times.stp new file mode 100644 index 00000000..1aeb2037 --- /dev/null +++ b/testsuite/systemtap.examples/thread-times.stp @@ -0,0 +1,32 @@ +#! /usr/bin/stap + +probe timer.profile { + tid=tid() + if (!user_mode()) + kticks[tid] <<< 1 + else + uticks[tid] <<< 1 + ticks <<< 1 + tids[tid] <<< 1 +} + +global uticks, kticks, ticks + +global tids + +probe timer.s(5), end { + allticks = @count(ticks) + printf ("%5s %7s %7s (of %d ticks)\n", "tid", "%user", "%kernel", allticks) + foreach (tid in tids- limit 20) { + uscaled = @count(uticks[tid])*10000/allticks + kscaled = @count(kticks[tid])*10000/allticks + printf ("%5d %3d.%02d%% %3d.%02d%%\n", + tid, uscaled/100, uscaled%100, kscaled/100, kscaled%100) + } + printf("\n") + + delete uticks + delete kticks + delete ticks + delete tids +} diff --git a/testsuite/systemtap.examples/traceio2.meta b/testsuite/systemtap.examples/traceio2.meta new file mode 100644 index 00000000..e6bca1a9 --- /dev/null +++ b/testsuite/systemtap.examples/traceio2.meta @@ -0,0 +1,13 @@ +title: Watch I/O Activity on a Particular Device +name: traceio2.stp +version: 1.0 +author: Red Hat +keywords: io +subsystem: io +status: production +exit: user-controlled +output: trace +scope: system-wide +description: Print out the executable name and process number as reads and writes to the specified device occur. +test_check: stap -p4 traceio2.stp 0x0801 +test_installcheck: /bin/sh eval stap traceio2.stp 0x0801 -c "sleep 1" diff --git a/testsuite/systemtap.examples/traceio2.stp b/testsuite/systemtap.examples/traceio2.stp new file mode 100644 index 00000000..656c38b3 --- /dev/null +++ b/testsuite/systemtap.examples/traceio2.stp @@ -0,0 +1,20 @@ +global device_of_interest + +probe begin { + /* The following is not the most efficient way to do this. + One could directly put the result of usrdev2kerndev() + into device_of_interest. However, want to test out + the other device functions */ + dev = usrdev2kerndev($1) + device_of_interest = MKDEV(MAJOR(dev), MINOR(dev)) +} + +probe kernel.function ("vfs_write"), + kernel.function ("vfs_read") +{ + dev_nr = $file->f_path->dentry->d_inode->i_sb->s_dev + + if (dev_nr == device_of_interest) + printf ("%s(%d) %s 0x%x\n", + execname(), pid(), probefunc(), dev_nr) +} diff --git a/testsuite/systemtap.pass1-4/buildok.exp b/testsuite/systemtap.pass1-4/buildok.exp index 07580550..08d50fb5 100644 --- a/testsuite/systemtap.pass1-4/buildok.exp +++ b/testsuite/systemtap.pass1-4/buildok.exp @@ -9,6 +9,9 @@ foreach file [lsort [glob -nocomplain $srcdir/$self/*.stp]] { buildok/twentysix.stp {setup_kfail 4105 *-*-*} buildok/twentyseven.stp {setup_kfail 4166 *-*-*} buildok/sched_test.stp {setup_kfail 1155 *-*-*} + buildok/process_test.stp {setup_kfail 1155 *-*-*} + buildok/rpc-all-probes.stp {setup_kfail 4413 *-*-*} + buildok/nfs-all-probes.stp {setup_kfail 4413 *-*-*} } if {$rc == 0} { pass $test } else { fail $test } } diff --git a/testsuite/systemtap.samples/profile.exp b/testsuite/systemtap.samples/profile.exp index 9ca9da15..87174d2c 100644 --- a/testsuite/systemtap.samples/profile.exp +++ b/testsuite/systemtap.samples/profile.exp @@ -12,4 +12,4 @@ expect { #FIXME does not handle case of hanging primes.stp correctly wait -if {$ok > 0} { pass "$test ($ok)" } { fail "$test" } +if {$ok > 0} { pass $test } { fail $test } |