tests: replace explicit $? || log_fail with log_must
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz> Closes #12996
This commit is contained in:
parent
85c2cce51c
commit
26bbce8173
|
@ -55,7 +55,6 @@ function log_note
|
||||||
function log_neg
|
function log_neg
|
||||||
{
|
{
|
||||||
log_neg_expect "" "$@"
|
log_neg_expect "" "$@"
|
||||||
return $?
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Execute a positive test and exit $STF_FAIL is test fails
|
# Execute a positive test and exit $STF_FAIL is test fails
|
||||||
|
@ -64,8 +63,7 @@ function log_neg
|
||||||
|
|
||||||
function log_must
|
function log_must
|
||||||
{
|
{
|
||||||
log_pos "$@"
|
log_pos "$@" || log_fail
|
||||||
(( $? != 0 )) && log_fail
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Execute a positive test (expecting no stderr) and exit $STF_FAIL
|
# Execute a positive test (expecting no stderr) and exit $STF_FAIL
|
||||||
|
@ -74,8 +72,7 @@ function log_must
|
||||||
|
|
||||||
function log_must_nostderr
|
function log_must_nostderr
|
||||||
{
|
{
|
||||||
log_pos_nostderr "$@"
|
log_pos_nostderr "$@" || log_fail
|
||||||
(( $? != 0 )) && log_fail
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Execute a positive test but retry the command on failure if the output
|
# Execute a positive test but retry the command on failure if the output
|
||||||
|
@ -149,8 +146,7 @@ function log_must_retry
|
||||||
# $@ - command to execute
|
# $@ - command to execute
|
||||||
function log_must_busy
|
function log_must_busy
|
||||||
{
|
{
|
||||||
log_must_retry "busy" 5 "$@"
|
log_must_retry "busy" 5 "$@" || log_fail
|
||||||
(( $? != 0 )) && log_fail
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Execute a negative test and exit $STF_FAIL if test passes
|
# Execute a negative test and exit $STF_FAIL if test passes
|
||||||
|
@ -159,8 +155,7 @@ function log_must_busy
|
||||||
|
|
||||||
function log_mustnot
|
function log_mustnot
|
||||||
{
|
{
|
||||||
log_neg "$@"
|
log_neg "$@" || log_fail
|
||||||
(( $? != 0 )) && log_fail
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Execute a negative test with keyword expected, and exit
|
# Execute a negative test with keyword expected, and exit
|
||||||
|
@ -171,8 +166,7 @@ function log_mustnot
|
||||||
|
|
||||||
function log_mustnot_expect
|
function log_mustnot_expect
|
||||||
{
|
{
|
||||||
log_neg_expect "$@"
|
log_neg_expect "$@" || log_fail
|
||||||
(( $? != 0 )) && log_fail
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Signal numbers are platform-dependent
|
# Signal numbers are platform-dependent
|
||||||
|
@ -576,5 +570,5 @@ function _recursive_output #logfile
|
||||||
fi
|
fi
|
||||||
rm -f $logfile
|
rm -f $logfile
|
||||||
logfile="$logfile.$$"
|
logfile="$logfile.$$"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
|
@ -154,12 +154,7 @@ typeset -i i=0
|
||||||
while ((i < ${#dataset[@]})); do
|
while ((i < ${#dataset[@]})); do
|
||||||
for opt in "${options[@]}"; do
|
for opt in "${options[@]}"; do
|
||||||
for prop in ${all_props[@]}; do
|
for prop in ${all_props[@]}; do
|
||||||
eval "zfs get $opt $prop ${dataset[i]} > \
|
log_must eval "zfs get $opt $prop ${dataset[i]} > $TESTDIR/$TESTFILE0"
|
||||||
$TESTDIR/$TESTFILE0"
|
|
||||||
ret=$?
|
|
||||||
if [[ $ret != 0 ]]; then
|
|
||||||
log_fail "zfs get returned: $ret"
|
|
||||||
fi
|
|
||||||
check_return_value ${dataset[i]} "$prop" "$opt"
|
check_return_value ${dataset[i]} "$prop" "$opt"
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
@ -170,12 +165,7 @@ i=0
|
||||||
while ((i < ${#bookmark[@]})); do
|
while ((i < ${#bookmark[@]})); do
|
||||||
for opt in "${options[@]}"; do
|
for opt in "${options[@]}"; do
|
||||||
for prop in ${bookmark_props[@]}; do
|
for prop in ${bookmark_props[@]}; do
|
||||||
eval "zfs get $opt $prop ${bookmark[i]} > \
|
log_must eval "zfs get $opt $prop ${bookmark[i]} > $TESTDIR/$TESTFILE0"
|
||||||
$TESTDIR/$TESTFILE0"
|
|
||||||
ret=$?
|
|
||||||
if [[ $ret != 0 ]]; then
|
|
||||||
log_fail "zfs get returned: $ret"
|
|
||||||
fi
|
|
||||||
check_return_value ${bookmark[i]} "$prop" "$opt"
|
check_return_value ${bookmark[i]} "$prop" "$opt"
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|
|
@ -85,11 +85,7 @@ for dst in ${dataset[@]}; do
|
||||||
for opt in "" $(gen_option_str "${options[*]}" "-" "" $opt_numb); do
|
for opt in "" $(gen_option_str "${options[*]}" "-" "" $opt_numb); do
|
||||||
for prop in $(gen_option_str "${props[*]}" "" "," $prop_numb)
|
for prop in $(gen_option_str "${props[*]}" "" "," $prop_numb)
|
||||||
do
|
do
|
||||||
zfs get $opt $prop $dst > /dev/null 2>&1
|
log_must eval "zfs get $opt $prop $dst > /dev/null"
|
||||||
ret=$?
|
|
||||||
if [[ $ret != 0 ]]; then
|
|
||||||
log_fail "zfs get $opt $prop $dst (Code: $ret)"
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|
|
@ -93,12 +93,7 @@ function test_options
|
||||||
for dst in ${dataset[@]}; do
|
for dst in ${dataset[@]}; do
|
||||||
for opt in $opts; do
|
for opt in $opts; do
|
||||||
for prop in $props; do
|
for prop in $props; do
|
||||||
zfs get $opt -- $prop $dst > /dev/null 2>&1
|
log_mustnot eval "zfs get $opt -- $prop $dst > /dev/null"
|
||||||
ret=$?
|
|
||||||
if [[ $ret == 0 ]]; then
|
|
||||||
log_fail "zfs get $opt -- $prop " \
|
|
||||||
"$dst unexpectedly succeeded."
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
@ -118,12 +113,7 @@ function test_options_bookmarks
|
||||||
for dst in ${bookmark[@]}; do
|
for dst in ${bookmark[@]}; do
|
||||||
for opt in $opts; do
|
for opt in $opts; do
|
||||||
for prop in $props; do
|
for prop in $props; do
|
||||||
zfs get $opt -- $prop $dst > /dev/null 2>&1
|
log_mustnot eval "zfs get $opt -- $prop $dst > /dev/null"
|
||||||
ret=$?
|
|
||||||
if [[ $ret == 0 ]]; then
|
|
||||||
log_fail "zfs get $opt -- $prop " \
|
|
||||||
"$dst unexpectedly succeeded."
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|
|
@ -49,7 +49,7 @@ function cleanup
|
||||||
poolexists $migratedpoolname && \
|
poolexists $migratedpoolname && \
|
||||||
log_must zpool destroy -f $migratedpoolname
|
log_must zpool destroy -f $migratedpoolname
|
||||||
|
|
||||||
[[ -d $import_dir ]] && rm -rf $import_dir
|
rm -rf $import_dir
|
||||||
}
|
}
|
||||||
|
|
||||||
log_assert "Verify command history moves with migrated pool."
|
log_assert "Verify command history moves with migrated pool."
|
||||||
|
@ -80,10 +80,7 @@ for arch in "i386" "sparc"; do
|
||||||
log_must zpool destroy -f $migratedpoolname
|
log_must zpool destroy -f $migratedpoolname
|
||||||
|
|
||||||
log_must zpool import -d $import_dir $migratedpoolname
|
log_must zpool import -d $import_dir $migratedpoolname
|
||||||
TZ=$TIMEZONE zpool history $migratedpoolname | grep -v "^$" \
|
log_must eval "TZ=$TIMEZONE zpool history $migratedpoolname | grep -v "^\$" >$migrated_cmds_f"
|
||||||
>$migrated_cmds_f
|
|
||||||
RET=$?
|
|
||||||
(( $RET != 0 )) && log_fail "zpool history $migratedpoolname fails."
|
|
||||||
|
|
||||||
# The migrated history file should differ with original history file on
|
# The migrated history file should differ with original history file on
|
||||||
# two commands -- 'export' and 'import', which are included in migrated
|
# two commands -- 'export' and 'import', which are included in migrated
|
||||||
|
@ -92,14 +89,13 @@ for arch in "i386" "sparc"; do
|
||||||
# then compare this filtered file with the original history file. They
|
# then compare this filtered file with the original history file. They
|
||||||
# should be identical at this time.
|
# should be identical at this time.
|
||||||
for subcmd in "export" "import"; do
|
for subcmd in "export" "import"; do
|
||||||
grep "$subcmd" $migrated_cmds_f >/dev/null 2>&1
|
grep -q "$subcmd" $migrated_cmds_f || \
|
||||||
RET=$?
|
log_fail "zpool $subcmd is not logged for" \
|
||||||
(( $RET != 0 )) && log_fail "zpool $subcmd is not logged for" \
|
"the imported pool $migratedpoolname."
|
||||||
"the imported pool $migratedpoolname."
|
|
||||||
done
|
done
|
||||||
|
|
||||||
tmpfile=$import_dir/cmds_tmp.$$
|
tmpfile=$import_dir/cmds_tmp.$$
|
||||||
linenum=`cat $migrated_cmds_f | wc -l`
|
linenum=`wc -l < $migrated_cmds_f`
|
||||||
(( linenum = linenum - 2 ))
|
(( linenum = linenum - 2 ))
|
||||||
head -n $linenum $migrated_cmds_f > $tmpfile
|
head -n $linenum $migrated_cmds_f > $tmpfile
|
||||||
log_must diff $tmpfile $orig_cmds_f1
|
log_must diff $tmpfile $orig_cmds_f1
|
||||||
|
|
|
@ -120,7 +120,7 @@ typeset str
|
||||||
typeset -i ret
|
typeset -i ret
|
||||||
for volsize in $VOLSIZES; do
|
for volsize in $VOLSIZES; do
|
||||||
log_note "Create a pool which will contain a volume device"
|
log_note "Create a pool which will contain a volume device"
|
||||||
create_pool $TESTPOOL2 "$DISKS"
|
log_must create_pool $TESTPOOL2 "$DISKS"
|
||||||
|
|
||||||
log_note "Create a volume device of desired sizes: $volsize"
|
log_note "Create a volume device of desired sizes: $volsize"
|
||||||
str=$(zfs create -sV $volsize $TESTPOOL2/$TESTVOL 2>&1)
|
str=$(zfs create -sV $volsize $TESTPOOL2/$TESTVOL 2>&1)
|
||||||
|
@ -140,7 +140,7 @@ for volsize in $VOLSIZES; do
|
||||||
block_device_wait
|
block_device_wait
|
||||||
|
|
||||||
log_note "Create the largest pool allowed using the volume vdev"
|
log_note "Create the largest pool allowed using the volume vdev"
|
||||||
create_pool $TESTPOOL "$VOL_PATH"
|
log_must create_pool $TESTPOOL "$VOL_PATH"
|
||||||
|
|
||||||
log_note "Create a zfs file system in the largest pool"
|
log_note "Create a zfs file system in the largest pool"
|
||||||
log_must zfs create $TESTPOOL/$TESTFS
|
log_must zfs create $TESTPOOL/$TESTFS
|
||||||
|
|
|
@ -67,18 +67,12 @@ done
|
||||||
#
|
#
|
||||||
for ds in "$POOL/$FS/fs1" "$POOL/$FS/fs1/fs2" "$POOL/$FS/fs1/fclone" ; do
|
for ds in "$POOL/$FS/fs1" "$POOL/$FS/fs1/fs2" "$POOL/$FS/fs1/fclone" ; do
|
||||||
for prop in $(fs_inherit_prop) ; do
|
for prop in $(fs_inherit_prop) ; do
|
||||||
zfs inherit $prop $ds
|
log_must zfs inherit $prop $ds
|
||||||
if (($? !=0 )); then
|
|
||||||
log_fail "zfs inherit $prop $ds"
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
if is_global_zone ; then
|
if is_global_zone ; then
|
||||||
for prop in $(vol_inherit_prop) ; do
|
for prop in $(vol_inherit_prop) ; do
|
||||||
zfs inherit $prop $POOL/$FS/vol
|
log_must zfs inherit $prop $POOL/$FS/vol
|
||||||
if (($? !=0 )); then
|
|
||||||
log_fail "zfs inherit $prop $POOL/$FS/vol"
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -52,18 +52,13 @@ function edited_prop
|
||||||
"get")
|
"get")
|
||||||
typeset props=$(zfs inherit 2>&1 | \
|
typeset props=$(zfs inherit 2>&1 | \
|
||||||
awk '$2=="YES" {print $1}' | \
|
awk '$2=="YES" {print $1}' | \
|
||||||
egrep -v "^vol|\.\.\.$")
|
grep -Ev "^vol|\.\.\.$")
|
||||||
for item in $props ; do
|
for item in $props ; do
|
||||||
if [[ $item == "mlslabel" ]] && \
|
if [[ $item == "mlslabel" ]] && \
|
||||||
! is_te_enabled ; then
|
! is_te_enabled ; then
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
zfs get -H -o property,value $item $ds >> \
|
log_must eval "zfs get -H -o property,value $item $ds >> $backfile"
|
||||||
$backfile
|
|
||||||
if (($? != 0)); then
|
|
||||||
log_fail "zfs get -H -o property,value"\
|
|
||||||
"$item $ds > $backfile"
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
;;
|
;;
|
||||||
"set")
|
"set")
|
||||||
|
@ -72,11 +67,8 @@ function edited_prop
|
||||||
fi
|
fi
|
||||||
|
|
||||||
typeset prop value
|
typeset prop value
|
||||||
while read prop value ; do
|
while read -r prop value; do
|
||||||
eval zfs set $prop='$value' $ds
|
log_must zfs set "$prop=$value" "$ds"
|
||||||
if (($? != 0)); then
|
|
||||||
log_fail "zfs set $prop=$value $ds"
|
|
||||||
fi
|
|
||||||
done < $backfile
|
done < $backfile
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
|
Loading…
Reference in New Issue