[oprofile-testsuite PATCH 3/7] swizzle user==root requirements for tests

Will Schmidt <[email protected]>
Newsgroups gmane.linux.oprofile
Message-ID <[email protected]>
Now that perf events is the interface used underneath oprofile, root
authority is no longer required to retrieve kernel symbol info (via kallsyms).
This swizzles some of the user==root controls around the tests, moving the
check to just around the system-wide tests, which still require root.
Overall, this allows many more tests to run as a non-root user.

Signed-off-by: Will Schmidt <[email protected]>
---
 testsuite/oprofile-operf/oprofile-operf-run.exp |   25 ++++++++++++-----------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/testsuite/oprofile-operf/oprofile-operf-run.exp b/testsuite/oprofile-operf/oprofile-operf-run.exp
index 51aa2dc..a6496be 100644
--- a/testsuite/oprofile-operf/oprofile-operf-run.exp
+++ b/testsuite/oprofile-operf/oprofile-operf-run.exp
@@ -134,22 +134,18 @@ if {$op_version == 0} {
     set opcontrol_installed 0
 } else {
     if {$op_version < $operf_version} {
-	# Don't run the opcontrol tests if it is an earlier version
+        # Don't run the opcontrol tests at all if the opcontrol binary appears to
+        # be from an earlier version of OProfile.
         set opcontrol_installed 0
     } else {
         set opcontrol_installed 1
     }
 }
 
-check_user
-if {$user_is_root == 0} {
-    send "\nYou must be root to run the operf --system-wide command.\n"
-    send "Will not run operf tests.\n"
+if { $operf_version == 0 } {
+    send "Skipping the operf tests.\n"
+    send "Unable to find or verify the version of the OProfile operf utility.\n"
 } else {
-
-    if { $operf_version == 0 } {
-	send "\nThe OProfile operf user tool is not supported.  Will not run operf tests.\n"
-    } else {
 	# Ensure that the oprofile kernel module is unloaded, since it can
 	# interfere with proper operf operation on some platforms.
 	if {$opcontrol_installed == 1} {
@@ -162,8 +158,14 @@ if {$user_is_root == 0} {
         # around that opreport might inadvertenly pick up.
 	operf_delete_samples
 
-        send "Running the operf system-wide tests\n"
-	oprofile-operf_run_system_wide_tests
+       check_user
+        if {$user_is_root == 0} {
+            send "Skipping the operf system-wide tests.\n"
+            send "  You must be root to run operf with the --system-wide parameter.\n\n"
+        } else {
+            send "Running the operf system-wide tests.\n"
+            oprofile-operf_run_system_wide_tests
+        }
         send "Running the operf callgraph tests\n"
 	oprofile-callgraph_run_tests
 
@@ -177,5 +179,4 @@ if {$user_is_root == 0} {
 		oprofile-kallsyms-readable_run_tests
 	    }
 	}
-    }
 }


------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785471&iu=/4140
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.