summaryrefslogtreecommitdiffstats
path: root/testsuite/lib/systemtap.exp
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/lib/systemtap.exp')
-rw-r--r--testsuite/lib/systemtap.exp11
1 files changed, 11 insertions, 0 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
+ }