ci: enable shellcheck on whole .gitlab-ci
authorDavid Heidelberg <david.heidelberg@collabora.com>
Sat, 20 May 2023 22:47:05 +0000 (00:47 +0200)
committerDavid Heidelberg <david.heidelberg@collabora.com>
Thu, 25 May 2023 14:06:53 +0000 (16:06 +0200)
Signed-off-by: David Heidelberg <david.heidelberg@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21977>

44 files changed:
.gitlab-ci/bare-metal/cisco-2960-poe-off.sh
.gitlab-ci/bare-metal/cisco-2960-poe-on.sh
.gitlab-ci/bare-metal/cros-servo.sh
.gitlab-ci/bare-metal/eth008-power-down.sh
.gitlab-ci/bare-metal/eth008-power-up.sh
.gitlab-ci/bare-metal/expect-output.sh
.gitlab-ci/bare-metal/fastboot.sh
.gitlab-ci/bare-metal/google-power-down.sh
.gitlab-ci/bare-metal/google-power-up.sh
.gitlab-ci/bare-metal/poe-off
.gitlab-ci/bare-metal/poe-on
.gitlab-ci/bare-metal/poe-powered.sh
.gitlab-ci/bare-metal/rootfs-setup.sh
.gitlab-ci/build/compiler-wrapper-clang++-15.sh
.gitlab-ci/build/compiler-wrapper-clang++.sh
.gitlab-ci/build/compiler-wrapper-clang-15.sh
.gitlab-ci/build/compiler-wrapper-clang.sh
.gitlab-ci/build/compiler-wrapper-g++.sh
.gitlab-ci/build/compiler-wrapper-gcc.sh
.gitlab-ci/build/compiler-wrapper.sh
.gitlab-ci/common/capture-devcoredump.sh
.gitlab-ci/common/init-stage1.sh
.gitlab-ci/common/init-stage2.sh
.gitlab-ci/common/intel-gpu-freq.sh
.gitlab-ci/common/start-x.sh
.gitlab-ci/crosvm-init.sh
.gitlab-ci/crosvm-runner.sh
.gitlab-ci/cuttlefish-runner.sh
.gitlab-ci/deqp-runner.sh
.gitlab-ci/download-git-cache.sh
.gitlab-ci/fossilize-runner.sh
.gitlab-ci/fossils/fossils.sh
.gitlab-ci/gtest-runner.sh
.gitlab-ci/lava/lava-pytest.sh
.gitlab-ci/lava/lava-submit.sh
.gitlab-ci/meson/build.sh
.gitlab-ci/meson/time-strace.sh
.gitlab-ci/piglit/piglit-runner.sh
.gitlab-ci/piglit/piglit-traces.sh
.gitlab-ci/prepare-artifacts.sh
.gitlab-ci/run-shellcheck.sh
.gitlab-ci/setup-test-env.sh
.gitlab-ci/valve/traces-runner.sh
.gitlab-ci/vkd3d-proton/run.sh

index 2234ee7..fdc52d3 100755 (executable)
@@ -1,4 +1,5 @@
 #!/bin/bash
+# shellcheck disable=SC2086 # we want word splitting
 
 if [ -z "$BM_POE_INTERFACE" ]; then
     echo "Must supply the PoE Interface to power down"
@@ -11,7 +12,6 @@ if [ -z "$BM_POE_ADDRESS" ]; then
 fi
 
 SNMP_KEY="1.3.6.1.4.1.9.9.402.1.2.1.1.1.$BM_POE_INTERFACE"
-SNMP_ON="i 1"
 SNMP_OFF="i 4"
 
-snmpset -v2c -r 3 -t 30 -cmesaci $BM_POE_ADDRESS $SNMP_KEY $SNMP_OFF
+snmpset -v2c -r 3 -t 30 -cmesaci "$BM_POE_ADDRESS" "$SNMP_KEY" $SNMP_OFF
index 60d7d72..1f80ab3 100755 (executable)
@@ -1,4 +1,5 @@
 #!/bin/bash
+# shellcheck disable=SC2086 # we want word splitting
 
 if [ -z "$BM_POE_INTERFACE" ]; then
     echo "Must supply the PoE Interface to power up"
@@ -16,6 +17,6 @@ SNMP_KEY="1.3.6.1.4.1.9.9.402.1.2.1.1.1.$BM_POE_INTERFACE"
 SNMP_ON="i 1"
 SNMP_OFF="i 4"
 
-snmpset -v2c -r 3 -t 10 -cmesaci $BM_POE_ADDRESS $SNMP_KEY $SNMP_OFF
+snmpset -v2c -r 3 -t 10 -cmesaci "$BM_POE_ADDRESS" "$SNMP_KEY" $SNMP_OFF
 sleep 3s
-snmpset -v2c -r 3 -t 10 -cmesaci $BM_POE_ADDRESS $SNMP_KEY $SNMP_ON
+snmpset -v2c -r 3 -t 10 -cmesaci "$BM_POE_ADDRESS" "$SNMP_KEY" $SNMP_ON
index 0180307..a790a4e 100755 (executable)
@@ -1,4 +1,7 @@
 #!/bin/bash
+# shellcheck disable=SC1091 # The relative paths in this file only become valid at runtime.
+# shellcheck disable=SC2034
+# shellcheck disable=SC2086 # we want word splitting
 
 # Boot script for Chrome OS devices attached to a servo debug connector, using
 # NFS and TFTP to boot.
index 8a270bd..d61156d 100755 (executable)
@@ -7,4 +7,4 @@ if [ -z "$relay" ]; then
     exit 1
 fi
 
-$CI_PROJECT_DIR/install/bare-metal/eth008-power-relay.py $ETH_HOST $ETH_PORT off $relay
+"$CI_PROJECT_DIR"/install/bare-metal/eth008-power-relay.py "$ETH_HOST" "$ETH_PORT" off "$relay"
index 2d1071b..4c978ac 100755 (executable)
@@ -7,6 +7,6 @@ if [ -z "$relay" ]; then
     exit 1
 fi
 
-$CI_PROJECT_DIR/install/bare-metal/eth008-power-relay.py $ETH_HOST $ETH_PORT off $relay
+"$CI_PROJECT_DIR"/install/bare-metal/eth008-power-relay.py "$ETH_HOST" "$ETH_PORT" off "$relay"
 sleep 5
-$CI_PROJECT_DIR/install/bare-metal/eth008-power-relay.py $ETH_HOST $ETH_PORT on $relay
+"$CI_PROJECT_DIR"/install/bare-metal/eth008-power-relay.py "$ETH_HOST" "$ETH_PORT" on "$relay"
index db82ea0..425814d 100755 (executable)
@@ -5,26 +5,27 @@ set -e
 STRINGS=$(mktemp)
 ERRORS=$(mktemp)
 
