Files
2026-10-10 10:37:53 +02:00

46 lines
1.6 KiB
Bash
Executable File

#!/usr/bin/env bash
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (C) 2026 Bryan Joshua Pedini
# tests/docker/run-e2e.sh - run the E2E suite in ONE distro container.
#
# usage: run-e2e.sh <label> <image>
# e.g. run-e2e.sh debian-12 debian:12
#
# The repository is mounted read-only at /work and tests/e2e/entrypoint.sh is run
# with bash inside <image>. SU_DISTRO=<label> tells the suite which distro it is
# on. Output is shown and also written to tests/docker/logs/<label>.log.
# Exit status is the container's (i.e. the suite's) exit status.
set -euo pipefail
prog=${0##*/}
if (($# != 2)); then
printf 'usage: %s <label> <image>\n' "$prog" >&2
exit 1
fi
label=$1 image=$2
if [[ ! $label =~ ^[A-Za-z0-9][A-Za-z0-9._-]*$ ]]; then
printf '%s: invalid label %q (allowed: letters, digits, . _ -)\n' "$prog" "$label" >&2
exit 1
fi
cd -- "$(dirname -- "${BASH_SOURCE[0]}")/../.." # repository root
if [[ ! -f tests/e2e/entrypoint.sh ]]; then
printf '%s: tests/e2e/entrypoint.sh not found in %s\n' "$prog" "$PWD" >&2
exit 1
fi
log_dir=tests/docker/logs
log=$log_dir/$label.log
mkdir -p -- "$log_dir"
printf '== e2e %s (%s) %s ==\n' "$label" "$image" "$(date -u '+%Y-%m-%dT%H:%M:%SZ')" | tee -- "$log"
status=0
docker run --rm -i \
-v "$PWD":/work:ro -w /work \
-e LC_ALL=C -e DEBIAN_FRONTEND=noninteractive -e SU_DISTRO="$label" \
"$image" bash tests/e2e/entrypoint.sh 2>&1 | tee -a -- "$log" || status=${PIPESTATUS[0]}
if ((status == 0)); then result=PASS; else result=FAIL; fi
printf '== e2e %s: %s (exit %d), log: %s ==\n' "$label" "$result" "$status" "$log" | tee -a -- "$log"
exit "$status"