mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2024-12-11 11:15:11 +08:00
2d75fd1e0a
crosvm-runner.sh was using `export -p` to create an environment script for the virtualized system, but this command will dump every declared environment variable in the system, which includes Gitlab's CI variables with sensitive data, such as passwords and auth tokens. Replacing `export -p` to `generate-env.sh`, which only exports the necessary variables for Mesa CI jobs. Extra changes: * Stop changing ${PWD} variable programmatically in scripts. ${PWD} is a variable used by most prolific coreutils and bash commands, such as `cd` and `pwd`, besides it is set by subshells [1]; changing this variable may lead to complex situations. As drop-in replacement for ${PWD}, use ${DEQP_BIN_DIR} to flag that there is a special folder where dEQP should be run. * Double quote path and array variables. See: https://github.com/koalaman/shellcheck/wiki/SC2086 * Do not export variables directly from commands output. See: https://github.com/koalaman/shellcheck/wiki/SC2155 [1] ``` $ cd /tmp $ export PWD=test; bash -c 'echo $PWD' /tmp ``` v2: - Revert $DEQP_BIN_DIR quoting in crosvm-runner.sh and crosvm-init.sh - Log all the passed variables to stdout, to help with debugging when new variable are needed to be put in `generate-env.sh` v3: - Revert $DEQP_BIN_DIR quoting leftovers Signed-off-by: Guilherme Gallo <guilherme.gallo@collabora.com> Reviewed-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14626>
39 lines
836 B
Bash
Executable File
39 lines
836 B
Bash
Executable File
#!/bin/sh
|
|
|
|
set -e
|
|
|
|
export DEQP_TEMP_DIR="$1"
|
|
|
|
mount -t proc none /proc
|
|
mount -t sysfs none /sys
|
|
mkdir -p /dev/pts
|
|
mount -t devpts devpts /dev/pts
|
|
mount -t tmpfs tmpfs /tmp
|
|
|
|
. $DEQP_TEMP_DIR/crosvm-env.sh
|
|
|
|
# .gitlab-ci.yml script variable is using relative paths to install directory,
|
|
# so change to that dir before running `crosvm-script`
|
|
cd "${CI_PROJECT_DIR}"
|
|
|
|
# The exception is the dEQP binary, since it needs to run from the directory
|
|
# it's in
|
|
if [ -d "${DEQP_BIN_DIR}" ]
|
|
then
|
|
cd "${DEQP_BIN_DIR}"
|
|
fi
|
|
|
|
dmesg --level crit,err,warn -w >> $DEQP_TEMP_DIR/stderr &
|
|
|
|
set +e
|
|
stdbuf -oL sh $DEQP_TEMP_DIR/crosvm-script.sh 2>> $DEQP_TEMP_DIR/stderr >> $DEQP_TEMP_DIR/stdout
|
|
echo $? > $DEQP_TEMP_DIR/exit_code
|
|
set -e
|
|
|
|
sync
|
|
sleep 1
|
|
|
|
poweroff -d -n -f || true
|
|
|
|
sleep 1 # Just in case init would exit before the kernel shuts down the VM
|