From 14b31996a7752ab19f1b9017c65742c866394c1e Mon Sep 17 00:00:00 2001 From: wcohen Date: Mon, 7 Jan 2008 21:12:53 +0000 Subject: 2008-01-07 William Cohen * testsuite/lib/systemtap.exp (as_root): new proc. * testsuite/systemtap.context/context.exp: * testsuite/systemtap.printf/end1b.exp: * testsuite/systemtap.printf/mixed_outb.exp: * testsuite/systemtap.printf/out1b.exp: * testsuite/systemtap.printf/out2b.exp: * testsuite/systemtap.printf/out3b.exp: Use as_root proc. --- testsuite/lib/systemtap.exp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'testsuite/lib') 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 + } -- cgit