btrfs-progs: tests: fix shellcheck reports in cli-tests

- variable quoting
- cd error handling
- `` to $()
- command output instead of command (008-subvolume-get-set-default)

Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2024-06-18 00:11:11 +02:00
parent 7535c35128
commit 410d82d7b1
6 changed files with 13 additions and 13 deletions

View File

@ -6,7 +6,7 @@ source "$TEST_TOP/common" || exit
check_prereq btrfs
# returns 1
run_mayfail $TOP/btrfs || true
run_mayfail "$TOP/btrfs" || true
run_check "$TOP/btrfs" version
run_check "$TOP/btrfs" version --
run_check "$TOP/btrfs" help

View File

@ -13,7 +13,7 @@ prepare_test_dev
run_check_mkfs_test_dev
run_check_mount_test_dev
here=`pwd`
here=$(pwd)
cd "$TEST_MNT" || _fail "cannot chdir to TEST_MNT"
run_check $SUDO_HELPER "$TOP/btrfs" subvolume create subv-parent

View File

@ -13,14 +13,14 @@ check_default_id()
{
id=$(run_check_stdout $SUDO_HELPER "$TOP/btrfs" subvolume get-default .) \
|| { echo "$id"; exit 1; }
if $(echo "$id" | grep -vq "ID $1"); then
if echo "$id" | grep -vq "ID $1"; then
_fail "subvolume get-default: default id is not $1, but $id"
fi
}
run_check_mkfs_test_dev
run_check_mount_test_dev
cd "$TEST_MNT"
cd "$TEST_MNT" || _fail "Cannot cd into TEST_MNT $TEST_MNT"
check_default_id 5

View File

@ -62,8 +62,8 @@ test_run_commands() {
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
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"
@ -76,8 +76,8 @@ run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f --mixed -d single -m single "${loopd
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
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

View File

@ -63,7 +63,7 @@ test_raid1()
set -- $i
IFS=$OLDIFS
run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f -d"$1" ${loopdevs[@]}
run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f -d"$1" "${loopdevs[@]}"
run_check_mount_test_dev
vars=($(report_numbers))
data_chunk_size=${vars[1]}
@ -87,7 +87,7 @@ test_raid0()
local used_on_dev
local data_ratio
run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f -draid0 ${loopdevs[@]}
run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f -draid0 "${loopdevs[@]}"
run_check_mount_test_dev
vars=($(report_numbers))
data_chunk_size=${vars[1]}
@ -118,7 +118,7 @@ test_raid56()
set -- $i
IFS=$OLDIFS
run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f -d"$1" ${loopdevs[@]}
run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f -d"$1" "${loopdevs[@]}"
run_check_mount_test_dev
vars=($(report_numbers))
data_chunk_size=${vars[1]}

View File

@ -36,11 +36,11 @@ fi
# Set the limits by command
here=`pwd`
cd "$sysfs/devinfo"
cd "$sysfs/devinfo" || _fail "Cannot cd to $sysfs/devinfo"
for i in *; do
run_check $SUDO_HELPER "$TOP/btrfs" scrub limit -d "$i" -l 20m "$TEST_MNT"
done
cd "$here"
cd "$here" || _fail "Cannot cd to $here"
run_check "$TOP/btrfs" scrub limit "$TEST_MNT"
# Set limits for all devices