lvm2/tests/gating/main.sh
2026-06-03 17:12:27 +02:00

93 lines
2.4 KiB
Bash
Executable File

#!/bin/bash -ex
BRANCH="test-rhel-10.3"
TESTSUITE_OUT_FILE="lvm2-testsuite.out"
free
df
lsblk
for service in \
lvm2-lvmpolld.service \
lvm2-lvmpolld.socket \
lvm2-monitor.service \
dm-event.socket \
dm-event.service \
"lvm2-pvscan@.service" \
; \
do
systemctl stop "$service" || :
systemctl mask "$service" || :
done
sed -i 's/monitoring *= *.*/monitoring = 0/' /etc/lvm/lvm.conf || :
# TODO: change the branch depending on the OS major.minor version
# Install lvm2 tests from upstream branch:
git clone --depth=1 --branch "$BRANCH" -- "https://gitlab.com/lvmteam/lvm2.git" lvm2-test
# Make the test suite:
cd lvm2-test
./configure
make -C test
# NOTE: testsuite works either when installed OR with make check
make -C test install
# NOTE: clean up to remove built binaries, just in case!
make clean
RUNNER="/usr/bin/lvm2-testsuite"
TEST_PATH="/usr/share/lvm2-testsuite"
[[ -x "$RUNNER" ]]
[[ -d "$TEST_PATH" ]]
chmod 755 ci/tests.sh
chmod 755 ci/ignore.sh
lvm2_tests="$(ci/tests.sh)"
if [[ -z $lvm2_tests ]]; then
echo "ERROR: Found no tests to run" >&2
exit 1
fi
echo "$lvm2_tests"
flavours="$(cd "$TEST_PATH/lib" && ls -1 flavour-udev-* | grep -v "lvmlockd-dlm\|lvmlockd-sanlock" | grep "vanilla" | sed 's/^flavour-\(.*\)/\1/')"
if [[ -z $flavours ]]; then
echo "ERROR: Found no flavours to run" >&2
exit 1
fi
echo "$flavours"
# Run testsuite in RAM disk:
mkdir -p /dev/shm/lvm2-slave
export LVM_TEST_DIR=/dev/shm/lvm2-slave
mount -o remount,dev /dev/shm
for test_script in $lvm2_tests; do
echo "################################################################################" > /dev/console
echo "# Running test $test_script" > /dev/console
echo "################################################################################" > /dev/console
for flavour in $flavours; do
# TODO: Repeat failure if ???
"$RUNNER" --batch --continue --flavours "$flavour" --only "$test_script" 2>&1 | tee -a "$TESTSUITE_OUT_FILE"
RESULT="${PIPESTATUS[0]}"
if [[ $RESULT -ne 0 ]]; then
tmt-file-submit -l "${flavour}:${test_script//\//_}.txt"
fi
done
done
tmt-file-submit -l "journal"
tmt-file-submit -l "list"
tmt-file-submit -l "$TESTSUITE_OUT_FILE"
echo -e "\nFailures:"
grep -v "\(passed\|skipped\|warnings\)$" list || :
echo -e "\nSummary:"
cut -d" " -f2 "list" | sort | uniq -c
echo -e "\nFailures to check:"
if ci/ignore.sh < "list" | grep -v "^[[:space:]]*$"; then
exit 1
fi