-trap "rm $STRINGS; rm $ERRORS;" EXIT
+trap 'rm $STRINGS; rm $ERRORS;' EXIT
 
 FILE=$1
 shift 1
 
 while getopts "f:e:" opt; do
   case $opt in
-    f) echo "$OPTARG" >> $STRINGS;;
-    e) echo "$OPTARG" >> $STRINGS ; echo "$OPTARG" >> $ERRORS;;
+    f) echo "$OPTARG" >> "$STRINGS";;
+    e) echo "$OPTARG" >> "$STRINGS" ; echo "$OPTARG" >> "$ERRORS";;
+    *) exit
   esac
 done
 shift $((OPTIND -1))
 
 echo "Waiting for $FILE to say one of following strings"
-cat $STRINGS
+cat "$STRINGS"
 
-while ! egrep -wf $STRINGS $FILE; do
+while ! grep -E -wf "$STRINGS" "$FILE"; do
   sleep 2
 done
 
-if egrep -wf $ERRORS $FILE; then
+if grep -E -wf "$ERRORS" "$FILE"; then
   exit 1
 fi
index e4ea361..a7fa171 100755 (executable)
@@ -1,11 +1,14 @@
 #!/bin/bash
+# shellcheck disable=SC1091 # The relative paths in this file only become valid at runtime.
+# shellcheck disable=SC2034
+# shellcheck disable=SC2086 # we want word splitting
 
 . "$SCRIPTS_DIR"/setup-test-env.sh
 
 BM=$CI_PROJECT_DIR/install/bare-metal
 CI_COMMON=$CI_PROJECT_DIR/install/common
 
-if [ -z "$BM_SERIAL" -a -z "$BM_SERIAL_SCRIPT" ]; then
+if [ -z "$BM_SERIAL" ] && [ -z "$BM_SERIAL_SCRIPT" ]; then
   echo "Must set BM_SERIAL OR BM_SERIAL_SCRIPT in your gitlab-runner config.toml [[runners]] environment"
   echo "BM_SERIAL:"
   echo "  This is the serial device to talk to for waiting for fastboot to be ready and logging from the kernel."
@@ -84,10 +87,10 @@ else
   fi
 
   pushd rootfs
-  find -H | \
-    egrep -v "external/(openglcts|vulkancts|amber|glslang|spirv-tools)" |
-    egrep -v "traces-db|apitrace|renderdoc" | \
-    egrep -v $EXCLUDE_FILTER | \
+  find -H | \
+    grep -E -v "external/(openglcts|vulkancts|amber|glslang|spirv-tools)" |
+    grep -E -v "traces-db|apitrace|renderdoc" | \
+    grep -E -v $EXCLUDE_FILTER | \
     cpio -H newc -o | \
     xz --check=crc32 -T4 - > $CI_PROJECT_DIR/rootfs.cpio.gz
   popd
index 9aa68a7..0404619 100755 (executable)
@@ -7,4 +7,4 @@ if [ -z "$relay" ]; then
     exit 1
 fi
 
-$CI_PROJECT_DIR/install/bare-metal/google-power-relay.py off $relay
+"$CI_PROJECT_DIR"/install/bare-metal/google-power-relay.py off "$relay"
index f0c0541..d5c3cf7 100755 (executable)
@@ -7,6 +7,6 @@ if [ -z "$relay" ]; then
     exit 1
 fi
 
-$CI_PROJECT_DIR/install/bare-metal/google-power-relay.py off $relay
+"$CI_PROJECT_DIR"/install/bare-metal/google-power-relay.py off "$relay"
 sleep 5
-$CI_PROJECT_DIR/install/bare-metal/google-power-relay.py on $relay
+"$CI_PROJECT_DIR"/install/bare-metal/google-power-relay.py on "$relay"
index f458d61..3332a7b 100755 (executable)
@@ -10,8 +10,7 @@ if [ -z "$BM_POE_ADDRESS" ]; then
     exit 1
 fi
 
-SNMP_KEY="SNMPv2-SMI::mib-2.105.1.1.1.3.1.`expr 48 + $BM_POE_INTERFACE`"
-SNMP_ON="i 1"
+SNMP_KEY="SNMPv2-SMI::mib-2.105.1.1.1.3.1.$((48 + BM_POE_INTERFACE))"
 SNMP_OFF="i 2"
 
 flock /var/run/poe.lock -c "snmpset -v2c -r 3 -t 30 -cmesaci $BM_POE_ADDRESS $SNMP_KEY $SNMP_OFF"
index 6d5653c..de41fc9 100755 (executable)
@@ -10,7 +10,7 @@ if [ -z "$BM_POE_ADDRESS" ]; then
     exit 1
 fi
 
-SNMP_KEY="SNMPv2-SMI::mib-2.105.1.1.1.3.1.`expr 48 + $BM_POE_INTERFACE`"
+SNMP_KEY="SNMPv2-SMI::mib-2.105.1.1.1.3.1.$((48 + BM_POE_INTERFACE))"
 SNMP_ON="i 1"
 SNMP_OFF="i 2"
 
index b075aae..46aa786 100755 (executable)
@@ -1,4 +1,8 @@
 #!/bin/bash
+# shellcheck disable=SC1091
+# shellcheck disable=SC2034
+# shellcheck disable=SC2059
+# shellcheck disable=SC2086 # we want word splitting
 
 . "$SCRIPTS_DIR"/setup-test-env.sh
 
index 23226e4..31862d5 100644 (file)
@@ -1,4 +1,5 @@
-#!/bin/bash
+#!/usr/bin/env bash
+# shellcheck disable=SC2086 # we want word splitting
 
 rootfs_dst=$1
 
index d045162..15f392a 100755 (executable)
@@ -1,4 +1,5 @@
 #!/bin/sh
+# shellcheck disable=SC1091
 
 set -e
 
index ef0f8b8..2597481 100755 (executable)
@@ -1,4 +1,5 @@
 #!/bin/sh
+# shellcheck disable=SC1091
 
 set -e
 
index 0567601..1f67492 100644 (file)
@@ -1,3 +1,5 @@
+# shellcheck disable=SC1091
+# shellcheck disable=SC2086 # we want word splitting
 if command -V ccache >/dev/null 2>/dev/null; then
   CCACHE=ccache
 else
index f40b748..302b920 100755 (executable)
@@ -1,7 +1,10 @@
-#!/bin/sh
+#!/usr/bin/env bash
+# shellcheck disable=SC2035
+# shellcheck disable=SC2061
+# shellcheck disable=SC2086 # we want word splitting
 
 while true; do
