Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tools: tc-testing: rootPlugin

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>

authored by

Brenda J. Butler and committed by
David S. Miller
f6926e85 93707cba

+19 -4
+19
tools/testing/selftests/tc-testing/plugin-lib/rootPlugin.py
··· 1 + import os 2 + import sys 3 + from TdcPlugin import TdcPlugin 4 + 5 + from tdc_config import * 6 + 7 + 8 + class SubPlugin(TdcPlugin): 9 + def __init__(self): 10 + self.sub_class = 'root/SubPlugin' 11 + super().__init__() 12 + 13 + def pre_suite(self, testcount, testidlist): 14 + # run commands before test_runner goes into a test loop 15 + super().pre_suite(testcount, testidlist) 16 + 17 + if os.geteuid(): 18 + print('This script must be run with root privileges', file=sys.stderr) 19 + exit(1)
-4
tools/testing/selftests/tc-testing/tdc.py
··· 579 579 list_test_cases(alltests) 580 580 exit(0) 581 581 582 - if (os.geteuid() != 0): 583 - print("This script must be run with root privileges.\n") 584 - exit(1) 585 - 586 582 ns_create(args, pm) 587 583 588 584 if len(alltests):