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

Daniel Vetter daniel at ffwll.ch
Tue Feb 12 14:14:46 UTC 2019


On Tue, Feb 12, 2019 at 03:53:17PM +0200, Arkadiusz Hiler via igt-dev wrote:
> `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."

Reviewed-by: Daniel Vetter <daniel.vetter at ffwll.ch>

> +fi
> +
>  TESTLISTFILE="$tests_dir/test-list.txt"
>  if [ ! -r "$TESTLISTFILE" ]; then
>  	tests_dir="tests"
> -- 
> 2.20.1
> 
> _______________________________________________
> igt-dev mailing list
> igt-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/igt-dev

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


More information about the igt-dev mailing list