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 (53 lines) | stat: -rwxr-xr-x 1,243 bytes parent folder | download | duplicates (2)
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
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
#
# Verify that subvolume sync waits until the subvolume is cleaned

source "$TEST_TOP/common"

check_prereq mkfs.btrfs
check_prereq btrfs

setup_root_helper

prepare_test_dev

run_check_mkfs_test_dev
run_check_mount_test_dev
run_check $SUDO_HELPER chmod a+rw "$TEST_MNT"

cd "$TEST_MNT"

for i in `seq 5`; do
	run_check dd if=/dev/zero of=file$i bs=1M count=10
done

for sn in `seq 4`;do
	run_check $SUDO_HELPER "$TOP/btrfs" subvolume snapshot . snap$sn
	for i in `seq 10`; do
		run_check dd if=/dev/zero of="snap$sn/file$i" bs=1M count=10
	done
done

run_check $SUDO_HELPER "$TOP/btrfs" subvolume list .
run_check $SUDO_HELPER "$TOP/btrfs" subvolume list -d .

idtodel=$(_get_subvolid snap3)

# delete, sync after some time
run_check $SUDO_HELPER "$TOP/btrfs" subvolume delete -c snap3
{ sleep 5; run_check "$TOP/btrfs" filesystem sync "$TEST_MNT"; } &

run_check $SUDO_HELPER "$TOP/btrfs" subvolume sync . "$idtodel"

if run_check_stdout $SUDO_HELPER "$TOP/btrfs" subvolume list -d . |
		grep -q "ID $idtodel.*DELETED"; then
	_fail "sync did not wait for the subvolume cleanup"
fi

run_check "$TOP/btrfs" filesystem sync "$TEST_MNT"
run_check $SUDO_HELPER "$TOP/btrfs" subvolume list -d .

wait
cd ..

run_check_umount_test_dev