btrfs-progs/tests/misc-tests/009-subvolume-sync-must-wait/test.sh
David Sterba 9957162313 btrfs-progs: tests: update or fix shell script coding style
Fix the following issues in the test suite:

- lack of quoting for variables
- declare function variables local when missing (prevent accidental
  overwrite of global variables)
- for variables with underscore in the name use plain "$VAR_NAME"
  instead of { } (unless necessary)
- minor style adjustments like moving quotes to the end of the same
  string

Signed-off-by: David Sterba <dsterba@suse.com>
2024-06-24 19:18:08 +02:00

54 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
#
# Verify that subvolume sync waits until the subvolume is cleaned
source "$TEST_TOP/common" || exit
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