diff --git a/tests/cli-tests/012-fi-du-recursion/test.sh b/tests/cli-tests/012-fi-du-recursion/test.sh index 5de3ab1d..9b734043 100755 --- a/tests/cli-tests/012-fi-du-recursion/test.sh +++ b/tests/cli-tests/012-fi-du-recursion/test.sh @@ -20,7 +20,7 @@ _mktemp_local img2 1G run_check $SUDO_HELPER mkdir -p "$TEST_MNT"/mnt2 run_check $SUDO_HELPER dd if=/dev/zero bs=1M count=10 of="$TEST_MNT"/mnt2/hiddenfile -run_check $SUDO_HELPER "$TOP"/mkfs.btrfs -f img2 +run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f img2 run_check $SUDO_HELPER mount -o loop img2 "$TEST_MNT"/mnt2 run_check $SUDO_HELPER dd if=/dev/zero bs=1M count=10 of="$TEST_MNT"/mnt2/file21 run_check $SUDO_HELPER dd if=/dev/zero bs=1M count=10 of="$TEST_MNT"/mnt2/file22 diff --git a/tests/cli-tests/016-btrfs-fi-usage/test.sh b/tests/cli-tests/016-btrfs-fi-usage/test.sh index f3a6f1ac..ff1f9788 100755 --- a/tests/cli-tests/016-btrfs-fi-usage/test.sh +++ b/tests/cli-tests/016-btrfs-fi-usage/test.sh @@ -63,14 +63,14 @@ 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]} used_on_dev=${vars[2]} data_ratio=${vars[0]} - [[ $used_on_dev -eq $data_chunk_size ]] || + [[ "$used_on_dev" -eq "$data_chunk_size" ]] || _fail "$1 inconsistent chunk/device usage. Chunk: $data_chunk_size Device: $used_on_dev" [[ "$data_ratio" = "$2" ]] || @@ -95,10 +95,10 @@ test_raid0() data_ratio=${vars[0]} # Divide by 4 since 4 loopp devices are setup - [[ $used_on_dev -eq $(($data_chunk_size / 4)) ]] || + [[ "$used_on_dev" -eq $(($data_chunk_size / 4)) ]] || _fail "raid0 inconsistent chunk/device usage. Chunk: $data_chunk_size Device: $used_on_dev" - [[ $data_ratio = "1.00" ]] || + [[ "$data_ratio" = "1.00" ]] || _fail "raid0: Unexpected data ratio: $data_ratio (must be 1.5)" run_check_umount_test_dev } @@ -118,17 +118,17 @@ 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]} used_on_dev=${vars[2]} data_ratio=${vars[0]} - [[ $used_on_dev -eq $(($data_chunk_size / $3)) ]] || + [[ "$used_on_dev" -eq $(($data_chunk_size / $3)) ]] || _fail "$i inconsistent chunk/device usage. Chunk: $data_chunk_size Device: $used_on_dev" - [[ $data_ratio = "$2" ]] || + [[ "$data_ratio" = "$2" ]] || _fail "$1: Unexpected data ratio: $data_ratio (must be $2)" run_check_umount_test_dev diff --git a/tests/cli-tests/017-fi-show-missing/test.sh b/tests/cli-tests/017-fi-show-missing/test.sh index 653bde32..087415dd 100755 --- a/tests/cli-tests/017-fi-show-missing/test.sh +++ b/tests/cli-tests/017-fi-show-missing/test.sh @@ -21,7 +21,7 @@ run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f -d raid1 "${loopdevs[@]}" run_check $SUDO_HELPER mv "$dev2" /dev/loop-non-existent cond_wait_for_loopdevs -run_check $SUDO_HELPER mount -o degraded $dev1 $TEST_MNT +run_check $SUDO_HELPER mount -o degraded "$dev1" "$TEST_MNT" if ! run_check_stdout $SUDO_HELPER "$TOP/btrfs" filesystem show "$TEST_MNT" | \ grep -q -e "devid[[:space:]]\+2.*MISSING"; then diff --git a/tests/common b/tests/common index 7a23f6dd..30a3201e 100644 --- a/tests/common +++ b/tests/common @@ -739,9 +739,9 @@ _get_subvolid() DATASET_SIZE=50 generate_dataset() { + local dataset_type="$1" + local dirpath="$TEST_MNT/$dataset_type" - dataset_type="$1" - dirpath=$TEST_MNT/$dataset_type run_check $SUDO_HELPER mkdir -p "$dirpath" case "$dataset_type" in @@ -843,7 +843,7 @@ setup_loopdevs() # create all loop devices from a given loopdev environment prepare_loopdevs() { - for i in `seq $nloopdevs`; do + for i in `seq "$nloopdevs"`; do touch "$loopdev_prefix$i" chmod a+rw "$loopdev_prefix$i" truncate -s0 "$loopdev_prefix$i" @@ -921,14 +921,14 @@ prepare_nullbdevs() # Record any other pre-existing devices in case creation fails run_check $SUDO_HELPER "$nullb" ls - for i in `seq ${nullb_count}`; do + for i in `seq "$nullb_count"`; do # Last line has the name of the device node path - out=$(run_check_stdout $SUDO_HELPER "$nullb" create -s "${nullb_size}" -z "${nullb_zone_size}") + out=$(run_check_stdout $SUDO_HELPER "$nullb" create -s "$nullb_size" -z "$nullb_zone_size") if [ $? != 0 ]; then _fail "cannot create nullb zoned device $i" fi dev=$(echo "$out" | tail -n 1) - nullb_devs[$i]=${dev} + nullb_devs[$i]="$dev" done run_check $SUDO_HELPER "$nullb" ls diff --git a/tests/convert-tests/005-delete-all-rollback/test.sh b/tests/convert-tests/005-delete-all-rollback/test.sh index 5603d307..d0be331a 100755 --- a/tests/convert-tests/005-delete-all-rollback/test.sh +++ b/tests/convert-tests/005-delete-all-rollback/test.sh @@ -63,7 +63,7 @@ do_test() { convert_test_post_check_checksums "$CHECKSUMTMP" run_check_umount_test_dev - rm "$CHECKSUMTMP" + rm -- "$CHECKSUMTMP" } # Iterate over defaults and options that are not tied to hardware capabilities diff --git a/tests/convert-tests/025-ext4-uninit-written/test.sh b/tests/convert-tests/025-ext4-uninit-written/test.sh index cca8f69a..7230f232 100755 --- a/tests/convert-tests/025-ext4-uninit-written/test.sh +++ b/tests/convert-tests/025-ext4-uninit-written/test.sh @@ -29,7 +29,7 @@ fi # Now fill the underlying range with non-zeros. # For properly converted fs, we should not read the contents anyway -run_check $SUDO_HELPER dd if=/dev/urandom of=$TEST_DEV bs=4096 seek="$physical" conv=notrunc count=8 +run_check $SUDO_HELPER dd if=/dev/urandom of="$TEST_DEV" bs=4096 seek="$physical" conv=notrunc count=8 # Write some thing into the file range. run_check $SUDO_HELPER dd if=/dev/zero of="$TEST_MNT/file" bs=4096 count=1 conv=notrunc diff --git a/tests/fsck-tests/012-leaf-corruption/test.sh b/tests/fsck-tests/012-leaf-corruption/test.sh index 5539d8ab..dd849f85 100755 --- a/tests/fsck-tests/012-leaf-corruption/test.sh +++ b/tests/fsck-tests/012-leaf-corruption/test.sh @@ -48,11 +48,14 @@ generate_leaf_corrupt_no_data_ext() check_inode() { - path=$1 - ino=$2 - size=$3 - mode=$4 - name=$5 + local path=$1 + local ino=$2 + local size=$3 + local mode=$4 + local name=$5 + local exists + local found_mode + local found_size # Check whether the inode exists exists=$($SUDO_HELPER find "$path" -inum "$ino") @@ -84,11 +87,13 @@ check_inode() # Check salvaged data in the recovered image check_leaf_corrupt_no_data_ext() { - image=$1 + local image=$1 + local i + $SUDO_HELPER mount -o loop -t btrfs "$image" -o ro "$TEST_MNT" i=0 - while [ $i -lt ${#leaf_no_data_ext_list[@]} ]; do + while [ "$i" -lt ${#leaf_no_data_ext_list[@]} ]; do check_inode "$TEST_MNT/lost+found" \ ${leaf_no_data_ext_list[i]} \ ${leaf_no_data_ext_list[i + 1]} \ diff --git a/tests/fsck-tests/024-clear-space-cache/test.sh b/tests/fsck-tests/024-clear-space-cache/test.sh index 848ec46c..800b2619 100755 --- a/tests/fsck-tests/024-clear-space-cache/test.sh +++ b/tests/fsck-tests/024-clear-space-cache/test.sh @@ -23,7 +23,7 @@ sync # Remove file 1 3 5 to create holes for i in 1 3 5; do - run_check $SUDO_HELPER rm "$TEST_MNT/file_${i}" + run_check $SUDO_HELPER rm "$TEST_MNT/file_$i" done sync diff --git a/tests/fsck-tests/037-freespacetree-repair/test.sh b/tests/fsck-tests/037-freespacetree-repair/test.sh index 9e3d7dbc..e615fd5e 100755 --- a/tests/fsck-tests/037-freespacetree-repair/test.sh +++ b/tests/fsck-tests/037-freespacetree-repair/test.sh @@ -27,7 +27,7 @@ corrupt_fst_item() local offset type="$1" - if [[ $type == "bitmap" ]]; then + if [[ "$type" == "bitmap" ]]; then type=200 objectid=$("$TOP/btrfs" inspect-internal dump-tree -t 10 "$TEST_DEV" | \ grep -o "[[:digit:]]* FREE_SPACE_BITMAP [[:digit:]]*" | \ @@ -40,7 +40,7 @@ corrupt_fst_item() return 1 fi _log "Corrupting $objectid,FREE_SPACE_BITMAP,$offset" - elif [[ $type == "extent" ]]; then + elif [[ "$type" == "extent" ]]; then type=199 objectid=$("$TOP/btrfs" inspect-internal dump-tree -t 10 "$TEST_DEV" | \ grep -o "[[:digit:]]* FREE_SPACE_EXTENT [[:digit:]]*" | \ diff --git a/tests/fsck-tests/060-degraded-check/test.sh b/tests/fsck-tests/060-degraded-check/test.sh index 1fb0cacd..c4a91cc5 100755 --- a/tests/fsck-tests/060-degraded-check/test.sh +++ b/tests/fsck-tests/060-degraded-check/test.sh @@ -20,17 +20,17 @@ dev3=${loopdevs[3]} # Run 1: victim is dev1 run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f -m raid5 -d raid5 "${loopdevs[@]}" -run_check $SUDO_HELPER wipefs -fa $dev1 -run_check $SUDO_HELPER "$TOP/btrfs" check $dev2 +run_check $SUDO_HELPER wipefs -fa "$dev1" +run_check $SUDO_HELPER "$TOP/btrfs" check "$dev2" # Run 2: victim is dev2 run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f -m raid5 -d raid5 "${loopdevs[@]}" -run_check $SUDO_HELPER wipefs -fa $dev2 -run_check $SUDO_HELPER "$TOP/btrfs" check $dev3 +run_check $SUDO_HELPER wipefs -fa "$dev2" +run_check $SUDO_HELPER "$TOP/btrfs" check "$dev3" # Run 3: victim is dev3 run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f -m raid5 -d raid5 "${loopdevs[@]}" -run_check $SUDO_HELPER wipefs -fa $dev3 -run_check $SUDO_HELPER "$TOP/btrfs" check $dev1 +run_check $SUDO_HELPER wipefs -fa "$dev3" +run_check $SUDO_HELPER "$TOP/btrfs" check "$dev1" cleanup_loopdevs diff --git a/tests/fuzz-tests/003-multi-check-unmounted/test.sh b/tests/fuzz-tests/003-multi-check-unmounted/test.sh index 472b80d6..9b49ca07 100755 --- a/tests/fuzz-tests/003-multi-check-unmounted/test.sh +++ b/tests/fuzz-tests/003-multi-check-unmounted/test.sh @@ -13,7 +13,7 @@ setup_root_helper check_image() { local image - image=$1 + image="$1" run_mayfail $TOP/btrfs check -s 1 "$image" run_mayfail $TOP/btrfs check --force --init-csum-tree "$image" run_mayfail $TOP/btrfs check --repair --force --init-extent-tree "$image" diff --git a/tests/fuzz-tests/005-simple-dump-super/test.sh b/tests/fuzz-tests/005-simple-dump-super/test.sh index 59ae702f..fe9acd43 100755 --- a/tests/fuzz-tests/005-simple-dump-super/test.sh +++ b/tests/fuzz-tests/005-simple-dump-super/test.sh @@ -10,7 +10,7 @@ setup_root_helper check_image() { local image - image=$1 + image="$1" run_mayfail "$TOP/btrfs" inspect-internal dump-super "$image" run_mayfail "$TOP/btrfs" inspect-internal dump-super -Ffa "$image" } diff --git a/tests/fuzz-tests/007-simple-super-recover/test.sh b/tests/fuzz-tests/007-simple-super-recover/test.sh index ceee5a4c..3ba37553 100755 --- a/tests/fuzz-tests/007-simple-super-recover/test.sh +++ b/tests/fuzz-tests/007-simple-super-recover/test.sh @@ -16,6 +16,6 @@ check_image() { rm -- "$image".scratch } -check_all_images $TEST_TOP/fuzz-tests/images +check_all_images "$TEST_TOP/fuzz-tests/images" exit 0 diff --git a/tests/fuzz-tests/008-simple-chunk-recover/test.sh b/tests/fuzz-tests/008-simple-chunk-recover/test.sh index 9ef2c364..c9724818 100755 --- a/tests/fuzz-tests/008-simple-chunk-recover/test.sh +++ b/tests/fuzz-tests/008-simple-chunk-recover/test.sh @@ -10,7 +10,7 @@ setup_root_helper check_image() { local image - image=$1 + image="$1" run_check cp "$image" "$image".scratch run_mayfail "$TOP/btrfs" rescue chunk-recover -y -v "$image".scratch rm -- "$image".scratch diff --git a/tests/fuzz-tests/009-simple-zero-log/test.sh b/tests/fuzz-tests/009-simple-zero-log/test.sh index d62f4d45..013c435a 100755 --- a/tests/fuzz-tests/009-simple-zero-log/test.sh +++ b/tests/fuzz-tests/009-simple-zero-log/test.sh @@ -10,7 +10,7 @@ setup_root_helper check_image() { local image - image=$1 + image="$1" run_check cp "$image" "$image".scratch run_mayfail "$TOP/btrfs" rescue zero-log "$image".scratch rm -- "$image".scratch diff --git a/tests/misc-tests/002-uuid-rewrite/test.sh b/tests/misc-tests/002-uuid-rewrite/test.sh index 4c24362b..9ecac631 100755 --- a/tests/misc-tests/002-uuid-rewrite/test.sh +++ b/tests/misc-tests/002-uuid-rewrite/test.sh @@ -17,6 +17,7 @@ get_fs_uuid() { test_uuid_random() { local origuuid + local currentfsid origuuid=11111111-a101-4031-b29a-379d4f8b7a2d @@ -37,6 +38,7 @@ test_uuid_user() { local origuuid local newuuid + local fsid origuuid=22222222-d324-4f92-80e9-7658bf3b845f newuuid=33333333-bfc9-4045-9399-a396dc6893b3 diff --git a/tests/misc-tests/003-zero-log/test.sh b/tests/misc-tests/003-zero-log/test.sh index 5c11ff75..b647e4dd 100755 --- a/tests/misc-tests/003-zero-log/test.sh +++ b/tests/misc-tests/003-zero-log/test.sh @@ -19,6 +19,9 @@ get_log_root_level() { test_zero_log() { + local log_root + local log_root_level + # FIXME: we need an image with existing log_root run_check_mkfs_test_dev --rootdir "$INTERNAL_BIN/Documentation" run_check "$TOP/btrfs" inspect-internal dump-super "$TEST_DEV" diff --git a/tests/misc-tests/009-subvolume-sync-must-wait/test.sh b/tests/misc-tests/009-subvolume-sync-must-wait/test.sh index 22de6940..126a5fae 100755 --- a/tests/misc-tests/009-subvolume-sync-must-wait/test.sh +++ b/tests/misc-tests/009-subvolume-sync-must-wait/test.sh @@ -18,11 +18,11 @@ 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 + 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 + 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 diff --git a/tests/misc-tests/011-delete-missing-device/test.sh b/tests/misc-tests/011-delete-missing-device/test.sh index 5f41b2ed..0085fa19 100755 --- a/tests/misc-tests/011-delete-missing-device/test.sh +++ b/tests/misc-tests/011-delete-missing-device/test.sh @@ -26,6 +26,8 @@ test_wipefs() } test_delete_missing() { + local out + run_check_mount_test_dev -o degraded run_check $SUDO_HELPER "$TOP/btrfs" filesystem show "$TEST_MNT" run_check $SUDO_HELPER "$TOP/btrfs" device delete missing "$TEST_MNT" @@ -33,7 +35,6 @@ test_delete_missing() run_check_umount_test_dev run_check_mount_test_dev - local out out=$(run_check_stdout $SUDO_HELPER "$TOP/btrfs" filesystem show "$TEST_MNT") if echo "$out" | grep -q -- "$devtodel"; then _fail "device $devtodel not deleted" diff --git a/tests/misc-tests/013-subvolume-sync-crash/test.sh b/tests/misc-tests/013-subvolume-sync-crash/test.sh index ec34081e..e469b9ae 100755 --- a/tests/misc-tests/013-subvolume-sync-crash/test.sh +++ b/tests/misc-tests/013-subvolume-sync-crash/test.sh @@ -18,12 +18,12 @@ 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 + run_check dd if=/dev/zero of="file$i" bs=1M count=10 done # 128 is minimum for sn in `seq 130`;do - run_check $SUDO_HELPER "$TOP/btrfs" subvolume snapshot . snap$sn + 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=1 done diff --git a/tests/misc-tests/016-send-clone-src/test.sh b/tests/misc-tests/016-send-clone-src/test.sh index 686bb36a..84c492cc 100755 --- a/tests/misc-tests/016-send-clone-src/test.sh +++ b/tests/misc-tests/016-send-clone-src/test.sh @@ -19,14 +19,14 @@ cd "$TEST_MNT" || _fail "cannot chdir to TEST_MNT" run_check $SUDO_HELPER "$TOP/btrfs" subvolume create subv-parent1 for i in 1 2 3; do - run_check $SUDO_HELPER dd if=/dev/zero of=subv-parent1/file1_$i bs=1M count=1 - run_check $SUDO_HELPER "$TOP/btrfs" subvolume snapshot -r subv-parent1 subv-snap1_$i + run_check $SUDO_HELPER dd if=/dev/zero of="subv-parent1/file1_$i" bs=1M count=1 + run_check $SUDO_HELPER "$TOP/btrfs" subvolume snapshot -r subv-parent1 "subv-snap1_$i" done run_check $SUDO_HELPER "$TOP/btrfs" subvolume create subv-parent2 for i in 1 2 3; do - run_check $SUDO_HELPER dd if=/dev/zero of=subv-parent2/file2_$i bs=1M count=1 - run_check $SUDO_HELPER "$TOP/btrfs" subvolume snapshot -r subv-parent2 subv-snap2_$i + run_check $SUDO_HELPER dd if=/dev/zero of="subv-parent2/file2_$i" bs=1M count=1 + run_check $SUDO_HELPER "$TOP/btrfs" subvolume snapshot -r subv-parent2 "subv-snap2_$i" done _mktemp_local "$here/send-stream.img" diff --git a/tests/misc-tests/018-recv-end-of-stream/test.sh b/tests/misc-tests/018-recv-end-of-stream/test.sh index 5e5d1540..ece87ec9 100755 --- a/tests/misc-tests/018-recv-end-of-stream/test.sh +++ b/tests/misc-tests/018-recv-end-of-stream/test.sh @@ -52,7 +52,7 @@ test_full_simple_stream() { run_check $SUDO_HELPER "$TOP/btrfs" subvolume create subv1 for i in 1 2 3; do - run_check $SUDO_HELPER dd if=/dev/zero of=subv1/file1_$i bs=1M count=1 + run_check $SUDO_HELPER dd if=/dev/zero of="subv1/file1_$i" bs=1M count=1 done run_check $SUDO_HELPER "$TOP/btrfs" subvolume snapshot -r subv1 subv1-snap @@ -104,7 +104,8 @@ test_incr_empty_stream() { } test_incr_simple_stream() { - local str + local fstr + local istr fstr="$here/stream-full-simple.stream" istr="$here/stream-incr-simple.stream" @@ -115,13 +116,13 @@ test_incr_simple_stream() { run_check $SUDO_HELPER "$TOP/btrfs" subvolume create subv1 for i in 1 2 3; do - run_check $SUDO_HELPER dd if=/dev/zero of=subv1/file1_$i bs=1M count=1 + run_check $SUDO_HELPER dd if=/dev/zero of="subv1/file1_$i" bs=1M count=1 done run_check $SUDO_HELPER "$TOP/btrfs" subvolume snapshot -r subv1 subv1-snap for i in 1 2 3; do - run_check $SUDO_HELPER dd if=/dev/urandom of=subv1/file1_$i bs=1M count=1 + run_check $SUDO_HELPER dd if=/dev/urandom of="subv1/file1_$i" bs=1M count=1 done run_check $SUDO_HELPER "$TOP/btrfs" subvolume snapshot -r subv1 subv2-snap diff --git a/tests/misc-tests/020-fix-superblock-corruption/test.sh b/tests/misc-tests/020-fix-superblock-corruption/test.sh index e904160a..404fbb78 100755 --- a/tests/misc-tests/020-fix-superblock-corruption/test.sh +++ b/tests/misc-tests/020-fix-superblock-corruption/test.sh @@ -14,6 +14,8 @@ FIRST_SUPERBLOCK_OFFSET=65536 test_superblock_restore() { + local seek + run_check_mkfs_test_dev # Corrupt superblock checksum diff --git a/tests/misc-tests/028-superblock-recover/test.sh b/tests/misc-tests/028-superblock-recover/test.sh index 646ec6ea..474ca03b 100755 --- a/tests/misc-tests/028-superblock-recover/test.sh +++ b/tests/misc-tests/028-superblock-recover/test.sh @@ -13,8 +13,8 @@ prepare_test_dev 260G run_check_mkfs_test_dev check_corruption() { - local sb_offset=$1 - local source_sb=$2 + local sb_offset="$1" + local source_sb="$2" # First we ensure we can mount it successfully run_check_mount_test_dev @@ -37,7 +37,7 @@ check_corruption() { # Now run btrfs rescue which should fix the superblock. It uses 2 # to signal success of recovery use mayfail to ignore that retval # but still log the output of the command - run_mayfail $SUDO_HELPER "$TOP"/btrfs rescue super-recover -yv "$TEST_DEV" + run_mayfail $SUDO_HELPER "$TOP/btrfs" rescue super-recover -yv "$TEST_DEV" if [ $? != 2 ]; then _fail "couldn't rescue super" fi diff --git a/tests/misc-tests/030-missing-device-image/test.sh b/tests/misc-tests/030-missing-device-image/test.sh index 588d3e88..c7f1f629 100755 --- a/tests/misc-tests/030-missing-device-image/test.sh +++ b/tests/misc-tests/030-missing-device-image/test.sh @@ -24,7 +24,7 @@ test_missing() local good_num local good_dev - bad_num=$1 + bad_num="$1" bad_dev=${loopdevs[$bad_num]} good_num=$((3 - $bad_num)) good_dev=${loopdevs[$good_num]} diff --git a/tests/misc-tests/034-metadata-uuid/test.sh b/tests/misc-tests/034-metadata-uuid/test.sh index 43bab324..9dcb8948 100755 --- a/tests/misc-tests/034-metadata-uuid/test.sh +++ b/tests/misc-tests/034-metadata-uuid/test.sh @@ -43,13 +43,11 @@ read_metadata_uuid() { echo $(run_check_stdout $SUDO_HELPER "$TOP/btrfs" inspect-internal \ dump-super "$dev" | awk '/metadata_uuid/ {print $2}') else - read_fsid $dev + read_fsid "$dev" fi } check_btrfstune() { - local fsid - _log "Checking btrfstune logic" # test with random uuid run_check $SUDO_HELPER "$TOP/btrfstune" -m "$TEST_DEV" @@ -89,17 +87,16 @@ check_dump_super_output() { # assert that metadata/fsid match on non-changed fs fsid=$(read_fsid "$TEST_DEV") metadata_uuid=$(read_metadata_uuid "$TEST_DEV") - [ "$fsid" = "$metadata_uuid" ] || _fail "fsid ("$fsid") doesn't match metadata_uuid ("$metadata_uuid")" + [ "$fsid" = "$metadata_uuid" ] || _fail "fsid ($fsid) doesn't match metadata_uuid ($metadata_uuid)" dev_item_match=$(run_check_stdout $SUDO_HELPER "$TOP/btrfs" inspect-internal dump-super \ "$TEST_DEV" | awk '/dev_item.fsid/ {print $3}') - [ $dev_item_match = "[match]" ] || _fail "dev_item.fsid doesn't match on non-metadata uuid fs" - + [ "$dev_item_match" = "[match]" ] || _fail "dev_item.fsid doesn't match on non-metadata uuid fs" _log "Checking output after fsid change" # change metadatauuid and ensure everything in the output is still correct - old_metadata_uuid=$metadata_uuid + old_metadata_uuid="$metadata_uuid" run_check $SUDO_HELPER "$TOP/btrfstune" -M d88c8333-a652-4476-b225-2e9284eb59f1 "$TEST_DEV" fsid=$(read_fsid "$TEST_DEV") metadata_uuid=$(read_metadata_uuid "$TEST_DEV") diff --git a/tests/misc-tests/038-backup-root-corruption/test.sh b/tests/misc-tests/038-backup-root-corruption/test.sh index d276386f..d4396a7f 100755 --- a/tests/misc-tests/038-backup-root-corruption/test.sh +++ b/tests/misc-tests/038-backup-root-corruption/test.sh @@ -68,5 +68,5 @@ _log "After the backup usage:" _log "$(dump_super)" if [ "$main_root_ptr" -ne "$backup_new_root_ptr" ]; then - _fail "Backup ${slot_num} not overwritten" + _fail "Backup $slot_num not overwritten" fi diff --git a/tests/misc-tests/046-seed-multi-mount/test.sh b/tests/misc-tests/046-seed-multi-mount/test.sh index 38be4259..1ac80704 100755 --- a/tests/misc-tests/046-seed-multi-mount/test.sh +++ b/tests/misc-tests/046-seed-multi-mount/test.sh @@ -22,9 +22,9 @@ run_check_mkfs_test_dev -L BTRFS-TESTS-SEED run_check_mount_test_dev for i in `seq 6`; do - run_check $SUDO_HELPER dd if=/dev/zero of="$TEST_MNT/file${i}" bs=1M count=1 status=none + run_check $SUDO_HELPER dd if=/dev/zero of="$TEST_MNT/file$i" bs=1M count=1 status=none # Something to distinguish the contents - run_check md5sum "$TEST_MNT/file${i}" + run_check md5sum "$TEST_MNT/file$i" done run_check_umount_test_dev @@ -34,6 +34,9 @@ TEST_DEV=${loopdevs[1]} nextdevice() { local nextdev + local mnt + local md5sum + local md5sum2 nextdev="$1" # Mount again, as seeding device diff --git a/tests/misc-tests/053-receive-write-encoded/test.sh b/tests/misc-tests/053-receive-write-encoded/test.sh index bc06ee0a..95d9e975 100755 --- a/tests/misc-tests/053-receive-write-encoded/test.sh +++ b/tests/misc-tests/053-receive-write-encoded/test.sh @@ -22,7 +22,8 @@ here=`pwd` # assumes the filesystem exists, and does mount, write, snapshot, send, unmount # for the specified encoding option send_one() { - local str + local algorithm + local file local subv local snap diff --git a/tests/misc-tests/059-qgroup-show-stale-qgroup-crash/test.sh b/tests/misc-tests/059-qgroup-show-stale-qgroup-crash/test.sh index bcc924b4..cd7ffd27 100755 --- a/tests/misc-tests/059-qgroup-show-stale-qgroup-crash/test.sh +++ b/tests/misc-tests/059-qgroup-show-stale-qgroup-crash/test.sh @@ -13,9 +13,9 @@ count=24 run_check $SUDO_HELPER dd if=/dev/zero of="$TEST_MNT"/file bs=1M count=1 run_check $SUDO_HELPER "$TOP/btrfs" quota enable "$TEST_MNT" for i in `seq $count`; do - run_check $SUDO_HELPER "$TOP/btrfs" subvolume create "$TEST_MNT/subv${i}" + run_check $SUDO_HELPER "$TOP/btrfs" subvolume create "$TEST_MNT/subv$i" if [ "$(($i % 2))" = "0" ]; then - run_check $SUDO_HELPER "$TOP/btrfs" subvolume delete "$TEST_MNT/subv${i}" + run_check $SUDO_HELPER "$TOP/btrfs" subvolume delete "$TEST_MNT/subv$i" fi done run_check $SUDO_HELPER "$TOP/btrfs" qgroup show --sort path "$TEST_MNT" diff --git a/tests/misc-tests/060-ino-cache-clean/test.sh b/tests/misc-tests/060-ino-cache-clean/test.sh index 136f0bd3..518e2035 100755 --- a/tests/misc-tests/060-ino-cache-clean/test.sh +++ b/tests/misc-tests/060-ino-cache-clean/test.sh @@ -15,29 +15,29 @@ run_check "$TOP/btrfs" check "$image" # Check for FREE_INO items for toplevel subvol item_count=$(run_check_stdout "$TOP/btrfs" inspect-internal dump-tree -t fs "$image" | grep -c 'item [0-9].* key (FREE_INO') -[ $item_count -eq 0 ] || _fail "FREE_INO items for toplevel subvolume present" +[ "$item_count" -eq 0 ] || _fail "FREE_INO items for toplevel subvolume present" # Check for bitmap item for toplevel subvol item_count=$(run_check_stdout "$TOP/btrfs" inspect-internal dump-tree -t fs "$image" | grep -c '(FREE_SPACE') -[ $item_count -eq 0 ] || _fail "FREE_SPACE items for toplevel subvolume present" +[ "$item_count" -eq 0 ] || _fail "FREE_SPACE items for toplevel subvolume present" # Check for FREE_INO items for subvolume item_count=$(run_check_stdout "$TOP/btrfs" inspect-internal dump-tree -t 256 "$image" | grep -c 'item [0-9].* key (FREE_INO') -[ $item_count -eq 0 ] || _fail "ino cache items for subvolume present" +[ "$item_count" -eq 0 ] || _fail "ino cache items for subvolume present" # Check for bitmap item for subvolume item_count=$(run_check_stdout "$TOP/btrfs" inspect-internal dump-tree -t 256 "$image" | grep -c '(FREE_SPACE') -[ $item_count -eq 0 ] || _fail "FREE_SPACE items for subvolume present" +[ "$item_count" -eq 0 ] || _fail "FREE_SPACE items for subvolume present" # Check for FREE_INO items for snapshot item_count=$(run_check_stdout "$TOP/btrfs" inspect-internal dump-tree -t 257 "$image" | grep -c 'item [0-9].* key (FREE_INO') -[ $item_count -eq 0 ] || _fail "ino cache items for snapshot present" +[ "$item_count" -eq 0 ] || _fail "ino cache items for snapshot present" # Check for bitmap item for snapshot item_count=$(run_check_stdout "$TOP/btrfs" inspect-internal dump-tree -t 257 "$image" | grep -c '(FREE_SPACE') -[ $item_count -eq 0 ] || _fail "FREE_SPACE items for snapshot present" +[ "$item_count" -eq 0 ] || _fail "FREE_SPACE items for snapshot present" # Finally test that the csum tree is empty as ino cache also uses it. At this # point all ino items/extents should have been deleted hence the csum tree should @@ -45,6 +45,6 @@ item_count=$(run_check_stdout "$TOP/btrfs" inspect-internal dump-tree -t 257 "$i item_count=$(run_check_stdout "$TOP/btrfs" inspect-internal dump-tree -t csum "$image" | sed -n -e 's/^.* items \([0-9]*\).*/\1/p') -[ $item_count -eq 0 ] || _fail "csum tree not empty" +[ "$item_count" -eq 0 ] || _fail "csum tree not empty" rm -f -- "$image" diff --git a/tests/misc-tests/063-btrfstune-zoned-bgt/test.sh b/tests/misc-tests/063-btrfstune-zoned-bgt/test.sh index dc2003cc..5315f747 100755 --- a/tests/misc-tests/063-btrfstune-zoned-bgt/test.sh +++ b/tests/misc-tests/063-btrfstune-zoned-bgt/test.sh @@ -25,31 +25,31 @@ if [ $? != 0 ]; then _fail "cannot create nullb zoned device $i" fi dev=$(echo "$out" | tail -n 1) -name=$(basename "${dev}") +name=$(basename "$dev") run_check $SUDO_HELPER "$nullb" ls -TEST_DEV="${dev}" +TEST_DEV="$dev" # Create the fs without bgt -run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f -m single -d single -O ^block-group-tree "${dev}" +run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f -m single -d single -O ^block-group-tree "$dev" run_check_mount_test_dev run_check $SUDO_HELPER dd if=/dev/zero of="$TEST_MNT"/file1 bs=1M count=1 run_check $SUDO_HELPER "$TOP/btrfs" filesystem usage -T "$TEST_MNT" run_check_umount_test_dev # Convert to bgt -run_check $SUDO_HELPER "$TOP/btrfstune" --convert-to-block-group-tree "${dev}" +run_check $SUDO_HELPER "$TOP/btrfstune" --convert-to-block-group-tree "$dev" run_check_mount_test_dev run_check $SUDO_HELPER dd if=/dev/zero of="$TEST_MNT"/file2 bs=1M count=1 run_check $SUDO_HELPER "$TOP/btrfs" filesystem usage -T "$TEST_MNT" run_check_umount_test_dev # And convert back to old extent tree -run_check $SUDO_HELPER "$TOP/btrfstune" --convert-from-block-group-tree "${dev}" +run_check $SUDO_HELPER "$TOP/btrfstune" --convert-from-block-group-tree "$dev" run_check_mount_test_dev run_check $SUDO_HELPER dd if=/dev/zero of="$TEST_MNT"/file3 bs=1M count=1 run_check $SUDO_HELPER "$TOP/btrfs" filesystem usage -T "$TEST_MNT" run_check_umount_test_dev -run_check $SUDO_HELPER "$nullb" rm "${name}" +run_check $SUDO_HELPER "$nullb" rm "$name" diff --git a/tests/mkfs-tests/001-basic-profiles/test.sh b/tests/mkfs-tests/001-basic-profiles/test.sh index 07df6faa..2b46f1ff 100755 --- a/tests/mkfs-tests/001-basic-profiles/test.sh +++ b/tests/mkfs-tests/001-basic-profiles/test.sh @@ -36,6 +36,7 @@ test_get_info() run_check $SUDO_HELPER "$TOP/btrfs" device usage "$TEST_MNT" run_check $SUDO_HELPER umount "$TEST_MNT" } + test_do_mkfs() { run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f "$@" diff --git a/tests/mkfs-tests/008-sectorsize-nodesize-combination/test.sh b/tests/mkfs-tests/008-sectorsize-nodesize-combination/test.sh index a7d8216f..fe137f3c 100755 --- a/tests/mkfs-tests/008-sectorsize-nodesize-combination/test.sh +++ b/tests/mkfs-tests/008-sectorsize-nodesize-combination/test.sh @@ -17,8 +17,10 @@ features="^mixed-bg" # caller need to check whether the combination is valid do_test() { - sectorsize=$1 - nodesize=$2 + local sectorsize=$1 + local nodesize=$2 + local ret + run_mayfail "$TOP/mkfs.btrfs" -f -O "$features" -n "$nodesize" -s "$sectorsize" \ "$TEST_DEV" ret=$? diff --git a/tests/mkfs-tests/013-reserved-1M-for-single/test.sh b/tests/mkfs-tests/013-reserved-1M-for-single/test.sh index bc83a255..9434f741 100755 --- a/tests/mkfs-tests/013-reserved-1M-for-single/test.sh +++ b/tests/mkfs-tests/013-reserved-1M-for-single/test.sh @@ -15,6 +15,8 @@ prepare_test_dev do_one_test () { + local first_dev_extent + run_check_mkfs_test_dev "$@" # Use dev-extent tree to find first device extent diff --git a/tests/mkfs-tests/014-rootdir-inline-extent/test.sh b/tests/mkfs-tests/014-rootdir-inline-extent/test.sh index 889e6eee..7c686ae4 100755 --- a/tests/mkfs-tests/014-rootdir-inline-extent/test.sh +++ b/tests/mkfs-tests/014-rootdir-inline-extent/test.sh @@ -21,7 +21,7 @@ create_file() test_mkfs_rootdir() { - nodesize=$1 + local nodesize=$1 run_check_mkfs_test_dev --nodesize "$nodesize" --rootdir "$tmp" run_check $SUDO_HELPER "$TOP/btrfs" check "$TEST_DEV" } diff --git a/tests/mkfs-tests/031-zoned-bgt/test.sh b/tests/mkfs-tests/031-zoned-bgt/test.sh index e296c29b..97aa885f 100755 --- a/tests/mkfs-tests/031-zoned-bgt/test.sh +++ b/tests/mkfs-tests/031-zoned-bgt/test.sh @@ -11,7 +11,7 @@ prepare_nullbdevs TEST_DEV="${nullb_devs[1]}" # Use single as it's supported on more kernels -run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -m single -d single -O block-group-tree "${TEST_DEV}" +run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -m single -d single -O block-group-tree "$TEST_DEV" 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" diff --git a/tests/mkfs-tests/032-zoned-reset/test.sh b/tests/mkfs-tests/032-zoned-reset/test.sh index 2aedb14a..f899c391 100755 --- a/tests/mkfs-tests/032-zoned-reset/test.sh +++ b/tests/mkfs-tests/032-zoned-reset/test.sh @@ -13,29 +13,29 @@ prepare_nullbdevs TEST_DEV="${nullb_devs[1]}" last_zone_sector=$(( 4 * 31 * 1024 * 1024 / 512 )) # Write some data to the last zone -run_check $SUDO_HELPER dd if=/dev/urandom of="${TEST_DEV}" bs=1M count=4 seek=$(( 4 * 31 )) +run_check $SUDO_HELPER dd if=/dev/urandom of="$TEST_DEV" bs=1M count=4 seek=$(( 4 * 31 )) # Use single as it's supported on more kernels run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f -m single -d single "${TEST_DEV}" # Check if the lat zone is empty -run_check_stdout $SUDO_HELPER blkzone report -o ${last_zone_sector} -c 1 "${TEST_DEV}" | grep -Fq '(em)' +run_check_stdout $SUDO_HELPER blkzone report -o "$last_zone_sector" -c 1 "$TEST_DEV" | grep -Fq '(em)' if [ $? != 0 ]; then _fail "last zone is not empty" fi # Write some data to the last zone -run_check $SUDO_HELPER dd if=/dev/urandom of="${TEST_DEV}" bs=1M count=1 seek=$(( 4 * 31 )) +run_check $SUDO_HELPER dd if=/dev/urandom of="$TEST_DEV" bs=1M count=1 seek=$(( 4 * 31 )) # Create a FS excluding the last zone -run_mayfail $SUDO_HELPER "$TOP/mkfs.btrfs" -f -b $(( 4 * 31 ))M -m single -d single "${TEST_DEV}" +run_mayfail $SUDO_HELPER "$TOP/mkfs.btrfs" -f -b $(( 4 * 31 ))M -m single -d single "$TEST_DEV" if [ $? == 0 ]; then _fail "mkfs.btrfs should detect active zone outside of FS range" fi # Fill the last zone to finish it -run_check $SUDO_HELPER dd if=/dev/urandom of="${TEST_DEV}" bs=1M count=3 seek=$(( 4 * 31 + 1 )) +run_check $SUDO_HELPER dd if=/dev/urandom of="$TEST_DEV" bs=1M count=3 seek=$(( 4 * 31 + 1 )) # Create a FS excluding the last zone -run_mayfail $SUDO_HELPER "$TOP/mkfs.btrfs" -f -b $(( 4 * 31 ))M -m single -d single "${TEST_DEV}" +run_mayfail $SUDO_HELPER "$TOP/mkfs.btrfs" -f -b $(( 4 * 31 ))M -m single -d single "$TEST_DEV" # Check if the lat zone is not empty -run_check_stdout $SUDO_HELPER blkzone report -o ${last_zone_sector} -c 1 "${TEST_DEV}" | grep -Fq '(em)' +run_check_stdout $SUDO_HELPER blkzone report -o "$last_zone_sector" -c 1 "$TEST_DEV" | grep -Fq '(em)' if [ $? == 0 ]; then _fail "last zone is empty" fi