From: Brian Norris Date: Thu, 25 Jun 2020 20:22:02 +0000 (-0700) Subject: tests: run-tests: Do not use sudo if already root X-Git-Tag: hostap_2_10~877 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4b0bf0ec6efe6015aa6a9792ce1fb65bdc7f7548;p=thirdparty%2Fhostap.git tests: run-tests: Do not use sudo if already root Among other things, sudo can disrupt environment variables that a caller provides. Signed-off-by: Brian Norris --- diff --git a/tests/hwsim/run-all.sh b/tests/hwsim/run-all.sh index 495c9fa74..ee48cd058 100755 --- a/tests/hwsim/run-all.sh +++ b/tests/hwsim/run-all.sh @@ -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