1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
#!/bin/bash
# convenience script for development to run integration tests
# runs test-container.sh in a container
set -e
export CONTAINER="${CONTAINER:=$1}"
export CONTAINER="${CONTAINER:=fedora}"
export TESTS="${TESTS:=$2}"
export TEST_RUN_ID="${TEST_RUN_ID:=id}"
# if registry is not specified, add our registry
if [[ $CONTAINER != *"/"* ]]; then
CONTAINER="ghcr.io/dracut-ng/$CONTAINER"
fi
# if label is not specified, add latest label
if [[ $CONTAINER != *":"* ]]; then
CONTAINER="$CONTAINER:latest"
fi
# add architecture tag, see commit d8ff139
ARCH="${ARCH-$(uname -m)}"
case "$ARCH" in
aarch64 | arm64)
CONTAINER="$CONTAINER-arm"
;;
amd64 | i?86 | x86_64)
CONTAINER="$CONTAINER-amd"
;;
esac
echo "Running in a container from $CONTAINER"
if command -v podman &> /dev/null; then
PODMAN=podman
else
PODMAN=docker
fi
# Compute wildcards for TESTS variable (e.g. '1*')
# shellcheck disable=SC1001
[ -n "$TESTS" ] && TESTS=$(
cd test
for T in ${TESTS}; do find . -depth -type d -name "TEST-*${T}*" -exec echo {} \; | cut -d\- -f2 | tr '\n' ' '; done
)
# clear previous test run
TARGETS='clean all install check' "$PODMAN" run --rm -it \
--device=/dev/kvm --privileged \
-e V -e TESTS -e TEST_RUN_ID -e TARGETS -e MAKEFLAGS \
-v "$PWD"/:/z \
"$CONTAINER" \
/z/test/test-container.sh
|