mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-03-14 06:16:17 +03:00
Add typesets to zhack label repair test scripts
As a quality assurance measure, `typeset` is added to local variable declarations to actually enforce their intended scope. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: buzzingwires <buzzingwires@outlook.com> Closes #17732
This commit is contained in:
parent
1d2d812986
commit
ffe93aee0a
@ -100,7 +100,7 @@ VIRTUAL_MIRROR_DEVICE=
|
|||||||
|
|
||||||
function cleanup_lo
|
function cleanup_lo
|
||||||
{
|
{
|
||||||
L_DEVICE="$1"
|
typeset L_DEVICE="$1"
|
||||||
|
|
||||||
if [[ -e $L_DEVICE ]]; then
|
if [[ -e $L_DEVICE ]]; then
|
||||||
if is_linux; then
|
if is_linux; then
|
||||||
@ -136,9 +136,9 @@ function get_devsize
|
|||||||
|
|
||||||
function pick_logop
|
function pick_logop
|
||||||
{
|
{
|
||||||
L_SHOULD_SUCCEED="$1"
|
typeset L_SHOULD_SUCCEED="$1"
|
||||||
|
|
||||||
l_logop="log_mustnot"
|
typeset l_logop="log_mustnot"
|
||||||
if [ "$L_SHOULD_SUCCEED" == true ]; then
|
if [ "$L_SHOULD_SUCCEED" == true ]; then
|
||||||
l_logop="log_must"
|
l_logop="log_must"
|
||||||
fi
|
fi
|
||||||
@ -148,7 +148,9 @@ function pick_logop
|
|||||||
|
|
||||||
function check_dataset
|
function check_dataset
|
||||||
{
|
{
|
||||||
L_SHOULD_SUCCEED="$1"
|
typeset L_SHOULD_SUCCEED="$1"
|
||||||
|
|
||||||
|
typeset L_LOGOP=
|
||||||
L_LOGOP="$(pick_logop "$L_SHOULD_SUCCEED")"
|
L_LOGOP="$(pick_logop "$L_SHOULD_SUCCEED")"
|
||||||
|
|
||||||
"$L_LOGOP" mounted "$TESTPOOL"/"$TESTFS"
|
"$L_LOGOP" mounted "$TESTPOOL"/"$TESTFS"
|
||||||
@ -175,7 +177,8 @@ function setup_dataset
|
|||||||
|
|
||||||
function force_transactions
|
function force_transactions
|
||||||
{
|
{
|
||||||
L_TIMES="$1"
|
typeset L_TIMES="$1"
|
||||||
|
typeset i=
|
||||||
for ((i=0; i < L_TIMES; i++))
|
for ((i=0; i < L_TIMES; i++))
|
||||||
do
|
do
|
||||||
touch "$TESTDIR"/"test" || return $?
|
touch "$TESTDIR"/"test" || return $?
|
||||||
@ -186,7 +189,7 @@ function force_transactions
|
|||||||
|
|
||||||
function get_practical_size
|
function get_practical_size
|
||||||
{
|
{
|
||||||
L_SIZE="$1"
|
typeset L_SIZE="$1"
|
||||||
|
|
||||||
if [ "$((L_SIZE % LABEL_SIZE))" -ne 0 ]; then
|
if [ "$((L_SIZE % LABEL_SIZE))" -ne 0 ]; then
|
||||||
echo "$(((L_SIZE / LABEL_SIZE) * LABEL_SIZE))"
|
echo "$(((L_SIZE / LABEL_SIZE) * LABEL_SIZE))"
|
||||||
@ -197,10 +200,11 @@ function get_practical_size
|
|||||||
|
|
||||||
function corrupt_sized_label_checksum
|
function corrupt_sized_label_checksum
|
||||||
{
|
{
|
||||||
L_SIZE="$1"
|
typeset L_SIZE="$1"
|
||||||
L_LABEL="$2"
|
typeset L_LABEL="$2"
|
||||||
L_DEVICE="$3"
|
typeset L_DEVICE="$3"
|
||||||
|
|
||||||
|
typeset L_PRACTICAL_SIZE=
|
||||||
L_PRACTICAL_SIZE="$(get_practical_size "$L_SIZE")"
|
L_PRACTICAL_SIZE="$(get_practical_size "$L_SIZE")"
|
||||||
|
|
||||||
typeset -a L_OFFSETS=("$LABEL_CKSUM_START" \
|
typeset -a L_OFFSETS=("$LABEL_CKSUM_START" \
|
||||||
@ -215,8 +219,8 @@ function corrupt_sized_label_checksum
|
|||||||
|
|
||||||
function corrupt_labels
|
function corrupt_labels
|
||||||
{
|
{
|
||||||
L_SIZE="$1"
|
typeset L_SIZE="$1"
|
||||||
L_DISK="$2"
|
typeset L_DISK="$2"
|
||||||
|
|
||||||
corrupt_sized_label_checksum "$L_SIZE" 0 "$L_DISK"
|
corrupt_sized_label_checksum "$L_SIZE" 0 "$L_DISK"
|
||||||
corrupt_sized_label_checksum "$L_SIZE" 1 "$L_DISK"
|
corrupt_sized_label_checksum "$L_SIZE" 1 "$L_DISK"
|
||||||
@ -226,11 +230,14 @@ function corrupt_labels
|
|||||||
|
|
||||||
function try_import_and_repair
|
function try_import_and_repair
|
||||||
{
|
{
|
||||||
L_REPAIR_SHOULD_SUCCEED="$1"
|
typeset L_REPAIR_SHOULD_SUCCEED="$1"
|
||||||
L_IMPORT_SHOULD_SUCCEED="$2"
|
typeset L_IMPORT_SHOULD_SUCCEED="$2"
|
||||||
L_OP="$3"
|
typeset L_OP="$3"
|
||||||
L_POOLDISK="$4"
|
typeset L_POOLDISK="$4"
|
||||||
|
|
||||||
|
typeset L_REPAIR_LOGOP=
|
||||||
L_REPAIR_LOGOP="$(pick_logop "$L_REPAIR_SHOULD_SUCCEED")"
|
L_REPAIR_LOGOP="$(pick_logop "$L_REPAIR_SHOULD_SUCCEED")"
|
||||||
|
typeset L_IMPORT_LOGOP=
|
||||||
L_IMPORT_LOGOP="$(pick_logop "$L_IMPORT_SHOULD_SUCCEED")"
|
L_IMPORT_LOGOP="$(pick_logop "$L_IMPORT_SHOULD_SUCCEED")"
|
||||||
|
|
||||||
log_mustnot zpool import "$TESTPOOL" -d "$L_POOLDISK"
|
log_mustnot zpool import "$TESTPOOL" -d "$L_POOLDISK"
|
||||||
@ -244,10 +251,10 @@ function try_import_and_repair
|
|||||||
|
|
||||||
function prepare_vdev
|
function prepare_vdev
|
||||||
{
|
{
|
||||||
L_SIZE="$1"
|
typeset L_SIZE="$1"
|
||||||
L_BACKFILE="$2"
|
typeset L_BACKFILE="$2"
|
||||||
|
|
||||||
l_devname=
|
typeset l_devname=
|
||||||
if truncate -s "$L_SIZE" "$L_BACKFILE"; then
|
if truncate -s "$L_SIZE" "$L_BACKFILE"; then
|
||||||
if is_linux; then
|
if is_linux; then
|
||||||
l_devname="$(losetup -f "$L_BACKFILE" --show)"
|
l_devname="$(losetup -f "$L_BACKFILE" --show)"
|
||||||
@ -262,7 +269,7 @@ function prepare_vdev
|
|||||||
|
|
||||||
function run_test_one
|
function run_test_one
|
||||||
{
|
{
|
||||||
L_SIZE="$1"
|
typeset L_SIZE="$1"
|
||||||
|
|
||||||
VIRTUAL_DEVICE="$(prepare_vdev "$L_SIZE" "$VIRTUAL_DISK")"
|
VIRTUAL_DEVICE="$(prepare_vdev "$L_SIZE" "$VIRTUAL_DISK")"
|
||||||
log_must test -e "$VIRTUAL_DEVICE"
|
log_must test -e "$VIRTUAL_DEVICE"
|
||||||
@ -289,7 +296,7 @@ function run_test_one
|
|||||||
|
|
||||||
function make_mirrored_pool
|
function make_mirrored_pool
|
||||||
{
|
{
|
||||||
L_SIZE="$1"
|
typeset L_SIZE="$1"
|
||||||
|
|
||||||
VIRTUAL_DEVICE="$(prepare_vdev "$L_SIZE" "$VIRTUAL_DISK")"
|
VIRTUAL_DEVICE="$(prepare_vdev "$L_SIZE" "$VIRTUAL_DISK")"
|
||||||
log_must test -e "$VIRTUAL_DEVICE"
|
log_must test -e "$VIRTUAL_DEVICE"
|
||||||
@ -313,7 +320,7 @@ function export_and_cleanup_vdisk
|
|||||||
|
|
||||||
function run_test_two
|
function run_test_two
|
||||||
{
|
{
|
||||||
L_SIZE="$1"
|
typeset L_SIZE="$1"
|
||||||
|
|
||||||
make_mirrored_pool "$L_SIZE"
|
make_mirrored_pool "$L_SIZE"
|
||||||
|
|
||||||
@ -334,7 +341,7 @@ function run_test_two
|
|||||||
|
|
||||||
function run_test_three
|
function run_test_three
|
||||||
{
|
{
|
||||||
L_SIZE="$1"
|
typeset L_SIZE="$1"
|
||||||
|
|
||||||
make_mirrored_pool "$L_SIZE"
|
make_mirrored_pool "$L_SIZE"
|
||||||
|
|
||||||
@ -359,7 +366,7 @@ function run_test_three
|
|||||||
|
|
||||||
function run_test_four
|
function run_test_four
|
||||||
{
|
{
|
||||||
L_SIZE="$1"
|
typeset L_SIZE="$1"
|
||||||
|
|
||||||
make_mirrored_pool "$L_SIZE"
|
make_mirrored_pool "$L_SIZE"
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user