From f249edcd5f135278e15ccafb497be520c325a5e4 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Wed, 5 Aug 2009 16:55:24 -0700 Subject: [PATCH] Don't spawn uprobes tests with sudo Using spawn with sudo doesn't work well, because the password prompt won't go to the correct TTY. The only reason that the uprobes tests needed to do this is so uprobes.ko could be built as root. Now instead, I've added a pre-check that will directly call the uprobes make with sudo (via the as_root proc). * testsuite/lib/systemtap.exp (uprobes_p): Check and build uprobes.ko. * testsuite/systemtap.base/uprobes.exp: Use uprobes_p; don't spawn sudo. * testsuite/systemtap.base/bz6850.exp: Ditto. * testsuite/systemtap.base/bz10078.exp: Ditto. * testsuite/systemtap.base/bz6905.exp: sudo isn't needed for -p2. --- testsuite/lib/systemtap.exp | 23 +++++++++++++++++++++++ testsuite/systemtap.base/bz10078.exp | 6 ++---- testsuite/systemtap.base/bz6850.exp | 6 ++---- testsuite/systemtap.base/bz6905.exp | 3 +-- testsuite/systemtap.base/uprobes.exp | 6 ++---- 5 files changed, 30 insertions(+), 14 deletions(-) diff --git a/testsuite/lib/systemtap.exp b/testsuite/lib/systemtap.exp index 76fd57bd2..82afb6b7b 100644 --- a/testsuite/lib/systemtap.exp +++ b/testsuite/lib/systemtap.exp @@ -26,6 +26,29 @@ proc utrace_p {} { } +proc uprobes_p {} { + global env + if {! [utrace_p]} { + return 0 + } + set uprobes $env(SYSTEMTAP_RUNTIME)/uprobes + set res [catch "exec make -q -C $uprobes uprobes.ko" output] + if {$res != 0} { + if {! [installtest_p]} { + # build as user in the source tree + verbose -log "exec make -C $uprobes" + set res [catch "exec make -C $uprobes" output] + verbose -log "OUT $output" + verbose -log "RC $res" + } else { + # build as root in the installed location + set res [as_root "make -C $uprobes"] + } + } + if {$res == 0} { return 1 } else { return 0 } +} + + proc print_systemtap_version {} { set version [exec /bin/uname -r] set location "/boot/vmlinux-$version" diff --git a/testsuite/systemtap.base/bz10078.exp b/testsuite/systemtap.base/bz10078.exp index cad3a3a87..8928a078f 100644 --- a/testsuite/systemtap.base/bz10078.exp +++ b/testsuite/systemtap.base/bz10078.exp @@ -3,7 +3,7 @@ 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]} { +if {![uprobes_p]} { catch {exec rm -f $test} untested "$test -p4" untested "$test -p5" @@ -19,9 +19,7 @@ if {! [installtest_p]} { return } -# Pick up the stap being tested. -set stapexe [exec /usr/bin/which stap] -spawn sudo $stapexe $srcdir/$subdir/$test.stp -c ./$test +spawn stap $srcdir/$subdir/$test.stp -c ./$test set ok 0 expect { -timeout 60 diff --git a/testsuite/systemtap.base/bz6850.exp b/testsuite/systemtap.base/bz6850.exp index 32ecdaf5f..1b88ac108 100644 --- a/testsuite/systemtap.base/bz6850.exp +++ b/testsuite/systemtap.base/bz6850.exp @@ -3,7 +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" } -if {![utrace_p]} { +if {![uprobes_p]} { catch {exec rm -f $test} untested "$test -p4" untested "$test -p5" @@ -19,9 +19,7 @@ if {! [installtest_p]} { return } -# Pick up the stap being tested. -set stapexe [exec /usr/bin/which stap] -spawn sudo $stapexe $srcdir/$subdir/bz6850.stp -c ./bz6850 +spawn stap $srcdir/$subdir/bz6850.stp -c ./bz6850 expect { -timeout 60 -re {[^\r\n]*called\r\n} { exp_continue } diff --git a/testsuite/systemtap.base/bz6905.exp b/testsuite/systemtap.base/bz6905.exp index 8119159e8..20a846cca 100644 --- a/testsuite/systemtap.base/bz6905.exp +++ b/testsuite/systemtap.base/bz6905.exp @@ -9,8 +9,7 @@ if {![utrace_p]} { return } -set stapexe [exec /usr/bin/which stap] -spawn sudo $stapexe -p2 $srcdir/$subdir/$test.stp +spawn stap -p2 $srcdir/$subdir/$test.stp set hint 0 set probes 0 expect { diff --git a/testsuite/systemtap.base/uprobes.exp b/testsuite/systemtap.base/uprobes.exp index 6344cbf0a..bdd620b3e 100644 --- a/testsuite/systemtap.base/uprobes.exp +++ b/testsuite/systemtap.base/uprobes.exp @@ -18,7 +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" } -if {![utrace_p]} { +if {! [uprobes_p]} { untested "$test -p4"; untested "$test -p5" catch {exec rm -f jennie.c jennie} return @@ -33,9 +33,7 @@ if {! [installtest_p]} { return } -# Pick up the stap being tested. -set stapexe [exec /usr/bin/which stap] -spawn sudo $stapexe $srcdir/$subdir/uprobes.stp -w -c "./jennie 1 2 3 4" +spawn stap $srcdir/$subdir/uprobes.stp -w -c "./jennie 1 2 3 4" set ok 0 expect { -re {^process[^\r\n]*jennie[^\r\n]*main[^\r\n]*argc=0x[1-5][^\r\n]*\r\n} { incr ok; exp_continue } -- 2.43.5