Message ID | 20201020235126.1871815-12-fenghua.yu@intel.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | Miscellaneous fixes for resctrl selftests | expand |
diff --git a/tools/testing/selftests/resctrl/resctrl_tests.c b/tools/testing/selftests/resctrl/resctrl_tests.c index cab69ed8c67d..f4867a81eee6 100644 --- a/tools/testing/selftests/resctrl/resctrl_tests.c +++ b/tools/testing/selftests/resctrl/resctrl_tests.c @@ -125,8 +125,10 @@ int main(int argc, char **argv) * 1. We write to resctrl FS * 2. We execute perf commands */ - if (geteuid() != 0) - printf("# WARNING: not running as root, tests may fail.\n"); + if (geteuid() != 0) { + printf("Bail out! not running as root, abort testing\n"); + goto out; + } /* Detect AMD vendor */ detect_amd();
Running any resctrl unit test involves writing to resctrl file system and only a root user has permission to write to resctrl FS. Resctrl test suite before running any test checks for the privilege of the user and if it's not a root user, the test suite prints a warning and continues attempting to run tests. Attempting to run any test without root privileges will fail as below TAP version 13 ok kernel supports resctrl filesystem ................. not ok mounting resctrl to "/sys/fs/resctrl" not ok MBA: schemata change Hence, don't attempt to run any test if the user is not a root user and change the warning message to a bail out message to comply with TAP 13 standards. Fixes: ecdbb911f22d ("selftests/resctrl: Add MBM test") Signed-off-by: Fenghua Yu <fenghua.yu@intel.com> --- tools/testing/selftests/resctrl/resctrl_tests.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)