File: test.sh

package info (click to toggle)
btrfs-progs 6.17-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 20,596 kB
  • sloc: ansic: 127,198; sh: 7,836; python: 1,385; makefile: 900; asm: 296
file content (36 lines) | stat: -rwxr-xr-x 890 bytes parent folder | download | duplicates (3)
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
28
29
30
31
32
33
34
35
36
#!/bin/bash
#
# Test that if a device is missing for a mounted filesystem, btrfs fi show will
# show which device exactly is missing.

source "$TEST_TOP/common" || exit

check_prereq mkfs.btrfs
check_prereq btrfs

setup_root_helper
setup_loopdevs 2
prepare_loopdevs

dev1=${loopdevs[1]}
dev2=${loopdevs[2]}

run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f -d raid1 "${loopdevs[@]}"

# Move the device, changing its path, simulating the device being missing
run_check $SUDO_HELPER mv "$dev2" /dev/loop-non-existent

cond_wait_for_loopdevs
run_check $SUDO_HELPER mount -o degraded "$dev1" "$TEST_MNT"

if ! run_check_stdout $SUDO_HELPER "$TOP/btrfs" filesystem show "$TEST_MNT" | \
	grep -q -e "devid[[:space:]]\+2.*MISSING"; then

	_fail "didn't find exact missing device"
fi

run_check $SUDO_HELPER mv /dev/loop-non-existent "$dev2"

run_check $SUDO_HELPER umount "$TEST_MNT"

cleanup_loopdevs