mirror of
https://github.com/kdave/btrfs-progs
synced 2024-12-31 18:52:05 +00:00
btrfs-progs: tests: add test case for shrunk device
Create a filesystem on a file backed loop block device, then shrink the file (and its loop block device), then make sure btrfs check can detect such shrunk device. Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
0a348d3c81
commit
192d436503
31
tests/fsck-tests/059-shrunk-device/test.sh
Executable file
31
tests/fsck-tests/059-shrunk-device/test.sh
Executable file
@ -0,0 +1,31 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Make sure "btrfs check" can detect device smaller than its total_bytes
|
||||
# in device item
|
||||
#
|
||||
|
||||
source "$TEST_TOP/common"
|
||||
|
||||
setup_root_helper
|
||||
|
||||
file="img"
|
||||
# Allocate an initial 1G file for testing.
|
||||
truncate -s0 "$file"
|
||||
truncate -s1g "$file"
|
||||
|
||||
dev=$(run_check_stdout $SUDO_HELPER losetup --find --show "$file")
|
||||
|
||||
run_check "$TOP/mkfs.btrfs" -f "$dev"
|
||||
|
||||
# The original device size from prepare_loopdevs is 2G.
|
||||
# Since the fs is empty, shrinking it to 996m will not cause any
|
||||
# lose of metadata.
|
||||
run_check $SUDO_HELPER losetup -d "$dev"
|
||||
truncate -s 996m "$file"
|
||||
dev=$(run_check_stdout $SUDO_HELPER losetup --find --show "$file")
|
||||
|
||||
run_mustfail "btrfs check should detect errors in device size" \
|
||||
"$TOP/btrfs" check "$dev"
|
||||
|
||||
losetup -d "$dev"
|
||||
rm -- "$file"
|
Loading…
Reference in New Issue
Block a user