summaryrefslogtreecommitdiff
path: root/tests/mkfs-tests/006-partitioned-loopdev/test.sh
blob: 7c9fb82925bb1d6b81dfe150a09aaec6efcc10e5 (plain)
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
#!/bin/bash
# recognize partitioned loop devices

source $TOP/tests/common

check_prereq mkfs.btrfs
check_prereq btrfs-show-super

setup_root_helper

run_check truncate -s0 img
chmod a+w img
cp partition-1g-1g img
run_check truncate -s2g img

loopdev=$(run_check_stdout $SUDO_HELPER losetup --partscan --find --show img)
base=$(basename $loopdev)

# expect partitions named like loop0p1 etc
for looppart in $(ls /dev/$base?*); do
	run_check $SUDO_HELPER $TOP/mkfs.btrfs -f $looppart
	run_check $TOP/btrfs-show-super $looppart
done

# cleanup
run_check $SUDO_HELPER losetup -d $loopdev
run_check truncate -s0 img