diff --git a/config/core/rootfs-configs.yaml b/config/core/rootfs-configs.yaml index 375a2e4a92..3ad2b970e3 100644 --- a/config/core/rootfs-configs.yaml +++ b/config/core/rootfs-configs.yaml @@ -86,6 +86,7 @@ rootfs_configs: - misc_packages - package_management - misc_directories + test_overlay: "overlays/blktests" bookworm-cros-ec: diff --git a/config/rootfs/debos/overlays/blktests/usr/bin/run-blktests.sh b/config/rootfs/debos/overlays/blktests/usr/bin/run-blktests.sh new file mode 100755 index 0000000000..f33e4b8353 --- /dev/null +++ b/config/rootfs/debos/overlays/blktests/usr/bin/run-blktests.sh @@ -0,0 +1,42 @@ +#!/bin/bash +set -euo pipefail +set -x + +TEST_GROUP="${1:-}" +TEST_DEV="${2:-}" + +if [ -z "$TEST_GROUP" ] || [ -z "$TEST_DEV" ]; then + echo "Usage: $0 " + exit 1 +fi + +LOOPBACK_REQUIRED=false +LOOPDEV="" +LOOPFILE="" + +if [ "$TEST_DEV" = "loop" ]; then + LOOPBACK_REQUIRED=true +fi + +cleanup() { + if [ "$LOOPBACK_REQUIRED" = true ] && [ -n "${LOOPDEV:-}" ]; then + losetup -d "$LOOPDEV" || true + fi + [ -n "${LOOPFILE:-}" ] && rm -f "$LOOPFILE" +} +trap cleanup EXIT + +if [ "$LOOPBACK_REQUIRED" = true ]; then + LOOPFILE=$(mktemp /tmp/loopdisk.XXXX.img) + truncate -s 1G "$LOOPFILE" + LOOPDEV=$(losetup -f --show "$LOOPFILE") + echo "Created loop device: $LOOPDEV" + + mkfs.ext4 -F "$LOOPDEV" > /dev/null + TEST_DEV="$LOOPDEV" +fi + +mkdir -p /tmp/blktests-results +cd /usr/local/blktests/ +echo "TEST_DEVS=('$TEST_DEV')" > config +./check -c config "$TEST_GROUP" --output /tmp/blktests-results diff --git a/config/runtime/tests/blktests.jinja2 b/config/runtime/tests/blktests.jinja2 new file mode 100644 index 0000000000..8bc89868a1 --- /dev/null +++ b/config/runtime/tests/blktests.jinja2 @@ -0,0 +1,19 @@ +- test: + timeout: + minutes: {{ job_timeout|default('20') }} + definitions: + - repository: + metadata: + format: Lava-Test Test Definition 1.0 + name: {{ node.name }} + description: "blktests" + os: + - debian + scope: + - functional + run: + steps: + - /usr/bin/run-blktests.sh "{{ test_group }}" "{{ test_device }}" + from: inline + name: {{ node.name }} + path: inline/{{ node.name }}.yaml