run-unit-test-docker.sh: add extra docker run args
It can be useful to provide docker run with additional command line
arguments, such as --volume.
Consider a filesystem with git repositories:
~/git/openbmc/bmcweb
And git worktrees for those repositories outside of the ~/git/openbmc
namespace:
~/worktrees/worktree-a/bmcweb
~/worktrees/worktree-b/bmcweb
and then using EXTRA_DOCKER_RUN_ARGS="--volume $HOME/git:$HOME/git" it
becomes possible to run the unit tests with such a layout.
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Change-Id: I5524e4d369f98229180b2e1beaf322381ca814c7
diff --git a/run-unit-test-docker.sh b/run-unit-test-docker.sh
index 184d770..5ff16c5 100755
--- a/run-unit-test-docker.sh
+++ b/run-unit-test-docker.sh
@@ -23,6 +23,7 @@
# `/usr/share/dbus-1/system.conf`
# TEST_ONLY: Optional, do not run analysis tools
# NO_FORMAT_CODE: Optional, do not run format-code.sh
+# EXTRA_DOCKER_RUN_ARGS: Optional, pass arguments to docker run
# EXTRA_UNIT_TEST_ARGS: Optional, pass arguments to unit-test.py
# INTERACTIVE: Optional, run a bash shell instead of unit-test.py
# http_proxy: Optional, run the container with proxy environment
@@ -98,13 +99,15 @@
--env ftp_proxy=${http_proxy}"
fi
-# shellcheck disable=SC2086 # ${PROXY_ENV} is meant to be splitted
+# shellcheck disable=SC2086 # ${PROXY_ENV} and ${EXTRA_DOCKER_RUN_ARGS} are
+# meant to be split
docker run --cap-add=sys_admin --rm=true \
--privileged=true \
${PROXY_ENV} \
-u "$USER" \
-w "${DOCKER_WORKDIR}" -v "${WORKSPACE}":"${DOCKER_WORKDIR}" \
-e "MAKEFLAGS=${MAKEFLAGS}" \
+ ${EXTRA_DOCKER_RUN_ARGS:-} \
-${INTERACTIVE:+i}t "${DOCKER_IMG_NAME}" \
"${UNIT_TEST_SCRIPT_DIR}/${DBUS_UNIT_TEST_PY}" -u "${UNIT_TEST}" \
-f "${DBUS_SYS_CONFIG_FILE}"