diff options
Diffstat (limited to 'testsuite/systemtap.apps/postgres.exp')
-rw-r--r-- | testsuite/systemtap.apps/postgres.exp | 166 |
1 files changed, 166 insertions, 0 deletions
diff --git a/testsuite/systemtap.apps/postgres.exp b/testsuite/systemtap.apps/postgres.exp new file mode 100644 index 00000000..2d58a54f --- /dev/null +++ b/testsuite/systemtap.apps/postgres.exp @@ -0,0 +1,166 @@ +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 +$env(SYSTEMTAP_PATH)/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} +} |