From: Laszlo Gombos Date: Tue, 21 Feb 2023 00:20:29 +0000 Subject: fix(test): running tests no longer requires to be root Origin: upstream, https://github.com/dracutdevs/dracut/pull/2429 --- Makefile | 1 - docs/HACKING.md | 10 +++++----- test/Makefile | 1 - test/test-functions | 12 ------------ 4 files changed, 5 insertions(+), 19 deletions(-) diff --git a/Makefile b/Makefile index 333cd68..10a8e63 100644 --- a/Makefile +++ b/Makefile @@ -264,7 +264,6 @@ endif endif check: all syncheck - @[ "$$EUID" == "0" ] || { echo "'check' must be run as root! Please use 'sudo'."; exit 1; } @$(MAKE) -C test check testimage: all diff --git a/docs/HACKING.md b/docs/HACKING.md index 6a19434..2e3d614 100644 --- a/docs/HACKING.md +++ b/docs/HACKING.md @@ -253,27 +253,27 @@ For the testsuite to pass, you will have to install at least the software packag mentioned in the `test/container` Dockerfiles. ``` -$ sudo make clean check +$ make clean check ``` in verbose mode: ``` -$ sudo make V=1 clean check +$ make V=1 clean check ``` only specific test: ``` -$ sudo make TESTS="01 20 40" clean check +$ make TESTS="01 20 40" clean check ``` only runs the 01, 20 and 40 tests. debug a specific test case: ``` $ cd TEST-01-BASIC -$ sudo make clean setup run +$ make clean setup run ``` ... change some kernel parameters in `test.sh` ... ``` -$ sudo make run +$ make run ``` to run the test without doing the setup. diff --git a/test/Makefile b/test/Makefile index dfaa450..518e7d6 100644 --- a/test/Makefile +++ b/test/Makefile @@ -1,7 +1,6 @@ .PHONY: all check clean $(wildcard TEST-??-*) $(wildcard TEST-??-*): - @[ "$(shell id -u)" = 0 ] || { echo "'check' must be run as root! Please use 'sudo'."; exit 1; } @{ \ [ -d $@ ] || exit 0; \ [ -f $@/Makefile ] || exit 0; \ diff --git a/test/test-functions b/test/test-functions index f76d930..f28e30a 100644 --- a/test/test-functions +++ b/test/test-functions @@ -52,15 +52,6 @@ COLOR_FAILURE='\033[0;31m' COLOR_WARNING='\033[0;33m' COLOR_NORMAL='\033[0;39m' -check_root() { - if ((EUID != 0)); then - SETCOLOR_FAILURE - echo "Tests must be run as root! Please use 'sudo'." - SETCOLOR_NORMAL - exit 1 - fi -} - # generate qemu arguments for named raw disks # # qemu_add_drive_args [] @@ -122,13 +113,11 @@ test_marker_check() { while (($# > 0)); do case $1 in --run) - check_root echo "TEST RUN: $TEST_DESCRIPTION" test_check && test_run exit $? ;; --setup) - check_root echo "TEST SETUP: $TEST_DESCRIPTION" test_check && test_setup exit $? @@ -141,7 +130,6 @@ while (($# > 0)); do exit $? ;; --all) - check_root if ! test_check 2 &> test${TEST_RUN_ID:+-$TEST_RUN_ID}.log; then echo -e "TEST: $TEST_DESCRIPTION " "$COLOR_WARNING" "[SKIPPED]" "$COLOR_NORMAL" exit 0