diff options
Diffstat (limited to 'testsuite/systemtap.base')
-rw-r--r-- | testsuite/systemtap.base/mysql.exp | 344 | ||||
-rw-r--r-- | testsuite/systemtap.base/onoffprobe.exp | 20 | ||||
-rw-r--r-- | testsuite/systemtap.base/postgres.exp | 166 | ||||
-rw-r--r-- | testsuite/systemtap.base/pr10854.exp | 32 | ||||
-rw-r--r-- | testsuite/systemtap.base/pr10854.stp | 20 |
5 files changed, 71 insertions, 511 deletions
diff --git a/testsuite/systemtap.base/mysql.exp b/testsuite/systemtap.base/mysql.exp deleted file mode 100644 index 44b30cf4..00000000 --- a/testsuite/systemtap.base/mysql.exp +++ /dev/null @@ -1,344 +0,0 @@ -set test "mysql" - -# Test sdt support in mysql. - -global env - -if {! [info exists env(SYSTEMTAP_TEST_SDT)]} { - unsupported "mysql (\"SYSTEMTAP_TEST_SDT\" not in env)" - return -} - -########## Create /tmp/stap-mysql.stp ########## -set msdata "[pwd]/stap-mysql" -set mysqlrelease "mysql-5.4.1-beta" -set mysqldir "[pwd]/mysql/install/" -set testsuite "[pwd]" - -set fp [open "$testsuite/stap-mysql.stp" "w"] -puts $fp " -probe process(@1).mark(\"connection__start\") -{ - arg2 = user_string(\$arg2) - arg3 = user_string(\$arg3) - printf(\"%s %#x %s %s\\n\",\"connection__start\", \$arg1, arg2, arg3); -} -probe process(@1).mark(\"connection__done\") -{ - printf(\"%s %#x %#x \\n\",\"connection__done\", \$arg1, \$arg2); -} -probe process(@1).mark(\"command__start\") -{ - arg3 = user_string(\$arg3) - arg4 = user_string(\$arg4) - printf(\"%s %#x %#x %s %s\\n\",\"command__start\", \$arg1, \$arg2, arg3, arg4); -} -probe process(@1).mark(\"command__done\") -{ - printf(\"%s %#x\\n\",\"command__done\", \$arg1); -} -probe process(@1).mark(\"query__start\") -{ - arg1 = user_string(\$arg1) - arg3 = user_string(\$arg3) - arg4 = user_string(\$arg4) - arg5 = user_string(\$arg5) - printf(\"%s %s %#x %s %s %s\\n\",\"query__start\", arg1, \$arg2, - arg3, arg4, arg5); -} -probe process(@1).mark(\"query__done\") -{ - printf(\"%s %#x\\n\",\"query__done\", \$arg1); -} -probe process(@1).mark(\"query__parse__start\") -{ - arg1 = user_string(\$arg1) - printf(\"%s %s\\n\",\"query__parse__start\", arg1); -} -probe process(@1).mark(\"query__parse__done\") -{ - printf(\"%s %#x\\n\",\"query__parse__done\", \$arg1); -} -probe process(@1).mark(\"query__cache__hit\") -{ - arg1=user_string(\$arg1) - arg2=user_string(\$arg2) - printf(\"%s %s %s \\n\",\"query__cache__hit\", arg1, arg2); -} -probe process(@1).mark(\"query__cache__miss\") -{ - arg1=user_string(\$arg1) - printf(\"%s %s\\n\",\"query__cache__miss\", arg1); -} -probe process(@1).mark(\"query__exec__start\") -{ - arg1=user_string(\$arg1) - arg3=user_string(\$arg3) - arg4=user_string(\$arg4) - arg5=user_string(\$arg5) - printf(\"%s %s %#x %s %s %s\\n\",\"query__exec__start\", arg1, \$arg2, - arg3, arg4, arg5); -} -probe process(@1).mark(\"query__exec__done\") -{ - printf(\"%s %#x\\n\",\"query__exec__done\", \$arg1); -} -probe process(@1).mark(\"insert__row__start\") -{ - arg1=user_string(\$arg1) - arg2=user_string(\$arg2) - printf(\"%s %s %s \\n\",\"insert__row__start\", arg1, arg2); -} -probe process(@1).mark(\"insert__row__done\") -{ - printf(\"%s %#x\\n\",\"insert__row__done\", \$arg1); -} -probe process(@1).mark(\"update__row__start\") -{ - arg1=user_string(\$arg1) - arg2=user_string(\$arg2) - printf(\"%s %s %s \\n\",\"update__row__start\", arg1, arg2); -} -probe process(@1).mark(\"update__row__done\") -{ - printf(\"%s %#x\\n\",\"update__row__done\", \$arg1); -} -probe process(@1).mark(\"delete__row__start\") -{ - arg1=user_string(\$arg1) - arg2=user_string(\$arg2) - printf(\"%s %s %s \\n\",\"delete__row__start\", arg1, arg2); -} -probe process(@1).mark(\"delete__row__done\") -{ - printf(\"%s %#x\\n\",\"delete__row__done\", \$arg1); -} -probe process(@1).mark(\"handler__rdlock__start\") -{ - arg1=user_string(\$arg1) - arg2=user_string(\$arg2) - printf(\"%s %s %s \\n\",\"handler__rdlock__start\", arg1, arg2); -} -probe process(@1).mark(\"handler__wrlock__start\") -{ - arg1=user_string(\$arg1) - arg2=user_string(\$arg2) - printf(\"%s %s %s \\n\",\"handler__wrlock__start\", arg1, arg2); -} -probe process(@1).mark(\"handler__unlock__start\") -{ - arg1=user_string(\$arg1) - arg2=user_string(\$arg2) - printf(\"%s %s %s \\n\",\"handler__unlock__start\", arg1, arg2); -} -probe process(@1).mark(\"handler__rdlock__done\") -{ - printf(\"%s %#x\\n\",\"handler__rdlock__done\", \$arg1); -} -probe process(@1).mark(\"handler__wrlock__done\") -{ - printf(\"%s %#x\\n\",\"handler__wrlock__done\", \$arg1); -} -probe process(@1).mark(\"handler__unlock__done\") -{ - printf(\"%s %#x\\n\",\"handler__unlock__done\", \$arg1); -} -probe process(@1).mark(\"filesort__start\") -{ - printf(\"%s %#x %#x \\n\",\"filesort__start\", \$arg1, \$arg2); -} -probe process(@1).mark(\"filesort__done\") -{ - printf(\"%s %#x %#x \\n\",\"filesort__done\", \$arg1, \$arg2); -} -probe process(@1).mark(\"select__start\") -{ - arg1=user_string(\$arg1) - printf(\"%s %s\\n\",\"select__start\", arg1); -} -probe process(@1).mark(\"select__done\") -{ - printf(\"%s %#x %#x \\n\",\"select__done\", \$arg1, \$arg2); -} -probe process(@1).mark(\"insert__start\") -{ - arg1=user_string(\$arg1) - printf(\"%s %s\\n\",\"insert__start\", arg1); -} -probe process(@1).mark(\"insert__done\") -{ - printf(\"%s %#x %#x \\n\",\"insert__done\", \$arg1, \$arg2); -} -probe process(@1).mark(\"insert__select__start\") -{ - arg1=user_string(\$arg1) - printf(\"%s %s\\n\",\"insert__select__start\", arg1); -} -probe process(@1).mark(\"insert__select__done\") -{ - printf(\"%s %#x %#x \\n\",\"insert__select__done\", \$arg1, \$arg2); -} -probe process(@1).mark(\"update__start\") -{ - arg1=user_string(\$arg1) - printf(\"%s %s\\n\",\"update__start\", arg1); -} -probe process(@1).mark(\"update__done\") -{ - printf(\"%s %#x %#x %#x\\n\",\"update__done\", \$arg1, \$arg2, \$arg3); -} -probe process(@1).mark(\"multi__update__start\") -{ - arg1=user_string(\$arg1) - printf(\"%s %s\\n\",\"multi__update__start\", arg1); -} -probe process(@1).mark(\"multi__update__done\") -{ - printf(\"%s %#x %#x %#x\\n\",\"multi__update__done\", \$arg1, \$arg2, \$arg3); -} -probe process(@1).mark(\"delete__start\") -{ - arg1=user_string(\$arg1) - printf(\"%s %s\\n\",\"delete__start\", arg1); -} -probe process(@1).mark(\"delete__done\") -{ - printf(\"%s %#x %#x \\n\",\"delete__done\", \$arg1, \$arg2); -} -probe process(@1).mark(\"multi__delete__start\") -{ - arg1=user_string(\$arg1) - printf(\"%s %s\\n\",\"multi__delete__start\", arg1); -} -probe process(@1).mark(\"multi__delete__done\") -{ - printf(\"%s %#x %#x \\n\",\"multi__delete__done\", \$arg1, \$arg2); -} -probe process(@1).mark(\"net__read__start\") -{ - printf(\"%s \\n\",\"net__read__start\"); -} -probe process(@1).mark(\"net__read__done\") -{ - printf(\"%s %#x %#x \\n\",\"net__read__done\", \$arg1, \$arg2); -} -probe process(@1).mark(\"net__write__start\") -{ - printf(\"%s %#x\\n\",\"net__write__start\", \$arg1); -} -probe process(@1).mark(\"net__write__done\") -{ - printf(\"%s %#x\\n\",\"net__write__done\", \$arg1); -} -" -close $fp - -########## Begin /tmp/stap-mysql.sh ########## -set fp [open "$testsuite/stap-mysql.sh" "w"] -puts $fp " -##### begin run_tests ##### -function run_tests \{ -/bin/rm -rf $testsuite/stap-mysql -$mysqldir/bin/mysql_install_db --basedir=$mysqldir --datadir=$msdata - -(cd $mysqldir/mysql-test -# wait until mysql is running -MOD=stapsdt_\$(date +%j%k%M%N | sed 's/ //') -/usr/local/bin/stap -m \$MOD -c \"$mysqldir/libexec/mysqld --basedir=$mysqldir --datadir=$msdata --log-error=$msdata/mysql.log --pid-file=$msdata/mysql.pid --socket=$msdata/mysql.sock\" $testsuite/stap-mysql.stp $mysqldir/libexec/mysqld >$testsuite/stap-mysql-markers.log 2>&1 & -STAPPID=\$! - -for i in \$(seq 0 10) ; do - if $mysqldir/bin/mysqladmin ping --socket=$msdata/mysql.sock - then break; - fi - sleep 5 -done - -for i in select join insert query -do - echo '##### ' \$i - ./mysql-test-run.pl --force --extern socket=$msdata/mysql.sock \ - --tmpdir=/tmp/,mysql --vardir=/tmp/,mysql --do-test=\$i -done > $testsuite/stap-mysql.log -) - -ACQUIRE=\$(grep 'handler__unlock__start' $testsuite/stap-mysql-markers.log | wc -l) -RELEASE=\$(grep 'handler__unlock__done' $testsuite/stap-mysql-markers.log | wc -l) -COMMAND=\$(grep 'command__start' $testsuite/stap-mysql-markers.log | wc -l) -QUERY=\$(grep 'query__start' $testsuite/stap-mysql-markers.log | wc -l) -RDLOCK=\$(grep 'handler__rdlock__start' $testsuite/stap-mysql-markers.log | wc -l) -SELECT=\$(grep 'select_start' $testsuite/stap-mysql-markers.log | wc -l) -OKAY=\$(grep 'All.*tests were successful' $testsuite/stap-mysql.log | wc -l) - -echo ACQUIRE=\$ACQUIRE RELEASE=\$RELEASE COMMAND=\$COMMAND QUERY=\$QUERY RDLOCK=\$RDLOCK SELECT=\$SELECT OKAY=\$OKAY -if \[ \$ACQUIRE -gt 10000 -a \$RELEASE -gt 1000 -a \$COMMAND -gt 12000 -a \$QUERY -gt 13000 -a \$RDLOCK -gt 3000 \] ; then - echo PASS: mysql markers \$1 -else - echo FAIL: mysql markers \$1 -fi - -if \[ \$OKAY -eq 4 \] ; then - echo PASS: mysql tests \$1 -else - echo FAIL: mysql tests \$1 -fi - -$mysqldir/bin/mysqladmin shutdown -u root --socket=stap-mysql/mysql.sock -kill \$STAPPID -\} -##### end run_tests ##### - -if \[ ! -r $mysqlrelease.tar.gz \] ; then -wget http://dev.mysql.com/get/Downloads/MySQL-5.4/$mysqlrelease.tar.gz/from/ftp://mirror.services.wisc.edu/mirrors/mysql/ -fi - -if \[ ! -d mysql/src \] ; then -tar -x -z -f $mysqlrelease.tar.gz -mkdir mysql -mv $mysqlrelease mysql/src -fi - -if \[ ! -f mysql/install/bin/mysql \] ; then -cd mysql -mkdir bld -cd bld -# Force the use of dtrace -sed -i -e 's/HAVE_DTRACE_DASH_G=\"no\"/HAVE_DTRACE_DASH_G=\"yes\"/' ../src/configure -../src/configure --enable-dtrace --prefix=$mysqldir -for i in \$(find . -name Makefile) ; do - sed -i -e 's/^CXXFLAGS =/& -g/' \$i -done - -make -j2 -cp ./abi_check.out ../../src/include/mysql.h.pp -make -j2 -make install -fi - -run_tests uprobe -" -########## End /tmp/stap-mysql.sh ########## -close $fp - -########## /tmp/stap-mysql.sh does most of the work ########## -verbose -log Running mysql testsuite -spawn sh stap-mysql.sh 2>&1 -expect { - -timeout 1000 - -re {FAIL: [a-z_ ]+} { regexp " .*$" $expect_out(0,string) s; - fail "$s"; exp_continue } - -re {PASS: [a-z_ ]+} { regexp " .*$" $expect_out(0,string) s; - pass "$s"; exp_continue } - -re {UNSUPPORTED: [a-zA-Z_/: ]+} { regexp " .*$" $expect_out(0,string) s; - verbose -log "$s" - unsupported "$s"; exp_continue } - timeout { fail "$test (timeout)" } - eof { } -} - -if { $verbose == 0 } { -catch {exec rm -rf $msdata} -catch {exec rm -rf $testsuite/stap-mysql.stp $testsuite/stap-mysql.log \ - $testsuite/stap-mysql-markers.log $testsuite/stap-mysql.sh $mysqlrelease.tar.gz} -catch {exec rm -rf mysql} -} diff --git a/testsuite/systemtap.base/onoffprobe.exp b/testsuite/systemtap.base/onoffprobe.exp index 1b39dab5..c6d83d5d 100644 --- a/testsuite/systemtap.base/onoffprobe.exp +++ b/testsuite/systemtap.base/onoffprobe.exp @@ -10,9 +10,27 @@ proc advance {} { global expect_out global ok global modname + set procfs_file "/proc/systemtap/$modname/switch" + pass "$test $expect_out(1,string)" + + # If this is the first time, wait until the procfs file exists + # (for up to 10 seconds). + if {$ok == 0} { + set i 0 + while {![file exists $procfs_file]} { + sleep 1 + incr i + if {$i >= 10} { break } + } + # If the procfs file still doesn't exist, fail. + if {![file exists $procfs_file]} { + fail "$test (missing procfs file)" + } + } + incr ok - exec echo $ok > /proc/systemtap/$modname/switch + if {[file exists $procfs_file]} { exec echo $ok > $procfs_file } exec echo dummy > /dev/null exp_continue } diff --git a/testsuite/systemtap.base/postgres.exp b/testsuite/systemtap.base/postgres.exp deleted file mode 100644 index ceef9437..00000000 --- a/testsuite/systemtap.base/postgres.exp +++ /dev/null @@ -1,166 +0,0 @@ -set test "postgres" - -# Test sdt support in postgres. - -global env - -if {! [info exists env(SYSTEMTAP_TEST_SDT)]} { - unsupported "postgres (\"SYSTEMTAP_TEST_SDT\" not in env)" - return -} - -########## Create /tmp/stap-postgres.stp ########## -set postgresbuild "[pwd]/postgresql-8.3.6/bld" -set postgresdir "[pwd]/postgresql-8.3.6/install/" -set pgdata "/tmp/stap-postgres" - - -set fp [open "$pgdata.stp" "w"] -puts $fp " -probe process(\"$postgresdir/bin/postgres\").mark(\"transaction__start\") -{ - printf(\"%s %#x\\n\", \$\$name, \$arg1); -} -probe process(\"$postgresdir/bin/postgres\").mark(\"transaction__commit\") -{ - printf(\"%s %#x\\n\", \$\$name, \$arg1); -} -probe process(\"$postgresdir/bin/postgres\").mark(\"transaction__abort\") -{ - printf(\"%s %#x\\n\", \$\$name, \$arg1); -} -probe process(\"$postgresdir/bin/postgres\").mark(\"lock__startwait\") -{ - printf(\"%s %#x %#x\\n\", \$\$name, \$arg1, \$arg2); -} -probe process(\"$postgresdir/bin/postgres\").mark(\"lock__endwait\") -{ - printf(\"%s %#x %#x\\n\", \$\$name, \$arg1, \$arg2); -} -probe process(\"$postgresdir/bin/postgres\").mark(\"lwlock__endwait\") -{ - printf(\"%s %#x %#x\\n\", \$\$name, \$arg1, \$arg2); -} -probe process(\"$postgresdir/bin/postgres\").mark(\"lwlock__acquire\") -{ - printf(\"%s %#x %#x\\n\", \$\$name, \$arg1, \$arg2); -} -probe process(\"$postgresdir/bin/postgres\").mark(\"lwlock__condacquire__fail\") -{ - printf(\"%s %#x %#x\\n\", \$\$name, - \$arg1, \$arg2); -} -probe process(\"$postgresdir/bin/postgres\").mark(\"lwlock__condacquire\") -{ - printf(\"%s %#x %#x\\n\", \$\$name, \$arg1, \$arg2); -} -probe process(\"$postgresdir/bin/postgres\").mark(\"lwlock__release\") -{ - printf(\"%s %#x\\n\", \$\$name, \$arg1); -} -" -close $fp - -########## Begin /tmp/stap-postgres.sh ########## -set fp [open "$pgdata.sh" "w"] -puts $fp " -function run_tests \{ -/bin/rm -rf $pgdata -$postgresdir/bin/initdb $pgdata - -which stap -stap -m \$(date +stapsdt_%j%k%M%N | sed 's/ //') -c \"$postgresdir/bin/postgres -D $pgdata\" $pgdata.stp >$pgdata-markers.log 2>&1 & -STAPPID=\$! - -# wait until postgres is running -for i in \$(seq 0 10) ; do - if $postgresdir/bin/pg_ctl status -D $pgdata - then break; - fi - sleep 5 -done - -(cd $postgresbuild/src/test/regress/ - make installcheck > $pgdata.log 2>&1) - -ACQUIRE=\$(grep 'lwlock__acquire 0x\[0-9\]* 0x\[0-9\]*' $pgdata-markers.log | wc -l) -RELEASE=\$(grep 'lwlock__release 0x\[0-9\]*' $pgdata-markers.log | wc -l) -START=\$(grep 'transaction__start 0x\[0-9\]*' $pgdata-markers.log | wc -l) -COMMIT=\$(grep 'transaction__commit 0x\[0-9\]*' $pgdata-markers.log | wc -l) -OKAY=\$(grep 'test .*ok' $pgdata.log | wc -l) - -echo lwlock__acquire=\$ACQUIRE lwlock__release=\$RELEASE transaction__start=\$START transaction__commit=\$COMMIT test-ok=\$OKAY -: 44873 75325 591 489 0 - -if \[ \$ACQUIRE -gt 40000 -a \$RELEASE -gt 70000 -a \$START -gt 500 -a \$COMMIT -gt 400 \] ; then - echo PASS: postgres tests \$1 -else - echo FAIL: postgres tests \$1 -fi - -if \[ \$OKAY -gt 100 \] ; then - echo PASS: postgres markers \$1 -else - echo FAIL: postgres markers \$1 -fi - -/usr/local/pgsql/bin/pg_ctl stop -D $pgdata -kill \$STAPPID -\} - -if \[ ! -r postgresql-8.3.6.tar.bz2 \] ; then -wget http://wwwmaster.postgresql.org/redir/198/h/source/v8.3.6/postgresql-8.3.6.tar.bz2 -fi - -if \[ ! -d $postgresbuild/src/backend \] ; then -tar -x -f postgresql-8.3.6.tar.bz2 -fi - -cd postgresql-8.3.6/ -mkdir bld;cd bld -../configure --enable-dtrace --prefix=$postgresdir -# sed -i -e 's/ifeq (\$(PORTNAME), solaris)/ifeq (\$(enable_dtrace), yes)/' src/backend/Makefile -sed -i -e 's/^CFLAGS = -O2.*\$/& -g -DEXPERIMENTAL_UTRACE_SDT/' src/Makefile.global -make -make install -run_tests utrace - -sed -i -e 's/UTRACE/KPROBE/' src/Makefile.global -(cd src/backend/utils/ - make clean) -make -make install -run_tests kprobe - -sed -i -e 's/-DEXPERIMENTAL_KPROBE_SDT//' src/Makefile.global -(cd src/backend/utils/ - make clean) -make -make install -run_tests uprobe -" -########## End /tmp/stap-postgres.sh ########## -close $fp - -########## /tmp/stap-postgres.sh does most of the work ########## -verbose -log Running postgres testsuite -spawn sh $pgdata.sh 2>&1 -expect { - -timeout 1000 - -re {FAIL: [a-z_ ]+} { regexp " .*$" $expect_out(0,string) s; - fail "$s"; exp_continue } - -re {PASS: [a-z_ ]+} { regexp " .*$" $expect_out(0,string) s; - pass "$s"; exp_continue } - -re {UNSUPPORTED: [a-zA-Z_/: ]+} { regexp " .*$" $expect_out(0,string) s; - verbose -log "$s" - unsupported "$s"; exp_continue } - timeout { fail "$test (timeout)" } - eof { } -} - -if { $verbose == 0 } { -catch {exec rm -rf $pgdata} -catch {exec rm -rf $pgdata.stp $pgdata.log \ - $pgdata-markers.log $pgdata.sh postgresql-8.3.6.tar.bz2} -catch {exec rm -rf postgresql-8.3.6} -} diff --git a/testsuite/systemtap.base/pr10854.exp b/testsuite/systemtap.base/pr10854.exp new file mode 100644 index 00000000..9173c8b4 --- /dev/null +++ b/testsuite/systemtap.base/pr10854.exp @@ -0,0 +1,32 @@ +# This test is to make sure that we've resolved PR10854's race between probe +# initialization and shutdown. Here we load a module and then kill the stapio +# process as soon as we can to try to make the init and shutdown overlap. + +set test "pr10854" + +# precompile the script module +set compile { exec stap $srcdir/$subdir/$test.stp sys_read *@fs/*.c -p4 } +if { [catch { set module [eval $compile] } msg ] } { + fail "compiling $test.stp: $msg" + untested "$test runloop" + continue +} else { + pass "compiling $test.stp" +} + +if {![installtest_p]} { + untested "$test runloop" + continue +} + +# run & kill the module 10 times +# (this was usually enough to trigger the fault) +for {set i 0} {$i < 10} {incr i} { + spawn staprun $module -o /dev/null + while { [catch { exec pkill stapio -P [pid] } msg ] } { } + catch { close } + wait +} + +# if we're still alive, we pass :) +pass "$test runloop" diff --git a/testsuite/systemtap.base/pr10854.stp b/testsuite/systemtap.base/pr10854.stp new file mode 100644 index 00000000..55f027f2 --- /dev/null +++ b/testsuite/systemtap.base/pr10854.stp @@ -0,0 +1,20 @@ +function trace(entry_p) { + if(tid() in trace) + printf("%s%s%s\n",thread_indent(entry_p), + (entry_p>0?"->":"<-"), + probefunc()) +} + +global trace +probe kernel.function(@1).call { + if (execname() == "staprun") next # skip our own helper process + trace[tid()] = 1 + trace(1) +} +probe kernel.function(@1).return { + trace(-1) + delete trace[tid()] +} + +probe kernel.function(@2).call { trace(1) } +probe kernel.function(@2).return { trace(-1) } |