-  devcds=`find /sys/devices/virtual/devcoredump/ -name data 2>/dev/null`
+  devcds=$(find /sys/devices/virtual/devcoredump/ -name data 2>/dev/null)
   for i in $devcds; do
     echo "Found a devcoredump at $i."
     if cp $i /results/first.devcore; then
index 7b74123..41f1112 100755 (executable)
@@ -22,4 +22,4 @@ echo "nameserver 8.8.8.8" > /etc/resolv.conf
 
 # Set the time so we can validate certificates before we fetch anything;
 # however as not all DUTs have network, make this non-fatal.
-for i in 1 2 3; do sntp -sS pool.ntp.org && break || sleep 2; done || true
+for _ in 1 2 3; do sntp -sS pool.ntp.org && break || sleep 2; done || true
index f291f79..92e6d7b 100755 (executable)
@@ -1,4 +1,8 @@
 #!/bin/bash
+# shellcheck disable=SC1090
+# shellcheck disable=SC1091
+# shellcheck disable=SC2086 # we want word splitting
+# shellcheck disable=SC2155
 
 # Second-stage init, used to set up devices and our job environment before
 # running tests.
@@ -67,12 +71,12 @@ fi
 #
 if [ "$HWCI_KVM" = "true" ]; then
     unset KVM_KERNEL_MODULE
-    grep -qs '\bvmx\b' /proc/cpuinfo && KVM_KERNEL_MODULE=kvm_intel || {
+    (grep -qs '\bvmx\b' /proc/cpuinfo && KVM_KERNEL_MODULE=kvm_intel) || {
         grep -qs '\bsvm\b' /proc/cpuinfo && KVM_KERNEL_MODULE=kvm_amd
     }
 
-    [ -z "${KVM_KERNEL_MODULE}" ] && \
-        echo "WARNING: Failed to detect CPU virtualization extensions" || \
+    ([ -z "${KVM_KERNEL_MODULE}" ] && \
+      echo "WARNING: Failed to detect CPU virtualization extensions") || \
         modprobe ${KVM_KERNEL_MODULE}
 
     mkdir -p /lava-files
@@ -103,14 +107,14 @@ if [ "$HWCI_FREQ_MAX" = "true" ]; then
   head -0 /dev/dri/renderD128
 
   # Disable GPU frequency scaling
-  DEVFREQ_GOVERNOR=`find /sys/devices -name governor | grep gpu || true`
+  DEVFREQ_GOVERNOR=$(find /sys/devices -name governor | grep gpu || true)
   test -z "$DEVFREQ_GOVERNOR" || echo performance > $DEVFREQ_GOVERNOR || true
 
   # Disable CPU frequency scaling
   echo performance | tee -a /sys/devices/system/cpu/cpufreq/policy*/scaling_governor || true
 
   # Disable GPU runtime power management
-  GPU_AUTOSUSPEND=`find /sys/devices -name autosuspend_delay_ms | grep gpu | head -1`
+  GPU_AUTOSUSPEND=$(find /sys/devices -name autosuspend_delay_ms | grep gpu | head -1)
   test -z "$GPU_AUTOSUSPEND" || echo -1 > $GPU_AUTOSUSPEND || true
   # Lock Intel GPU frequency to 70% of the maximum allowed by hardware
   # and enable throttling detection & reporting.
@@ -139,12 +143,12 @@ fi
 if [ -n "$HWCI_START_XORG" ]; then
   echo "touch /xorg-started; sleep 100000" > /xorg-script
   env \
-    VK_ICD_FILENAMES=/install/share/vulkan/icd.d/${VK_DRIVER}_icd.`uname -m`.json \
+    VK_ICD_FILENAMES="/install/share/vulkan/icd.d/${VK_DRIVER}_icd.$(uname -m).json" \
     xinit /bin/sh /xorg-script -- /usr/bin/Xorg -noreset -s 0 -dpms -logfile /Xorg.0.log &
   BACKGROUND_PIDS="$! $BACKGROUND_PIDS"
 
   # Wait for xorg to be ready for connections.
-  for i in 1 2 3 4 5; do
+  for _ in 1 2 3 4 5; do
     if [ -e /xorg-started ]; then
       break
     fi
index e264348..8d0166e 100755 (executable)
@@ -1,4 +1,14 @@
-#!/bin/sh
+#!/usr/bin/env bash
+# shellcheck disable=SC2013
+# shellcheck disable=SC2015
+# shellcheck disable=SC2034
+# shellcheck disable=SC2046
+# shellcheck disable=SC2059
+# shellcheck disable=SC2086 # we want word splitting
+# shellcheck disable=SC2154
+# shellcheck disable=SC2155
+# shellcheck disable=SC2162
+# shellcheck disable=SC2229
 #
 # This is an utility script to manage Intel GPU frequencies.
 # It can be used for debugging performance problems or trying to obtain a stable
@@ -193,7 +203,7 @@ compute_freq_set() {
         val=${FREQ_RPn}
         ;;
     *%)
-        val=$((${1%?} * ${FREQ_RP0} / 100))
+        val=$((${1%?} * FREQ_RP0 / 100))
         # Adjust freq to comply with 50 MHz increments
         val=$((val / 50 * 50))
         ;;
@@ -242,12 +252,12 @@ set_freq_max() {
 
     [ -z "${DRY_RUN}" ] || return 0
 
-    printf "%s" ${SET_MAX_FREQ} | tee $(print_freq_sysfs_path max) \
-        $(print_freq_sysfs_path boost) > /dev/null
-    [ $? -eq 0 ] || {
+    if ! printf "%s" ${SET_MAX_FREQ} | tee $(print_freq_sysfs_path max) \
+        $(print_freq_sysfs_path boost) > /dev/null;
+    then
         log ERROR "Failed to set GPU max frequency"
         return 1
-    }
+    fi
 }
 
 #
@@ -272,11 +282,11 @@ set_freq_min() {
 
     [ -z "${DRY_RUN}" ] || return 0
 
-    printf "%s" ${SET_MIN_FREQ} > $(print_freq_sysfs_path min)
-    [ $? -eq 0 ] || {
+    if ! printf "%s" ${SET_MIN_FREQ} > $(print_freq_sysfs_path min);
+    then
         log ERROR "Failed to set GPU min frequency"
         return 1
-    }
+    fi
 }
 
 #
@@ -495,7 +505,7 @@ compute_cpu_freq_set() {
         val=${CPU_FREQ_cpuinfo_min}
         ;;
     *%)
-        val=$((${1%?} * ${CPU_FREQ_cpuinfo_max} / 100))
+        val=$((${1%?} * CPU_FREQ_cpuinfo_max / 100))
         ;;
     *[!0-9]*)
         log ERROR "Cannot set CPU freq to invalid value: %s" "$1"
