Skip to content

Commit fc43306

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

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

config/core/rootfs-configs.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ rootfs_configs:
8686
- misc_packages
8787
- package_management
8888
- misc_directories
89+
test_overlay: "overlays/blktests"
8990

9091

9192
bookworm-cros-ec:
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
set -x
4+
5+
TEST_GROUP="${1:-}"
6+
TEST_DEV="${2:-}"
7+
8+
if [ -z "$TEST_GROUP" ] || [ -z "$TEST_DEV" ]; then
9+
echo "Usage: $0 <TEST_GROUP> <TEST_DEV|loop>"
10+
exit 1
11+
fi
12+
13+
LOOPBACK_REQUIRED=false
14+
LOOPDEV=""
15+
LOOPFILE=""
16+
17+
if [ "$TEST_DEV" = "loop" ]; then
18+
LOOPBACK_REQUIRED=true
19+
fi
20+
21+
cleanup() {
22+
if [ "$LOOPBACK_REQUIRED" = true ] && [ -n "${LOOPDEV:-}" ]; then
23+
losetup -d "$LOOPDEV" || true
24+
fi
25+
[ -n "${LOOPFILE:-}" ] && rm -f "$LOOPFILE"
26+
}
27+
trap cleanup EXIT
28+
29+
if [ "$LOOPBACK_REQUIRED" = true ]; then
30+
LOOPFILE=$(mktemp /tmp/loopdisk.XXXX.img)
31+
truncate -s 1G "$LOOPFILE"
32+
LOOPDEV=$(losetup -f --show "$LOOPFILE")
33+
echo "Created loop device: $LOOPDEV"
34+
35+
mkfs.ext4 -F "$LOOPDEV" > /dev/null
36+
TEST_DEV="$LOOPDEV"
37+
fi
38+
39+
mkdir -p /tmp/blktests-results
40+
cd /usr/local/blktests/
41+
echo "TEST_DEVS=('$TEST_DEV')" > config
42+
./check -c config "$TEST_GROUP" --output /tmp/blktests-results

0 commit comments

Comments
 (0)