File: test.sh

package info (click to toggle)
btrfs-progs 6.17.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 20,612 kB
  • sloc: ansic: 127,282; sh: 7,915; python: 1,384; makefile: 900; asm: 296
file content (89 lines) | stat: -rwxr-xr-x 2,776 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/bin/bash
# Create filesystem with multiple block groups and check commands that are
# supposed to warn about that:
# - device add
# - device delete
# - device usage
# - balance pause
# - balance cancel
# - filesystem df
#
# Tested for separate data/metadata and mixed

source "$TEST_TOP/common" || exit

check_prereq mkfs.btrfs
check_prereq btrfs

setup_root_helper
setup_loopdevs 4
prepare_loopdevs
dev1=${loopdevs[1]}
TEST_DEV=$dev1
msg="Multiple block group profiles detected"

test_run_commands() {
	run_check "$TOP/btrfs" filesystem usage "$TEST_MNT"
	# Report: filesystem df
	if ! run_check_stdout "$TOP/btrfs" filesystem df "$TEST_MNT" | \
		grep -q "$msg"; then
		_fail "filesystem df does not warn"
	fi
	# Report: device delete
	if ! run_check_stdout $SUDO_HELPER "$TOP/btrfs" device delete "${loopdevs[4]}" "$TEST_MNT" | \
		grep -q "$msg"; then
		_fail "device delete does not warn"
	fi
	# Report: device add
	if ! run_check_stdout $SUDO_HELPER "$TOP/btrfs" device add -f "${loopdevs[4]}" "$TEST_MNT" | \
		grep -q "$msg"; then
		_fail "device add does not warn"
	fi
	# Report: device usage
	if ! run_check_stdout $SUDO_HELPER "$TOP/btrfs" device usage "$TEST_MNT" | \
		grep -q "$msg"; then
		_fail "device usage does not warn"
	fi
	# Balance status
	out=$(run_mayfail_stdout $SUDO_HELPER "$TOP/btrfs" balance pause "$TEST_MNT")
	_log "$out"
	if ! echo "$out" | grep -q "$msg"; then
		_fail "balance pause does not warn"
	fi

	out=$(run_mayfail_stdout $SUDO_HELPER "$TOP/btrfs" balance cancel "$TEST_MNT")
	_log "$out"
	if ! echo "$out" | grep -q "$msg"; then
		_fail "balance cancel does not warn"
	fi
}

# Data and metadata
run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f -d single -m single "${loopdevs[@]}"
run_check_mount_test_dev
run_check "$TOP/btrfs" filesystem usage "$TEST_MNT"
for i in $(seq 10); do
	run_check $SUDO_HELPER dd if=/dev/zero of="$TEST_MNT/file$i" bs=100M count=1 status=none
done
# Create filesystem with single and RAID1 profiles
run_check $SUDO_HELPER "$TOP/btrfs" balance start -dconvert=raid1,limit=1 "$TEST_MNT"

test_run_commands
run_check_umount_test_dev

# The same, with mixed profiles
run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f --mixed -d single -m single "${loopdevs[@]}"
run_check_mount_test_dev
run_check "$TOP/btrfs" filesystem usage "$TEST_MNT"
# Create 1 and a half of 1G chunks
for i in $(seq 14); do
	run_check $SUDO_HELPER dd if=/dev/zero of="$TEST_MNT/file$i" bs=100M count=1 status=none
done
# Create filesystem with single and RAID1 profiles, the limit=1 trick does not work
# so use the usage filter to convert about half of the filesystem
run_check $SUDO_HELPER "$TOP/btrfs" balance start -mconvert=raid1,usage=50 -dconvert=raid1,usage=50 "$TEST_MNT"

test_run_commands
run_check_umount_test_dev

cleanup_loopdevs