btrfs-progs/tests/misc-tests/003-zero-log/test.sh
David Sterba 9957162313 btrfs-progs: tests: update or fix shell script coding style
Fix the following issues in the test suite:

- lack of quoting for variables
- declare function variables local when missing (prevent accidental
  overwrite of global variables)
- for variables with underscore in the name use plain "$VAR_NAME"
  instead of { } (unless necessary)
- minor style adjustments like moving quotes to the end of the same
  string

Signed-off-by: David Sterba <dsterba@suse.com>
2024-06-24 19:18:08 +02:00

43 lines
1.0 KiB
Bash
Executable File

#!/bin/bash
# test zero-log
source "$TEST_TOP/common" || exit
check_prereq mkfs.btrfs
check_prereq btrfs
prepare_test_dev
get_log_root()
{
"$TOP/btrfs" inspect-internal dump-super "$1" | \
grep '^log_root\>' | awk '{print $2}'
}
get_log_root_level() {
"$TOP/btrfs" inspect-internal dump-super "$1" | \
grep '^log_root_level' | awk '{print $2}'
}
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"
run_check "$TOP/btrfs" rescue zero-log "$TEST_DEV"
log_root=$(get_log_root "$TEST_DEV")
log_root_level=$(get_log_root "$TEST_DEV")
if [ "$log_root" != 0 ]; then
_fail "FAIL: log_root not reset"
fi
if [ "$log_root_level" != 0 ]; then
_fail "FAIL: log_root_level not reset"
fi
run_check "$TOP/btrfs" inspect-internal dump-super "$TEST_DEV"
run_check $SUDO_HELPER "$TOP/btrfs" check "$TEST_DEV"
}
test_zero_log standalone
test_zero_log internal