@@ -538,11 +548,11 @@ set_cpu_freq_max() {
     local pstate_info=$(printf "${CPU_PSTATE_SYSFS_PATTERN}" max_perf_pct)
     [ -e "${pstate_info}" ] && {
         log INFO "Setting intel_pstate max perf to %s" "${target_freq}%"
-        printf "%s" "${target_freq}" > "${pstate_info}"
-        [ $? -eq 0 ] || {
+        if ! printf "%s" "${target_freq}" > "${pstate_info}";
+       then
             log ERROR "Failed to set intel_pstate max perf"
             res=1
-        }
+       fi
     }
 
     local cpu_index
@@ -555,11 +565,11 @@ set_cpu_freq_max() {
         log INFO "Setting CPU%s max scaling freq to %s Hz" ${cpu_index} "${target_freq}"
         [ -n "${DRY_RUN}" ] && continue
 
-        printf "%s" ${target_freq} > $(print_cpu_freq_sysfs_path scaling_max ${cpu_index})
-        [ $? -eq 0 ] || {
+        if ! printf "%s" ${target_freq} > $(print_cpu_freq_sysfs_path scaling_max ${cpu_index});
+       then
             res=1
             log ERROR "Failed to set CPU%s max scaling frequency" ${cpu_index}
-        }
+       fi
     done
 
     return ${res}
index 4d3336f..ccd1323 100755 (executable)
@@ -13,7 +13,7 @@ fi
 xinit /bin/sh "${_XORG_SCRIPT}" -- /usr/bin/Xorg vt45 -noreset -s 0 -dpms -logfile /Xorg.0.log &
 
 # Wait for xorg to be ready for connections.
-for i in 1 2 3 4 5; do
+for _ in 1 2 3 4 5; do
     if [ -e "${_FLAG_FILE}" ]; then
         break
     fi
index d3e3d8d..c4446bf 100755 (executable)
@@ -1,5 +1,6 @@
 #!/usr/bin/env bash
-
+# shellcheck disable=SC1091 # The relative paths in this file only become valid at runtime.
+# shellcheck disable=SC2086 # we want word splitting
 set -e
 
 VSOCK_STDOUT=$1
index bd941c4..317f35d 100755 (executable)
@@ -1,5 +1,5 @@
-#!/bin/sh
-
+#!/usr/bin/env bash
+# shellcheck disable=SC2086 # we want word splitting
 set -e
 
 # If run outside of a deqp-runner invoction (e.g. piglit trace replay), then act
@@ -35,7 +35,7 @@ set_vsock_context() {
     rm -rf $VM_TEMP_DIR
     mkdir $VM_TEMP_DIR || return 1
 
-    VSOCK_CID=$(((CI_JOB_ID & 0x1ffffff) | ((${THREAD} & 0x7f) << 25)))
+    VSOCK_CID=$(((CI_JOB_ID & 0x1ffffff) | ((THREAD & 0x7f) << 25)))
     VSOCK_STDOUT=5001
     VSOCK_STDERR=5002
 
@@ -66,7 +66,7 @@ set_vsock_context || { echo "Could not generate crosvm vsock CID" >&2; exit 1; }
 echo "Variables passed through:"
 SCRIPT_DIR=$(readlink -en "${0%/*}")
 ${SCRIPT_DIR}/common/generate-env.sh | tee ${VM_TEMP_DIR}/crosvm-env.sh
-cp ${SCRIPTS_DIR}/setup-test-env.sh ${VM_TEMP_DIR}/setup-test-env.sh
+cp ${SCRIPT_DIR}/setup-test-env.sh ${VM_TEMP_DIR}/setup-test-env.sh
 
 # Set the crosvm-script as the arguments of the current script
 echo ". ${VM_TEMP_DIR}/setup-test-env.sh" > ${VM_TEMP_DIR}/crosvm-script.sh
index 56e6019..e332b54 100755 (executable)
@@ -1,4 +1,6 @@
 #!/usr/bin/env bash
+# shellcheck disable=SC2086 # we want word splitting
+
 section_start cuttlefish_setup "cuttlefish: setup"
 set -xe
 
@@ -26,6 +28,7 @@ ADB="adb -s vsock:3:5555"
 $ADB root
 sleep 1
 $ADB shell echo Hi from Android
+# shellcheck disable=SC2035
 $ADB logcat dEQP:D *:S &
 
 # overlay vendor
@@ -97,7 +100,7 @@ $ADB shell "mkdir /data/results; cd /data; strace -o /data/results/out.strace -f
     --flakes /data/$GPU_VERSION-flakes.txt \
     --testlog-to-xml /deqp/executor/testlog-to-xml \
     --fraction-start $CI_NODE_INDEX \
-    --fraction `expr $CI_NODE_TOTAL \* ${DEQP_FRACTION:-1}` \
+    --fraction $(( CI_NODE_TOTAL * ${DEQP_FRACTION:-1})) \
     --jobs ${FDO_CI_CONCURRENT:-4} \
     $DEQP_RUNNER_OPTIONS"
 
index 62137c3..1121161 100755 (executable)
@@ -1,4 +1,5 @@
 #!/usr/bin/env bash
+# shellcheck disable=SC2086 # we want word splitting
 
 section_start test_setup "deqp: preparing test setup"
 
@@ -32,8 +33,6 @@ findmnt -n tmpfs ${SHADER_CACHE_HOME} || findmnt -n tmpfs ${SHADER_CACHE_DIR} ||
     mount -t tmpfs -o nosuid,nodev,size=2G,mode=1755 tmpfs ${SHADER_CACHE_DIR}
 }
 
-HANG_DETECTION_CMD=""
-
 if [ -z "$DEQP_SUITE" ]; then
     if [ -z "$DEQP_VER" ]; then
         echo 'DEQP_SUITE must be set to the name of your deqp-gpu_version.toml, or DEQP_VER must be set to something like "gles2", "gles31-khr" or "vk" for the test run'
@@ -50,7 +49,7 @@ if [ -z "$DEQP_SUITE" ]; then
     DEQP_OPTIONS="$DEQP_OPTIONS --deqp-gl-config-name=$DEQP_CONFIG"
     DEQP_OPTIONS="$DEQP_OPTIONS --deqp-visibility=hidden"
 
-    if [ "$DEQP_VER" = "vk" -a -z "$VK_DRIVER" ]; then
+    if [ "$DEQP_VER" = "vk" ] && [ -z "$VK_DRIVER" ]; then
         echo 'VK_DRIVER must be to something like "radeon" or "intel" for the test run'
         exit 1
     fi
@@ -59,11 +58,10 @@ if [ -z "$DEQP_SUITE" ]; then
     if [ "$DEQP_VER" = "vk" ]; then
        MUSTPASS=/deqp/mustpass/vk-$DEQP_VARIANT.txt
        DEQP=/deqp/external/vulkancts/modules/vulkan/deqp-vk
-       HANG_DETECTION_CMD="/parallel-deqp-runner/build/bin/hang-detection"
-    elif [ "$DEQP_VER" = "gles2" -o "$DEQP_VER" = "gles3" -o "$DEQP_VER" = "gles31" -o "$DEQP_VER" = "egl" ]; then
+    elif [ "$DEQP_VER" = "gles2" ] || [ "$DEQP_VER" = "gles3" ] || [ "$DEQP_VER" = "gles31" ] || [ "$DEQP_VER" = "egl" ]; then
        MUSTPASS=/deqp/mustpass/$DEQP_VER-$DEQP_VARIANT.txt
        DEQP=/deqp/modules/$DEQP_VER/deqp-$DEQP_VER
-    elif [ "$DEQP_VER" = "gles2-khr" -o "$DEQP_VER" = "gles3-khr" -o "$DEQP_VER" = "gles31-khr" -o "$DEQP_VER" = "gles32-khr" ]; then
+    elif [ "$DEQP_VER" = "gles2-khr" ] || [ "$DEQP_VER" = "gles3-khr" ] || [ "$DEQP_VER" = "gles31-khr" ] || [ "$DEQP_VER" = "gles32-khr" ]; then
        MUSTPASS=/deqp/mustpass/$DEQP_VER-$DEQP_VARIANT.txt
        DEQP=/deqp/external/openglcts/modules/glcts
     else
@@ -129,7 +127,7 @@ export VK_LAYER_SETTINGS_PATH=$INSTALL/$GPU_VERSION-validation-settings.txt
 
 report_load() {
     echo "System load: $(cut -d' ' -f1-3 < /proc/loadavg)"
-    echo "# of CPU cores: $(cat /proc/cpuinfo | grep processor | wc -l)"
+    echo "# of CPU cores: $(grep -c processor /proc/cpuinfo)"
 }
 
 if [ "$GALLIUM_DRIVER" = "virpipe" ]; then
@@ -149,10 +147,11 @@ fi
 
 if [ -z "$DEQP_SUITE" ]; then
     if [ -n "$DEQP_EXPECTED_RENDERER" ]; then
-        export DEQP_RUNNER_OPTIONS="$DEQP_RUNNER_OPTIONS --renderer-check "$DEQP_EXPECTED_RENDERER""
+        export DEQP_RUNNER_OPTIONS="$DEQP_RUNNER_OPTIONS --renderer-check $DEQP_EXPECTED_RENDERER"
     fi
-    if [ $DEQP_VER != vk -a $DEQP_VER != egl ]; then
-        export DEQP_RUNNER_OPTIONS="$DEQP_RUNNER_OPTIONS --version-check `cat $INSTALL/VERSION | sed 's/[() ]/./g'`"
+    if [ $DEQP_VER != vk ] && [ $DEQP_VER != egl ]; then
+       VER=$(sed 's/[() ]/./g' "$INSTALL/VERSION")
+        export DEQP_RUNNER_OPTIONS="$DEQP_RUNNER_OPTIONS --version-check $VER"
     fi
 fi
 
@@ -181,7 +180,7 @@ else
         --flakes $INSTALL/$GPU_VERSION-flakes.txt \
         --testlog-to-xml /deqp/executor/testlog-to-xml \
         --fraction-start $CI_NODE_INDEX \
-        --fraction `expr $CI_NODE_TOTAL \* ${DEQP_FRACTION:-1}` \
+       --fraction $((CI_NODE_TOTAL * ${DEQP_FRACTION:-1})) \
         --jobs ${FDO_CI_CONCURRENT:-4} \
        $DEQP_RUNNER_OPTIONS
 fi
index e66f989..5fcb36e 100644 (file)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 
 set +e
 set -o xtrace
@@ -16,12 +16,9 @@ fi
 TMP_DIR=$(mktemp -d)
 
 echo "Downloading archived master..."
-/usr/bin/wget \
+if ! /usr/bin/wget \
              -O "$TMP_DIR/$CI_PROJECT_NAME.tar.gz" \
-              "https://${MINIO_HOST}/git-cache/${FDO_UPSTREAM_REPO}/$CI_PROJECT_NAME.tar.gz"
-
-# check wget error code
-if [[ $? -ne 0 ]]
+              "https://${MINIO_HOST}/git-cache/${FDO_UPSTREAM_REPO}/$CI_PROJECT_NAME.tar.gz";
 then
     echo "Repository cache not available"
     exit
index e19544f..f236892 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/usr/bin/env bash
 
 set -ex
 
@@ -7,15 +7,15 @@ if [ -z "$VK_DRIVER" ]; then
    exit 1
 fi
 
-INSTALL=`pwd`/install
+INSTALL=$PWD/install
 
 # Set up the driver environment.
-export LD_LIBRARY_PATH=`pwd`/install/lib/
-export VK_ICD_FILENAMES=`pwd`/install/share/vulkan/icd.d/"$VK_DRIVER"_icd.x86_64.json
-export LD_PRELOAD=`pwd`/install/lib/libamdgpu_noop_drm_shim.so
+export LD_LIBRARY_PATH="$INSTALL/lib/"
+export VK_ICD_FILENAMES="$INSTALL/share/vulkan/icd.d/${VK_DRIVER}_icd.x86_64.json"
+export LD_PRELOAD="$INSTALL/lib/libamdgpu_noop_drm_shim.so"
 
 # To store Fossilize logs on failure.
-RESULTS=`pwd`/results
+RESULTS="$PWD/results"
 mkdir -p results
 
 "$INSTALL/fossils/fossils.sh" "$INSTALL/fossils.yml" "$RESULTS"
index 0dffa47..e50312d 100755 (executable)
@@ -1,4 +1,6 @@
 #!/usr/bin/env bash
+# shellcheck disable=SC2086 # we want word splitting
+# shellcheck disable=SC2155
 
 FOSSILS_SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
 FOSSILS_YAML="$(readlink -f "$1")"
@@ -10,7 +12,7 @@ clone_fossils_db()
     local commit="$2"
     rm -rf fossils-db
     git clone --no-checkout "$repo" fossils-db
-    (cd fossils-db; git reset "$commit" || git reset "origin/$commit")
+    (cd fossils-db || return; git reset "$commit" || git reset "origin/$commit")
 }
 
 query_fossils_yaml()
@@ -51,7 +53,7 @@ fetch_fossil()
 if [[ -n "$(query_fossils_yaml fossils_db_repo)" ]]; then
     clone_fossils_db "$(query_fossils_yaml fossils_db_repo)" \
                      "$(query_fossils_yaml fossils_db_commit)"
-    cd fossils-db
+    cd fossils-db || return
 else
     echo "Warning: No fossils-db entry in $FOSSILS_YAML, assuming fossils-db is current directory"
 fi
@@ -65,8 +67,8 @@ create_clean_git
 for fossil in $(query_fossils_yaml fossils)
 do
     fetch_fossil "$fossil" || exit $?
-    fossilize-replay --num-threads 4 $fossil 1>&2 2> $FOSSILS_RESULTS/fossil_replay.txt
-    if [ $? != 0 ]; then
+    if ! fossilize-replay --num-threads 4 $fossil 1>&2 2> $FOSSILS_RESULTS/fossil_replay.txt;
+    then
         echo "Replay of $fossil failed"
         grep "pipeline crashed or hung" $FOSSILS_RESULTS/fossil_replay.txt
         exit 1
index 1e66101..8dfa374 100755 (executable)
@@ -1,4 +1,5 @@
 #!/usr/bin/env bash
+# shellcheck disable=SC2086 # we want word splitting
 
 set -ex
 
index 4f5ca50..786a669 100755 (executable)
@@ -1,35 +1,17 @@
 #!/usr/bin/env bash
-#
-# Copyright (C) 2022 Collabora Limited
+# SPDX-License-Identifier: MIT
+# © Collabora Limited
 # Author: Guilherme Gallo <guilherme.gallo@collabora.com>
-#
-# Permission is hereby granted, free of charge, to any person obtaining a
-# copy of this software and associated documentation files (the "Software"),
-# to deal in the Software without restriction, including without limitation
-# the rights to use, copy, modify, merge, publish, distribute, sublicense,
-# and/or sell copies of the Software, and to permit persons to whom the
-# Software is furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice (including the next
-# paragraph) shall be included in all copies or substantial portions of the
-# Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
-# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-# SOFTWARE.
 
 # This script runs unit/integration tests related with LAVA CI tools
+# shellcheck disable=SC1091 # The relative paths in this file only become valid at runtime.
 
 set -ex
 
 # Use this script in a python virtualenv for isolation
 python3 -m venv .venv
 . .venv/bin/activate
-python3 -m pip install --break-system-packages -r ${CI_PROJECT_DIR}/.gitlab-ci/lava/requirements-test.txt
+python3 -m pip install --break-system-packages -r "${CI_PROJECT_DIR}/.gitlab-ci/lava/requirements-test.txt"
 
 TEST_DIR=${CI_PROJECT_DIR}/.gitlab-ci/tests
 
index f2b4fc5..bf1ba7f 100755 (executable)
@@ -1,7 +1,7 @@
 #!/usr/bin/env bash
+# shellcheck disable=SC2086 # we want word splitting
 
-set -e
-set -x
+set -ex
 
 # If we run in the fork (not from mesa or Marge-bot), reuse mainline kernel and rootfs, if exist.
 BASE_SYSTEM_HOST_PATH="${BASE_SYSTEM_MAINLINE_HOST_PATH}"
index f6e57e7..978fcd1 100755 (executable)
@@ -1,4 +1,6 @@
 #!/usr/bin/env bash
+# shellcheck disable=SC1003 # works for us now...
+# shellcheck disable=SC2086 # we want word splitting
 
 section_switch meson-configure "meson: configure"
 
@@ -19,9 +21,9 @@ printf > native.file "%s\n" \
 # tweak the cross file or generate a native file to do so.
 if test -n "$LLVM_VERSION"; then
     LLVM_CONFIG="llvm-config-${LLVM_VERSION}"
-    echo "llvm-config = '`which $LLVM_CONFIG`'" >> native.file
+    echo "llvm-config = '$(which "$LLVM_CONFIG")'" >> native.file
     if [ -n "$CROSS" ]; then
-        sed -i -e '/\[binaries\]/a\' -e "llvm-config = '`which $LLVM_CONFIG`'" $CROSS_FILE
+      sed -i -e '/\[binaries\]/a\' -e "llvm-config = '$(which "$LLVM_CONFIG")'" $CROSS_FILE
     fi
     $LLVM_CONFIG --version
 fi
@@ -71,7 +73,7 @@ meson setup _build \
       --wrap-mode=nofallback \
       --force-fallback-for perfetto \
       ${CROSS+--cross "$CROSS_FILE"} \
-      -D prefix=`pwd`/install \
+      -D prefix=$PWD/install \
       -D libdir=lib \
       -D buildtype=${BUILDTYPE:-debug} \
       -D build-tests=true \
@@ -101,7 +103,7 @@ fi
 
 
 uncollapsed_section_switch meson-test "meson: test"
-LC_ALL=C.UTF-8 meson test --num-processes ${FDO_CI_CONCURRENT:-4} --print-errorlogs ${MESON_TEST_ARGS}
+LC_ALL=C.UTF-8 meson test --num-processes "${FDO_CI_CONCURRENT:-4}" --print-errorlogs ${MESON_TEST_ARGS}
 if command -V mold &> /dev/null ; then
     mold --run ninja install
 else
index dab628a..53bfd6a 100755 (executable)
@@ -1,7 +1,8 @@
-#!/bin/sh
+#!/usr/bin/env bash
+# shellcheck disable=SC2086 # we want word splitting
 
-if [ "x$STRACEDIR" = "x" ]; then
-    STRACEDIR=meson-logs/strace/$(for i in $@; do basename -z -- $i; echo -n _; done).$$
+if [[ -z "$STRACEDIR" ]]; then
+    STRACEDIR=meson-logs/strace/$(for i in "$@"; do basename -z -- $i; echo -n _; done).$$
 fi
 
 mkdir -p $STRACEDIR
index 0a98e72..188df6f 100755 (executable)
@@ -1,4 +1,5 @@
-#!/bin/sh
+#!/usr/bin/env bash
+# shellcheck disable=SC2086 # we want word splitting
 
 set -ex
 
@@ -7,14 +8,14 @@ if [ -z "$GPU_VERSION" ]; then
    exit 1
 fi
 
-INSTALL=`pwd`/install
+INSTALL="$PWD/install"
 
 # Set up the driver environment.
-export LD_LIBRARY_PATH=`pwd`/install/lib/
+export LD_LIBRARY_PATH="$INSTALL/lib/"
 export EGL_PLATFORM=surfaceless
-export VK_ICD_FILENAMES=`pwd`/install/share/vulkan/icd.d/"$VK_DRIVER"_icd.${VK_CPU:-`uname -m`}.json
+export VK_ICD_FILENAMES="$INSTALL/share/vulkan/icd.d/${VK_DRIVER}_icd.${VK_CPU:-$(uname -m)}.json"
 
-RESULTS=`pwd`/${PIGLIT_RESULTS_DIR:-results}
+RESULTS=$PWD/${PIGLIT_RESULTS_DIR:-results}
 mkdir -p $RESULTS
 
 # Ensure Mesa Shader Cache resides on tmpfs.
@@ -42,8 +43,8 @@ if [ "$GALLIUM_DRIVER" = "virpipe" ]; then
     sleep 1
 fi
 
-if [ -n "$PIGLIT_FRACTION" -o -n "$CI_NODE_INDEX" ]; then
-   FRACTION=`expr ${PIGLIT_FRACTION:-1} \* ${CI_NODE_TOTAL:-1}`
+if [ -n "$PIGLIT_FRACTION" ] || [ -n "$CI_NODE_INDEX" ]; then
+    FRACTION=$((${PIGLIT_FRACTION:-1} * ${CI_NODE_TOTAL:-1}))
 PIGLIT_RUNNER_OPTIONS="$PIGLIT_RUNNER_OPTIONS --fraction $FRACTION"
 fi
 
index 5e0675d..941afb1 100755 (executable)
@@ -1,4 +1,6 @@
 #!/usr/bin/env bash
+# shellcheck disable=SC2035 # FIXME glob
+# shellcheck disable=SC2086 # we want word splitting
 
 set -ex
 
@@ -26,7 +28,7 @@ esac
 #PATH="/opt/wine-stable/bin/:$PATH" # WineHQ path
 
 # Avoid asking about Gecko or Mono instalation
-export WINEDLLOVERRIDES=mscoree=d;mshtml=d
+export WINEDLLOVERRIDES="mscoree=d;mshtml=d"  # FIXME: drop, not needed anymore? (wine dir is already created)
 
 # Set environment for DXVK.
 export DXVK_LOG_LEVEL="info"
@@ -40,20 +42,12 @@ export DXVK_STATE_CACHE=0
 # using a command wrapper. Hence, we will just set it when running the
 # command.
 export __LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$INSTALL/lib/"
-export VK_ICD_FILENAMES="$INSTALL/share/vulkan/icd.d/${VK_DRIVER}_icd.${VK_CPU:-`uname -m`}.json"
+export VK_ICD_FILENAMES="$INSTALL/share/vulkan/icd.d/${VK_DRIVER}_icd.${VK_CPU:-$(uname -m)}.json"
 
 # Sanity check to ensure that our environment is sufficient to make our tests
 # run against the Mesa built by CI, rather than any installed distro version.
 MESA_VERSION=$(head -1 "$INSTALL/VERSION" | sed 's/\./\\./g')
 
-print_red() {
-    RED='\033[0;31m'
-    NC='\033[0m' # No Color
-    printf "${RED}"
-    "$@"
-    printf "${NC}"
-}
-
 # wrapper to supress +x to avoid spamming the log
 quiet() {
     set +x
@@ -79,14 +73,14 @@ HANG_DETECTION_CMD=""
 
 # Set up the platform windowing system.
 
-if [ "x$EGL_PLATFORM" = "xsurfaceless" ]; then
+if [ "$EGL_PLATFORM" = "surfaceless" ]; then
     # Use the surfaceless EGL platform.
     export DISPLAY=
     export WAFFLE_PLATFORM="surfaceless_egl"
 
     SANITY_MESA_VERSION_CMD="$SANITY_MESA_VERSION_CMD --platform surfaceless_egl --api gles2"
 
-    if [ "x$GALLIUM_DRIVER" = "xvirpipe" ]; then
+    if [ "$GALLIUM_DRIVER" = "virpipe" ]; then
     # piglit is to use virpipe, and virgl_test_server llvmpipe
     export GALLIUM_DRIVER="$GALLIUM_DRIVER"
 
@@ -98,9 +92,9 @@ if [ "x$EGL_PLATFORM" = "xsurfaceless" ]; then
 
     sleep 1
     fi
-elif [ "x$PIGLIT_PLATFORM" = "xgbm" ]; then
+elif [ "$PIGLIT_PLATFORM" = "gbm" ]; then
     SANITY_MESA_VERSION_CMD="$SANITY_MESA_VERSION_CMD --platform gbm --api gl"
-elif [ "x$PIGLIT_PLATFORM" = "xmixed_glx_egl" ]; then
+elif [ "$PIGLIT_PLATFORM" = "mixed_glx_egl" ]; then
     # It is assumed that you have already brought up your X server before
     # calling this script.
     SANITY_MESA_VERSION_CMD="$SANITY_MESA_VERSION_CMD --platform glx --api gl"
@@ -115,6 +109,7 @@ if [ -n "$CI_NODE_INDEX" ]; then
     USE_CASELIST=1
 fi
 
+# shellcheck disable=SC2317
 replay_minio_upload_images() {
     find "$RESULTS/$__PREFIX" -type f -name "*.png" -printf "%P\n" \
         | while read -r line; do
@@ -167,7 +162,7 @@ PIGLIT_CMD="./piglit run -l verbose --timeout 300 -j${FDO_CI_CONCURRENT:-4} $PIG
 RUN_CMD="export LD_LIBRARY_PATH=$__LD_LIBRARY_PATH; $SANITY_MESA_VERSION_CMD && $HANG_DETECTION_CMD $PIGLIT_CMD"
 
 if [ "$RUN_CMD_WRAPPER" ]; then
-    RUN_CMD="set +e; $RUN_CMD_WRAPPER "$(/usr/bin/printf "%q" "$RUN_CMD")"; set -e"
+    RUN_CMD="set +e; $RUN_CMD_WRAPPER \"$(/usr/bin/printf "%q" "$RUN_CMD")\"; set -e"
 fi
 
 # The replayer doesn't do any size or checksum verification for the traces in
@@ -177,9 +172,8 @@ fi
 # run.
 rm -rf replayer-db
 
-eval $RUN_CMD
-
-if [ $? -ne 0 ]; then
+if ! eval $RUN_CMD;
+then
     printf "%s\n" "Found $(cat /tmp/version.txt), expected $MESA_VERSION"
 fi
 
@@ -217,7 +211,7 @@ find "$RESULTS"/summary -type f -name "*.html" -print0 \
 find "$RESULTS"/summary -type f -name "*.html" -print0 \
         | xargs -0 sed -i 's%<img src="file://%<img src="https://'"${PIGLIT_REPLAY_REFERENCE_IMAGES_BASE}"'/%g'
 
-quiet print_red echo "Failures in traces:"
+echo "Failures in traces:"
 cat $RESULTSFILE
-quiet print_red echo "Review the image changes and get the new checksums at: ${ARTIFACTS_BASE_URL}/results/summary/problems.html"
+error echo "Review the image changes and get the new checksums at: ${ARTIFACTS_BASE_URL}/results/summary/problems.html"
 exit 1
index 8592c85..8e3e823 100755 (executable)
@@ -1,4 +1,6 @@
 #!/usr/bin/env bash
+# shellcheck disable=SC2038 # TODO: rewrite the find
+# shellcheck disable=SC2086 # we want word splitting
 
 section_switch prepare-artifacts "artifacts: prepare"
 
index 4be356a..9691ccd 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 
-CHECKPATH=".gitlab-ci/container"  # TODO: expand to cover whole .gitlab-ci/
+CHECKPATH=".gitlab-ci"
 
 is_bash() {
     [[ $1 == *.sh ]] && return 0
index b066b3b..943d658 100644 (file)
@@ -1,4 +1,7 @@
 #!/usr/bin/env bash
+# shellcheck disable=SC2048
+# shellcheck disable=SC2086 # we want word splitting
+# shellcheck disable=SC2155 # mktemp usually not failing
 
 function x_off {
     if [[ "$-" == *"x"* ]]; then
index a21d499..8974fa2 100755 (executable)
@@ -1,8 +1,9 @@
-#!/bin/sh
+#!/usr/bin/env bash
+# shellcheck disable=SC2086 # we want word splitting
 
 set -ex
 
-if [ "x$VK_DRIVER" = "x" ]; then
+if [[ -z "$VK_DRIVER" ]]; then
     exit 1
 fi
 
@@ -21,14 +22,14 @@ export __LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$INSTALL/lib/"
 
 # Sanity check to ensure that our environment is sufficient to make our tests
 # run against the Mesa built by CI, rather than any installed distro version.
-MESA_VERSION=$(cat "$INSTALL/VERSION" | sed 's/\./\\./g')
+MESA_VERSION=$(sed 's/\./\\./g' "$INSTALL/VERSION")
 
 # Force the stdout and stderr streams to be unbuffered in python.
 export PYTHONUNBUFFERED=1
 
 # Set the Vulkan driver to use.
 export VK_ICD_FILENAMES="$INSTALL/share/vulkan/icd.d/${VK_DRIVER}_icd.x86_64.json"
-if [ ${VK_DRIVER} = "radeon" ]; then
+if [ "${VK_DRIVER}" = "radeon" ]; then
     # Disable vsync
     export MESA_VK_WSI_PRESENT_MODE=mailbox
     export vblank_mode=0
@@ -63,7 +64,7 @@ SANITY_MESA_VERSION_CMD="vulkaninfo"
 
 # Set up the Window System Interface (WSI)
 # TODO: Can we get away with GBM?
-if [ ${TEST_START_XORG:-0} -eq 1 ]; then
+if [ "${TEST_START_XORG:-0}" -eq 1 ]; then
     "$INSTALL"/common/start-x.sh "$INSTALL"
     export DISPLAY=:0
 fi
@@ -75,9 +76,8 @@ SANITY_MESA_VERSION_CMD="$SANITY_MESA_VERSION_CMD | tee /tmp/version.txt | grep
 RUN_CMD="export LD_LIBRARY_PATH=$__LD_LIBRARY_PATH; $SANITY_MESA_VERSION_CMD"
 
 set +e
-eval $RUN_CMD
-
-if [ $? -ne 0 ]; then
+if ! eval $RUN_CMD;
+then
     printf "%s\n" "Found $(cat /tmp/version.txt), expected $MESA_VERSION"
 fi
 set -e
index e508a80..c8c6fd7 100755 (executable)
@@ -1,8 +1,9 @@
-#!/bin/sh
+#!/usr/bin/env bash
+# shellcheck disable=SC2035 # FIXME glob
 
 set -ex
 
-if [ "x$VK_DRIVER" = "x" ]; then
+if [[ -z "$VK_DRIVER" ]]; then
     exit 1
 fi
 
@@ -19,7 +20,7 @@ export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$INSTALL/lib/:/vkd3d-proton-tests/x64/"
 
 # Sanity check to ensure that our environment is sufficient to make our tests
 # run against the Mesa built by CI, rather than any installed distro version.
-MESA_VERSION=$(cat "$INSTALL/VERSION" | sed 's/\./\\./g')
+MESA_VERSION=$(sed 's/\./\\./g' "$INSTALL/VERSION")
 
 # Set the Vulkan driver to use.
 export VK_ICD_FILENAMES="$INSTALL/share/vulkan/icd.d/${VK_DRIVER}_icd.x86_64.json"
@@ -29,14 +30,6 @@ export WINEDEBUG="-all"
 export WINEPREFIX="/vkd3d-proton-wine64"
 export WINEESYNC=1
 
-print_red() {
-    RED='\033[0;31m'
-    NC='\033[0m' # No Color
-    printf "${RED}"
-    "$@"
-    printf "${NC}"
-}
-
 # wrapper to supress +x to avoid spamming the log
 quiet() {
     set +x
@@ -45,9 +38,8 @@ quiet() {
 }
 
 set +e
-vulkaninfo | tee /tmp/version.txt | grep \"Mesa $MESA_VERSION\(\s\|$\)\"
-
-if [ $? -ne 0 ]; then
+if ! vulkaninfo | tee /tmp/version.txt | grep "\"Mesa $MESA_VERSION\(\s\|$\)\"";
+then
     printf "%s\n" "Found $(cat /tmp/version.txt), expected $MESA_VERSION"
 fi
 set -e
@@ -61,10 +53,9 @@ fi
 quiet printf "%s\n" "Running vkd3d-proton testsuite..."
 
 set +e
-/vkd3d-proton-tests/x64/bin/d3d12 > $RESULTS/vkd3d-proton.log
-
-if [ $? != 0 ]; then
-    quiet print_red printf "%s\n" "Failed, see vkd3d-proton.log!"
+if ! /vkd3d-proton-tests/x64/bin/d3d12 > "$RESULTS/vkd3d-proton.log";
+then
+    error printf "%s\n" "Failed, see vkd3d-proton.log!"
 
     # Collect all the failures
     VKD3D_PROTON_RESULTS="${VKD3D_PROTON_RESULTS:-vkd3d-proton-results}"
@@ -82,7 +73,7 @@ if [ $? != 0 ]; then
 
     # Make sure that the failures found in this run match the current expectation
     if ! diff -q ".gitlab-ci/vkd3d-proton/$VKD3D_PROTON_RESULTS.txt.baseline" "$RESULTSFILE"; then
-        quiet print_red printf "%s\n" "Changes found, see vkd3d-proton.log!"
+        error printf "%s\n" "Changes found, see vkd3d-proton.log!"
         quiet diff --color=always -u ".gitlab-ci/vkd3d-proton/$VKD3D_PROTON_RESULTS.txt.baseline" "$RESULTSFILE"
     fi