[igt-dev] [PATCH i-g-t] igt_command_line.sh: Abort if run as root

Arkadiusz Hiler arkadiusz.hiler at intel.com
Tue Feb 12 13:53:17 UTC 2019


`ninja test` invokes igt_command_line.sh for each test binary to check
the behavior of some of the switches. One of the verified things is that
the test exists with non-zero status when requesting invalid subtest.

`--run-subtest` results in igt_fixtures being executed - this fiddles
with the device and sysfs knobs.

Let's exit early, if we are root, to save people form unintentional
side-effects and strange failures.

Cc: Petri Latvala <petri.latvala at intel.com>
Cc: Andi Shyti <andi.shyti at intel.com>
Signed-off-by: Arkadiusz Hiler <arkadiusz.hiler at intel.com>
---
 tests/igt_command_line.sh | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tests/igt_command_line.sh b/tests/igt_command_line.sh
index e05ec34c..408d965f 100755
--- a/tests/igt_command_line.sh
+++ b/tests/igt_command_line.sh
@@ -100,6 +100,10 @@ check_test ()
 	./$test --run-subtest invalid-subtest > /dev/null 2>&1 && fail $test
 }
 
+if [ "$EUID" -eq 0 ]; then
+    fail "Don't run $0 as root. It executes igt_fixture blocks."
+fi
+
 TESTLISTFILE="$tests_dir/test-list.txt"
 if [ ! -r "$TESTLISTFILE" ]; then
 	tests_dir="tests"
-- 
2.20.1



More information about the igt-dev mailing list