[PATCH 2/2] tests: run-tests: don't use sudo if already root
Brian Norris
briannorris at chromium.org
Thu Jun 25 16:22:02 EDT 2020
Among other things, sudo can disrupt environment variables that a caller
provides.
Signed-off-by: Brian Norris <briannorris at chromium.org>
---
tests/hwsim/run-all.sh | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/tests/hwsim/run-all.sh b/tests/hwsim/run-all.sh
index 495c9fa744b8..ee48cd0581c6 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
--
2.27.0.212.ge8ba1cc988-goog
More information about the Hostap
mailing list