diff options
author | Stan Cox <scox@redhat.com> | 2009-08-27 14:47:08 -0400 |
---|---|---|
committer | Stan Cox <scox@redhat.com> | 2009-08-27 14:47:08 -0400 |
commit | ef2082d8c887bdc14b2900882491555d3b87ce1c (patch) | |
tree | 5c06ca94052628be2c2b2ce7809d916696a18dcf | |
parent | 8096dd7dbc7bc5712da58a6f9bcb90c0b74c10db (diff) | |
download | systemtap-steved-ef2082d8c887bdc14b2900882491555d3b87ce1c.tar.gz systemtap-steved-ef2082d8c887bdc14b2900882491555d3b87ce1c.tar.xz systemtap-steved-ef2082d8c887bdc14b2900882491555d3b87ce1c.zip |
Teach postgres.exp to use a locally built version of postgres.
* postgres.exp: Grab postgres from upstream then build and test it
with uprobe, utrace, and kprobe.
-rw-r--r-- | testsuite/systemtap.base/postgres.exp | 154 |
1 files changed, 92 insertions, 62 deletions
diff --git a/testsuite/systemtap.base/postgres.exp b/testsuite/systemtap.base/postgres.exp index 0c53d86b..11a9288f 100644 --- a/testsuite/systemtap.base/postgres.exp +++ b/testsuite/systemtap.base/postgres.exp @@ -1,125 +1,152 @@ set test "postgres" -# Test sdt support in postgres. Assumes a markered postgres is installed. +# Test sdt support in postgres. + +global env + +if {! [info exists env(SYSTEMTAP_TEST_SDT)]} { + unsupported "postgres (\"SYSTEMTAP_TEST_SDT\" not in env)" + exit +} ########## Create /tmp/stap-postgres.stp ########## -set dpath "/tmp/stap-postgres.stp" -set fp [open $dpath "w"] +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(\"/usr/local/pgsql/bin/postgres\").mark(\"transaction__start\") +probe process(\"$postgresdir/bin/postgres\").mark(\"transaction__start\") { printf(\"%s %#x\\n\", \$\$name, \$arg1); } -probe process(\"/usr/local/pgsql/bin/postgres\").mark(\"transaction__commit\") +probe process(\"$postgresdir/bin/postgres\").mark(\"transaction__commit\") { printf(\"%s %#x\\n\", \$\$name, \$arg1); } -probe process(\"/usr/local/pgsql/bin/postgres\").mark(\"transaction__abort\") +probe process(\"$postgresdir/bin/postgres\").mark(\"transaction__abort\") { printf(\"%s %#x\\n\", \$\$name, \$arg1); } -probe process(\"/usr/local/pgsql/bin/postgres\").mark(\"lock__startwait\") +probe process(\"$postgresdir/bin/postgres\").mark(\"lock__startwait\") { printf(\"%s %#x %#x\\n\", \$\$name, \$arg1, \$arg2); } -probe process(\"/usr/local/pgsql/bin/postgres\").mark(\"lock__endwait\") +probe process(\"$postgresdir/bin/postgres\").mark(\"lock__endwait\") { printf(\"%s %#x %#x\\n\", \$\$name, \$arg1, \$arg2); } -probe process(\"/usr/local/pgsql/bin/postgres\").mark(\"lwlock__endwait\") +probe process(\"$postgresdir/bin/postgres\").mark(\"lwlock__endwait\") { printf(\"%s %#x %#x\\n\", \$\$name, \$arg1, \$arg2); } -probe process(\"/usr/local/pgsql/bin/postgres\").mark(\"lwlock__acquire\") +probe process(\"$postgresdir/bin/postgres\").mark(\"lwlock__acquire\") { printf(\"%s %#x %#x\\n\", \$\$name, \$arg1, \$arg2); } -probe process(\"/usr/local/pgsql/bin/postgres\").mark(\"lwlock__condacquire__fail\") +probe process(\"$postgresdir/bin/postgres\").mark(\"lwlock__condacquire__fail\") { printf(\"%s %#x %#x\\n\", \$\$name, \$arg1, \$arg2); } -probe process(\"/usr/local/pgsql/bin/postgres\").mark(\"lwlock__condacquire\") +probe process(\"$postgresdir/bin/postgres\").mark(\"lwlock__condacquire\") { printf(\"%s %#x %#x\\n\", \$\$name, \$arg1, \$arg2); } -probe process(\"/usr/local/pgsql/bin/postgres\").mark(\"lwlock__release\") +probe process(\"$postgresdir/bin/postgres\").mark(\"lwlock__release\") { printf(\"%s %#x\\n\", \$\$name, \$arg1); } " close $fp -########## Create /tmp/stap-postgres.sh ########## -set dpath "/tmp/stap-postgres.sh" -set fp [open $dpath "w"] +########## Begin /tmp/stap-postgres.sh ########## +set fp [open "$pgdata.sh" "w"] puts $fp " -if locate pg_regress_main.o ; then - POSTGRESBUILD=\$(dirname \$(locate pg_regress_main.o)) -else - echo UNSUPPORTED: Directory does not exist: postgres-build-dir/src/test/regress - exit -fi -if \[ -d /usr/local/pgsql \] ; then - POSTGRESDIR=/usr/local/pgsql/bin -else - echo UNSUPPORTED: Directory does not exist /usr/local/pgsql - exit -fi -\$POSTGRESDIR/initdb /tmp/stap-postgres +function run_tests \{ +/bin/rm -rf $pgdata +$postgresdir/bin/initdb $pgdata -if \[ \$(objdump -h \$POSTGRESDIR/postgres | grep probes | wc -l) -eq 0 \] ; then - echo UNSUPPORTED: \$POSTGRESDIR/postgres does not contain probes - exit -fi -PGDATA=/tmp/stap-postgres/ stap -c \"\$POSTGRESDIR/postgres -D /tmp/stap-postgres\" /tmp/stap-postgres.stp >/tmp/stap-postgres-markers.log 2>&1 & +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 -I=0 -while \[ \$I -ne 10 \] ; do - if expr \$(ps --no-headers -C postgres | wc -l) > 0 - then - I=10 - else - sleep 5 - I=\$\[\$I+1\] +for i in \$(seq 0 10) ; do + if pg_ctl status -D $pgdata + then break; fi - done + sleep 5 +done -cd \$POSTGRESBUILD/ -make installcheck > /tmp/stap-postgres.log 2>&1 +(cd $postgresbuild/src/test/regress/ + make installcheck > $pgdata.log 2>&1) -ACQUIRE=\$(grep 'lwlock__acquire 0x\[0-9\]* 0x\[0-9\]*' /tmp/stap-postgres-markers.log | wc -l) -RELEASE=\$(grep 'lwlock__release 0x\[0-9\]*' /tmp/stap-postgres-markers.log | wc -l) -START=\$(grep 'transaction__start 0x\[0-9\]*' /tmp/stap-postgres-markers.log | wc -l) -COMMIT=\$(grep 'transaction__commit 0x\[0-9\]*' /tmp/stap-postgres-markers.log | wc -l) -OKAY=\$(grep 'test .*ok' /tmp/stap-postgres.log | wc -l) +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 44000 -a \$RELEASE -gt 75000 -a \$START -gt 580 -a \$COMMIT -gt 480 \] ; then - echo PASS: postgres markers +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 markers + echo FAIL: postgres tests \$1 fi if \[ \$OKAY -gt 100 \] ; then - echo PASS: postgres tests + echo PASS: postgres markers \$1 else - echo FAIL: postgres tests + 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 -kill \$(ps --no-headers -C postgres | head -1 | awk '{print \$1}') +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 /tmp/stap-postgres.sh 2>&1 +spawn sh $pgdata.sh 2>&1 expect { - -timeout 180 + -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; @@ -127,10 +154,13 @@ expect { -re {UNSUPPORTED: [a-zA-Z_/: ]+} { regexp " .*$" $expect_out(0,string) s; verbose -log "$s" unsupported "$s"; exp_continue } - timeout { fail "$test (timeout) } + timeout { fail "$test (timeout)" } eof { } } -catch {exec rm -rf /tmp/stap-postgres} -catch {exec rm /tmp/stap-postgres.stp /tmp/stap-postgres.log \ - /tmp/stap-postgres-markers.log /tmp/stap-postgres.sh} +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} +} |