File: test.sh

package info (click to toggle)
btrfs-progs 6.2-1%2Bdeb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 17,244 kB
  • sloc: ansic: 114,376; sh: 9,576; python: 1,242; makefile: 820
file content (40 lines) | stat: -rwxr-xr-x 1,201 bytes parent folder | download
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
37
38
39
40
#!/bin/bash
# Detect if subvolume deletion fails when it's part of send

source "$TEST_TOP/common"

check_prereq mkfs.btrfs
check_prereq btrfs

prepare_test_dev 4G

run_check_mkfs_test_dev
run_check_mount_test_dev

run_check $SUDO_HELPER "$TOP/btrfs" subvolume create "$TEST_MNT/subv1"
# Generate 2.7G of data to send, should be slow enough to let the subvolume
# deletion catch send in progress
for i in `seq 10`; do
	run_check $SUDO_HELPER dd if=/dev/zero of="$TEST_MNT/subv1/file$i" bs=50M count="$i"
done
run_check $SUDO_HELPER "$TOP/btrfs" subvolume snapshot -r "$TEST_MNT/subv1" "$TEST_MNT/snap1"

stream="stream$RANDOM.out"
_mktemp_local "$stream"
run_check "$TOP/btrfs" filesystem sync "$TEST_MNT"
# Output to file must be slow
run_check $SUDO_HELPER "$TOP/btrfs" send -f "$stream" "$TEST_MNT/snap1" &
# Give send time to start
run_check sleep 2
# If this fails, send was fast
ps faux | run_check grep "btrfs send -f $stream"

# Fail if send is still in progress, may not work on a really fast device
run_mustfail "deleting default subvolume by path succeeded" \
	$SUDO_HELPER "$TOP/btrfs" subvolume delete "$TEST_MNT/snap1"

# Wait for send
wait
rm -f -- "$stream"

run_check_umount_test_dev