Files
qdl/tests/test_flashmap.sh
T
Igor Opaniuk 21c7f22183 tests: give each integration test its own fixture directory
test_flashmap.sh and test_vip_generation.sh both wrote fixtures to
${builddir}/tests/data, and meson runs the two tests in parallel.
Their generate_flat_build.sh invocations therefore raced on dd, cp
and the final `zip flashmap.zip ...`, while test_vip_generation.sh's
EXIT trap could rm -rf the directory out from under its peer.

The race was masked while zip took several seconds on the unshrunk
1 GB fixtures; once fixture generation dropped to ~30 ms it started
firing on the macos-14 arm64 runner as zip exit status 18 ("could
not open a specified file to read").

Point each test at its own directory (data-flashmap / data-vip) so
they no longer share mutable state.

Signed-off-by: Igor Opaniuk <igor.opaniuk@oss.qualcomm.com>
2026-05-11 10:15:23 -05:00

82 lines
1.4 KiB
Bash

#!/bin/bash
# SPDX-License-Identifier: BSD-3-Clause
set -e
SCRIPT_PATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
while [[ $# -gt 0 ]]; do
case "$1" in
--builddir)
builddir="$2"
shift 2
;;
*)
echo "Unknown option: $1" >&2
exit 1
;;
esac
done
if [[ -z "${builddir}" ]]; then
echo "Error: --builddir is required." >&2
exit 1
fi
FLAT_BUILD=${SCRIPT_PATH}/data
QDL_PATH=$builddir
uname_out="$(uname -s)"
case "${uname_out}" in
Linux*|Darwin*)
QDL=qdl
;;
CYGWIN*|MINGW*|MSYS*)
QDL=qdl.exe
;;
*)
exit 1
;;
esac
DATA_SRC=${SCRIPT_PATH}/data
FLAT_BUILD=${builddir}/tests/data-flashmap
${DATA_SRC}/generate_flat_build.sh "${FLAT_BUILD}" >&2
cd $FLAT_BUILD
echo "1..2"
n=1
fail=0
run_test() {
desc="$1"
shift
out="$(mktemp)"
err="$(mktemp)"
if "$@" >"$out" 2>"$err" ; then
echo "ok $n - $desc"
else
rc=$?
echo "not ok $n - $desc"
echo "# exit code: $rc"
sed 's/^/# stdout: /' "$out"
sed 's/^/# stderr: /' "$err"
fail=1
fi
n=$((n + 1))
}
#echo "####### Flashing flashmap.json"
run_test "flashing flashmap.json" ${QDL_PATH}/${QDL} --dry-run flash flashmap.json
#echo "####### Flashing flashmap.zip"
run_test "flashing flashmap.zip" ${QDL_PATH}/${QDL} --dry-run flash flashmap.zip
exit $fail