]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: run-tests: Do not use sudo if already root
authorBrian Norris <briannorris@chromium.org>
Thu, 25 Jun 2020 20:22:02 +0000 (13:22 -0700)
committerJouni Malinen <j@w1.fi>
Sat, 10 Oct 2020 17:33:00 +0000 (20:33 +0300)
Among other things, sudo can disrupt environment variables that a caller
provides.

Signed-off-by: Brian Norris <briannorris@chromium.org>
tests/hwsim/run-all.sh

index 495c9fa744b87dd329556da4d6d841e3bff6b6d1..ee48cd0581c620f4849e4f417123130920d63854 100755 (executable)
@@ -122,7 +122,13 @@ if ! ./start.sh $VM $VALGRIND $TRACE channels=$NUM_CH; then
        exit 1
 fi
 
-sudo ./run-tests.py -D --logdir "$LOGDIR" $TRACE_ARGS -q $DB $RUN_TEST_ARGS || errors=1
+# Only use sudo if not already root.
+if [ "$(id -u)" != 0 ]; then
+       SUDO=sudo
+else
+       SUDO=
+fi
+${SUDO} ./run-tests.py -D --logdir "$LOGDIR" $TRACE_ARGS -q $DB $RUN_TEST_ARGS || errors=1
 
 ./stop.sh