Skip to content

Commit b04340b

Browse files
committed
rootfs: overlays: blktests: add blktests script
Add blktests test script. Signed-off-by: Vignesh Raman <[email protected]>
1 parent 15def67 commit b04340b

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
TEST_GROUP="${1:-}"
5+
TEST_DEV="${2:-}"
6+
7+
if [ -z "$TEST_GROUP" ] || [ -z "$TEST_DEV" ]; then
8+
echo "Usage: $0 <TEST_GROUP> <TEST_DEV>"
9+
exit 1
10+
fi
11+
12+
LOOPBACK_REQUIRED=false
13+
LOOPDEV=""
14+
LOOPFILE=""
15+
16+
if [[ "$TEST_DEV" =~ ^/dev/loop[0-9]+$ ]]; then
17+
LOOPBACK_REQUIRED=true
18+
fi
19+
20+
cleanup() {
21+
if [ "$LOOPBACK_REQUIRED" = true ] && [ -n "$LOOPDEV" ]; then
22+
losetup -d "$LOOPDEV" || true
23+
rm -f "$LOOPFILE"
24+
fi
25+
}
26+
trap cleanup EXIT
27+
28+
# Remove this after kernel-ci switches to upstream blktests
29+
BLKTESTS_URL="https://github.com/linux-blktests/blktests.git"
30+
BLKTESTS_SHA=8c610b5b
31+
git clone -b ${BLKTESTS_SHA} ${BLKTESTS_URL}
32+
cd blktests
33+
34+
if [ "$LOOPBACK_REQUIRED" = true ]; then
35+
LOOPFILE=$(mktemp /tmp/loopdisk.XXXX.img)
36+
truncate -s 1G "$LOOPFILE"
37+
LOOPDEV=$(losetup -f --show "$LOOPFILE")
38+
echo "Created loop device: $LOOPDEV"
39+
TEST_DEV="$LOOPDEV"
40+
fi
41+
42+
echo "TEST_DEVS=('$TEST_DEV')" > config
43+
44+
mkdir -p /tmp/blktests-results
45+
./check -c config "$TEST_GROUP" --output /tmp/blktests-results

0 commit comments

Comments
 (0)