summaryrefslogtreecommitdiffstats
path: root/testsuite
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/lib/systemtap.exp11
-rw-r--r--testsuite/systemtap.context/context.exp9
-rw-r--r--testsuite/systemtap.printf/end1b.exp8
-rw-r--r--testsuite/systemtap.printf/mixed_outb.exp8
-rw-r--r--testsuite/systemtap.printf/out1b.exp8
-rw-r--r--testsuite/systemtap.printf/out2b.exp8
-rw-r--r--testsuite/systemtap.printf/out3b.exp8
7 files changed, 36 insertions, 24 deletions
diff --git a/testsuite/lib/systemtap.exp b/testsuite/lib/systemtap.exp
index 7fb1e317..3b66b05a 100644
--- a/testsuite/lib/systemtap.exp
+++ b/testsuite/lib/systemtap.exp
@@ -111,3 +111,14 @@ proc stap_run_batch {args} {
return [lindex $results 3]
}
}
+
+proc as_root { command } {
+
+ set effective_pid [exec /usr/bin/id -u]
+
+ if {$effective_pid != 0} {
+ set command "sudo $command"
+ }
+ set res [catch {eval exec $command} value]
+ return $res
+ }
diff --git a/testsuite/systemtap.context/context.exp b/testsuite/systemtap.context/context.exp
index 3b4a0328..bc5f8ebe 100644
--- a/testsuite/systemtap.context/context.exp
+++ b/testsuite/systemtap.context/context.exp
@@ -13,8 +13,8 @@ proc cleanup {} {
global build_dir
catch {send "\003"}
foreach n {1 2} {
- catch {exec sudo /bin/rm -f /lib/modules/$::uname/kernel/systemtap_test_module$n.ko}
- catch {exec sudo /sbin/rmmod systemtap_test_module$n}
+ as_root [list /bin/rm -f /lib/modules/$::uname/kernel/systemtap_test_module$n.ko]
+ as_root [list /sbin/rmmod systemtap_test_module$n]
}
if {$build_dir != ""} {exec rm -rf $build_dir}
}
@@ -46,14 +46,15 @@ proc build_modules {} {
cd $old_dir
return 0
}
- if {[catch {exec sudo cp systemtap_test_module$n.ko /lib/modules/$::uname/kernel} res]} {
+ set res [as_root [list cp systemtap_test_module$n.ko /lib/modules/$::uname/kernel]]
+ if { $res != 0 } {
puts $res
cd $old_dir
return 0
}
}
foreach n {2 1} {
- catch {exec sudo /sbin/insmod systemtap_test_module$n.ko}
+ as_root [list /sbin/insmod systemtap_test_module$n.ko]
}
cd $old_dir
return 1
diff --git a/testsuite/systemtap.printf/end1b.exp b/testsuite/systemtap.printf/end1b.exp
index b1b75c52..6168f66e 100644
--- a/testsuite/systemtap.printf/end1b.exp
+++ b/testsuite/systemtap.printf/end1b.exp
@@ -24,24 +24,24 @@ if {[catch {exec mktemp -t staptestXXXXX} tmpfile]} {
if {[catch {exec stap -b -o $tmpfile $test} res]} {
untested $TEST_NAME
puts "stap failed: $res"
- catch {eval [list exec sudo /bin/rm -f] [glob ${tmpfile}*]}
+ as_root {/bin/rm -f [glob ${tmpfile}*]}
return
}
if {[catch {eval [list exec $stap_merge_path -o $tmpfile] [glob "${tmpfile}_*"]} res]} {
puts "merge failed: $res"
fail "$TEST_NAME failed"
- catch {eval [list exec sudo /bin/rm -f] [glob ${tmpfile}*]}
+ as_root {/bin/rm -f [glob ${tmpfile}*]}
return
}
if {[catch {exec cmp $tmpfile $srcdir/$subdir/large_output} res]} {
puts "$res"
fail "$TEST_NAME failed"
- catch {eval [list exec sudo /bin/rm -f] [glob ${tmpfile}*]}
+ as_root {/bin/rm -f [glob ${tmpfile}*]}
return
}
pass "$TEST_NAME passed"
-catch {eval [list exec sudo /bin/rm -f] [glob ${tmpfile}*]}
+as_root {/bin/rm -f [glob ${tmpfile}*]}
diff --git a/testsuite/systemtap.printf/mixed_outb.exp b/testsuite/systemtap.printf/mixed_outb.exp
index 9d1be4c6..6d352dd4 100644
--- a/testsuite/systemtap.printf/mixed_outb.exp
+++ b/testsuite/systemtap.printf/mixed_outb.exp
@@ -24,24 +24,24 @@ if {[catch {exec mktemp -t staptestXXXXX} tmpfile]} {
if {[catch {exec stap -DMAXACTION=100000 -b -o $tmpfile $test} res]} {
untested $TEST_NAME
puts "stap failed: $res"
- catch {eval [list exec sudo /bin/rm -f] [glob ${tmpfile}*]}
+ as_root {/bin/rm -f [glob ${tmpfile}*]}
return
}
if {[catch {eval [list exec $stap_merge_path -o $tmpfile] [glob "${tmpfile}_*"]} res]} {
puts "merge failed: $res"
fail "$TEST_NAME failed"
- catch {eval [list exec sudo /bin/rm -f] [glob ${tmpfile}*]}
+ as_root {/bin/rm -f [glob ${tmpfile}*]}
return
}
if {[catch {exec cmp $tmpfile $srcdir/$subdir/large_output} res]} {
puts "$res"
fail "$TEST_NAME failed"
- catch {eval [list exec sudo /bin/rm -f] [glob ${tmpfile}*]}
+ as_root {/bin/rm -f [glob ${tmpfile}*]}
return
}
pass "$TEST_NAME passed"
-catch {eval [list exec sudo /bin/rm -f] [glob ${tmpfile}*]}
+as_root {/bin/rm -f [glob ${tmpfile}*]}
diff --git a/testsuite/systemtap.printf/out1b.exp b/testsuite/systemtap.printf/out1b.exp
index 0242dee6..723238c5 100644
--- a/testsuite/systemtap.printf/out1b.exp
+++ b/testsuite/systemtap.printf/out1b.exp
@@ -24,24 +24,24 @@ if {[catch {exec mktemp -t staptestXXXXX} tmpfile]} {
if {[catch {exec stap -b -o $tmpfile $test} res]} {
untested $TEST_NAME
puts "stap failed: $res"
- catch {eval [list exec sudo /bin/rm -f] [glob ${tmpfile}*]}
+ as_root {/bin/rm -f [glob ${tmpfile}*]}
return
}
if {[catch {eval [list exec $stap_merge_path -o $tmpfile] [glob "${tmpfile}_*"]} res]} {
puts "merge failed: $res"
fail "$TEST_NAME failed"
- catch {eval [list exec sudo /bin/rm -f] [glob ${tmpfile}*]}
+ as_root {/bin/rm -f [glob ${tmpfile}*]}
return
}
if {[catch {exec cmp $tmpfile $srcdir/$subdir/large_output} res]} {
puts "$res"
fail "$TEST_NAME failed"
- catch {eval [list exec sudo /bin/rm -f] [glob ${tmpfile}*]}
+ as_root {/bin/rm -f [glob ${tmpfile}*]}
return
}
pass "$TEST_NAME passed"
-catch {eval [list exec sudo /bin/rm -f] [glob ${tmpfile}*]}
+as_root {/bin/rm -f [glob ${tmpfile}*]}
diff --git a/testsuite/systemtap.printf/out2b.exp b/testsuite/systemtap.printf/out2b.exp
index be050854..085cfa14 100644
--- a/testsuite/systemtap.printf/out2b.exp
+++ b/testsuite/systemtap.printf/out2b.exp
@@ -24,24 +24,24 @@ if {[catch {exec mktemp -t staptestXXXXX} tmpfile]} {
if {[catch {exec stap -b -o $tmpfile $test} res]} {
untested $TEST_NAME
puts "stap failed: $res"
- catch {eval [list exec sudo /bin/rm -f] [glob ${tmpfile}*]}
+ as_root {/bin/rm -f [glob ${tmpfile}*]}
return
}
if {[catch {eval [list exec $stap_merge_path -o $tmpfile] [glob "${tmpfile}_*"]} res]} {
puts "merge failed: $res"
fail "$TEST_NAME failed"
- catch {eval [list exec sudo /bin/rm -f] [glob ${tmpfile}*]}
+ as_root {/bin/rm -f [glob ${tmpfile}*]}
return
}
if {[catch {exec cmp $tmpfile $srcdir/$subdir/large_output} res]} {
puts "$res"
fail "$TEST_NAME failed"
- catch {eval [list exec sudo /bin/rm -f] [glob ${tmpfile}*]}
+ as_root {/bin/rm -f [glob ${tmpfile}*]}
return
}
pass "$TEST_NAME passed"
-catch {eval [list exec sudo /bin/rm -f] [glob ${tmpfile}*]}
+as_root {/bin/rm -f [glob ${tmpfile}*]}
diff --git a/testsuite/systemtap.printf/out3b.exp b/testsuite/systemtap.printf/out3b.exp
index 2d2b3d0b..395363fc 100644
--- a/testsuite/systemtap.printf/out3b.exp
+++ b/testsuite/systemtap.printf/out3b.exp
@@ -24,24 +24,24 @@ if {[catch {exec mktemp -t staptestXXXXX} tmpfile]} {
if {[catch {exec stap -DMAXACTION=100000 -b -o $tmpfile $test} res]} {
untested $TEST_NAME
puts "stap failed: $res"
- catch {eval [list exec sudo /bin/rm -f] [glob ${tmpfile}*]}
+ as_root {/bin/rm -f [glob ${tmpfile}*]}
return
}
if {[catch {eval [list exec $stap_merge_path -o $tmpfile] [glob "${tmpfile}_*"]} res]} {
puts "merge failed: $res"
fail "$TEST_NAME failed"
- catch {eval [list exec sudo /bin/rm -f] [glob ${tmpfile}*]}
+ as_root {/bin/rm -f [glob ${tmpfile}*]}
return
}
if {[catch {exec cmp $tmpfile $srcdir/$subdir/large_output} res]} {
puts "$res"
fail "$TEST_NAME failed"
- catch {eval [list exec sudo /bin/rm -f] [glob ${tmpfile}*]}
+ as_root {/bin/rm -f [glob ${tmpfile}*]}
return
}
pass "$TEST_NAME passed"
-catch {eval [list exec sudo /bin/rm -f] [glob ${tmpfile}*]}
+as_root {/bin/rm -f [glob ${tmpfile}*]}