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 (55 lines) | stat: -rwxr-xr-x 1,448 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
# Test parallel reset of zones.
# Needs kernel modules: null_blk, configfs and at least 2G of free memory for
# the devices

source "$TEST_TOP/common"

setup_root_helper
prepare_test_dev

if ! check_min_kernel_version 5.12; then
	_not_run "zoned tests need kernel 5.12 and newer"
fi

nullb="$TEST_TOP/nullb"
# Create 128M devices with 4M zones, 32 of them
size=128
zone=4
# More than 10 may fail
count=10

declare -a devices
declare -a names

run_check $SUDO_HELPER "$nullb" setup
if [ $? != 0 ]; then
	_not_run "cannot setup nullb environment for zoned devices"
fi

# Record any other pre-existing devices in case creation fails
run_check $SUDO_HELPER "$nullb" ls

for i in `seq $count`; do
	# Last line has the name of the device node path
	out=$(run_check_stdout $SUDO_HELPER "$nullb" create -s "$size" -z "$zone")
	if [ $? != 0 ]; then
		_fail "cannot create nullb zoned device $i"
	fi
	devices[$i]=$(echo "$out" | tail -n 1)
	names[$i]=$(basename "${devices[$i]}")
done

run_check $SUDO_HELPER "$nullb" ls

TEST_DEV="${devices[1]}"
# Use single as it's supported on more kernels
run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -d single -m single "${devices[@]}"
run_check_mount_test_dev
run_check $SUDO_HELPER dd if=/dev/zero of="$TEST_MNT"/file bs=1M count=1
run_check $SUDO_HELPER "$TOP/btrfs" filesystem usage -T "$TEST_MNT"
run_check_umount_test_dev

for i in `seq $count`; do
	run_check $SUDO_HELPER "$nullb" rm "${names[$i]}"
done