]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
tools: tc-testing: rootPlugin
authorBrenda J. Butler <bjb@mojatatu.com>
Wed, 14 Feb 2018 19:09:22 +0000 (14:09 -0500)
committerDavid S. Miller <davem@davemloft.net>
Thu, 15 Feb 2018 20:38:33 +0000 (15:38 -0500)
Move the functionality that checks for root permissions into a plugin.

Signed-off-by: Brenda J. Butler <bjb@mojatatu.com>
Acked-by: Lucas Bates <lucasb@mojatatu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
tools/testing/selftests/tc-testing/plugin-lib/rootPlugin.py [new file with mode: 0644]
tools/testing/selftests/tc-testing/tdc.py

diff --git a/tools/testing/selftests/tc-testing/plugin-lib/rootPlugin.py b/tools/testing/selftests/tc-testing/plugin-lib/rootPlugin.py
new file mode 100644 (file)
index 0000000..e36775b
--- /dev/null
@@ -0,0 +1,19 @@
+import os
+import sys
+from TdcPlugin import TdcPlugin
+
+from tdc_config import *
+
+
+class SubPlugin(TdcPlugin):
+    def __init__(self):
+        self.sub_class = 'root/SubPlugin'
+        super().__init__()
+
+    def pre_suite(self, testcount, testidlist):
+        # run commands before test_runner goes into a test loop
+        super().pre_suite(testcount, testidlist)
+
+        if os.geteuid():
+            print('This script must be run with root privileges', file=sys.stderr)
+            exit(1)
index 3e6f9f2e1691801c575525a56d3ef1382573f426..a718d2b577397a32546c16c2a679ac0268130db1 100755 (executable)
@@ -579,10 +579,6 @@ def set_operation_mode(pm, args):
             list_test_cases(alltests)
             exit(0)
 
-    if (os.geteuid() != 0):
-        print("This script must be run with root privileges.\n")
-        exit(1)
-
     ns_create(args, pm)
 
     if len(alltests):