tests: review every instance of $?

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #13259
This commit is contained in:
наб 2022-03-23 01:52:39 +01:00 committed by Brian Behlendorf
parent 6586085673
commit 23914a3b91
147 changed files with 560 additions and 1485 deletions

View File

@ -45,9 +45,7 @@ function scan_scsi_hosts
log_must eval "echo '- - -' > $host/scan"
done
else
log_must eval \
"echo /sys/class/scsi_host/host$hostnum/scan" \
> /dev/null
log_note "/sys/class/scsi_host/host$hostnum/scan"
log_must eval \
"echo '- - -' > /sys/class/scsi_host/host$hostnum/scan"
fi
@ -176,13 +174,11 @@ function is_mpath_device #disk
[[ -z $disk ]] && log_fail "No argument for disk given."
if is_linux; then
lsblk $DEV_MPATHDIR/$disk -o TYPE 2>/dev/null | \
grep -q mpath
if (($? == 0)); then
if lsblk $DEV_MPATHDIR/$disk -o TYPE 2>/dev/null | \
grep -q mpath; then
readlink $DEV_MPATHDIR/$disk > /dev/null 2>&1
return $?
else
return $?
false
fi
elif is_freebsd; then
is_disk_device $DEV_MPATHDIR/$disk
@ -438,11 +434,8 @@ function load_scsi_debug # dev_size_mb add_host num_tgts max_luns blksz
esac
if is_linux; then
modprobe -n scsi_debug
if (($? != 0)); then
log_unsupported "Platform does not have scsi_debug"
"module"
fi
modprobe -n scsi_debug ||
log_unsupported "Platform does not have scsi_debug module"
if lsmod | grep -q scsi_debug; then
log_fail "scsi_debug module already installed"
else

View File

@ -65,17 +65,16 @@ function linux_version
{
typeset ver="$1"
[[ -z "$ver" ]] && ver=$(uname -r | grep -Eo "^[0-9]+\.[0-9]+\.[0-9]+")
[ -z "$ver" ] && ver=$(uname -r | grep -Eo "^[0-9]+\.[0-9]+\.[0-9]+")
typeset version=$(echo $ver | cut -d '.' -f 1)
typeset major=$(echo $ver | cut -d '.' -f 2)
typeset minor=$(echo $ver | cut -d '.' -f 3)
typeset version major minor _
IFS='.' read -r version major minor _ <<<"$ver"
[[ -z "$version" ]] && version=0
[[ -z "$major" ]] && major=0
[[ -z "$minor" ]] && minor=0
[ -z "$version" ] && version=0
[ -z "$major" ] && major=0
[ -z "$minor" ] && minor=0
echo $((version * 10000 + major * 100 + minor))
echo $((version * 100000 + major * 1000 + minor))
}
# Determine if this is a Linux test system
@ -144,7 +143,7 @@ function ismounted
{
typeset fstype=$2
[[ -z $fstype ]] && fstype=zfs
typeset out dir name ret
typeset out dir name
case $fstype in
zfs)
@ -153,7 +152,6 @@ function ismounted
else
! zfs mount | awk -v ds="$1" '$1 == ds {exit 1}'
fi
return $?
;;
ufs|nfs)
if is_freebsd; then
@ -161,9 +159,7 @@ function ismounted
[[ "$1" == "$dev" || "$1" == "$dir" ]] && return 0
done
else
out=$(df -F $fstype $1 2>/dev/null)
ret=$?
(($ret != 0)) && return $ret
out=$(df -F $fstype $1 2>/dev/null) || return
dir=${out%%\(*}
dir=${dir%% *}
@ -176,7 +172,6 @@ function ismounted
;;
ext*)
df -t $fstype $1 > /dev/null 2>&1
return $?
;;
zvol)
if [[ -L "$ZVOL_DEVDIR/$1" ]]; then
@ -186,9 +181,10 @@ function ismounted
return 0
fi
;;
*)
false
;;
esac
return 1
}
# Return 0 if a dataset is mounted; 1 otherwise
@ -199,8 +195,6 @@ function ismounted
function mounted
{
ismounted $1 $2
(($? == 0)) && return 0
return 1
}
# Return 0 if a dataset is unmounted; 1 otherwise
@ -210,9 +204,7 @@ function mounted
function unmounted
{
ismounted $1 $2
(($? == 1)) && return 0
return 1
! ismounted $1 $2
}
function default_setup
@ -644,8 +636,7 @@ function default_container_cleanup
reexport_pool
fi
ismounted $TESTPOOL/$TESTCTR/$TESTFS1
[[ $? -eq 0 ]] && \
ismounted $TESTPOOL/$TESTCTR/$TESTFS1 &&
log_must zfs unmount $TESTPOOL/$TESTCTR/$TESTFS1
destroy_dataset "$TESTPOOL/$TESTCTR/$TESTFS1" "-R"
@ -907,8 +898,7 @@ function set_partition
parted $disk -s -- print 1 >/dev/null
typeset ret_val=$?
if [[ $slicenum -eq 0 || $ret_val -ne 0 ]]; then
parted $disk -s -- mklabel gpt
if [[ $? -ne 0 ]]; then
if ! parted $disk -s -- mklabel gpt; then
log_note "Failed to create GPT partition table on $disk"
return 1
fi
@ -945,8 +935,7 @@ function set_partition
if [[ $slicenum -eq 0 ]] || ! gpart show $disk >/dev/null 2>&1; then
gpart destroy -F $disk >/dev/null 2>&1
gpart create -s GPT $disk
if [[ $? -ne 0 ]]; then
if ! gpart create -s GPT $disk; then
log_note "Failed to create GPT partition table on $disk"
return 1
fi
@ -1144,9 +1133,8 @@ function fill_fs # destdir dirnum filenum bytes num_writes data
mkdir -p $destdir/{1..$dirnum}
for f in $destdir/{1..$dirnum}/$TESTFILE{1..$filenum}; do
file_write -o create -f $f -b $bytes -c $num_writes -d $data \
|| return $?
|| return
done
return 0
}
# Get the specified dataset property in parsable format or fail
@ -1835,8 +1823,7 @@ function zfs_zones_setup #zone_name zone_root zone_ip
log_must rm -f $zone_conf
# Install the zone
zoneadm -z $zone_name install
if (($? == 0)); then
if zoneadm -z $zone_name install; then
log_note "SUCCESS: zoneadm -z $zone_name install"
else
log_fail "FAIL: zoneadm -z $zone_name install"
@ -1899,14 +1886,10 @@ function check_state # pool disk state{online,offline,degraded}
if [[ -z $disk ]]; then
#check pool state only
zpool get -H -o value health $pool \
| grep -i "$state" > /dev/null 2>&1
zpool get -H -o value health $pool | grep -qi "$state"
else
zpool status -v $pool | grep "$disk" \
| grep -i "$state" > /dev/null 2>&1
zpool status -v $pool | grep "$disk" | grep -qi "$state"
fi
return $?
}
#
@ -1980,10 +1963,10 @@ function verify_filesys # pool filesystem dir
log_must zpool import $search_path $pool
zdb -cudi $filesys > $zdbout 2>&1
if [[ $? != 0 ]]; then
if ! zdb -cudi $filesys > $zdbout 2>&1; then
log_note "Output: zdb -cudi $filesys"
cat $zdbout
rm -f $zdbout
log_fail "zdb detected errors with: '$filesys'"
fi
@ -2056,10 +2039,8 @@ function stress_timeout
log_note "Killing child processes after ${TIMEOUT} stress timeout."
typeset pid
for pid in $cpids; do
ps -p $pid > /dev/null 2>&1
if (($? == 0)); then
ps -p $pid > /dev/null 2>&1 &&
log_must kill -USR1 $pid
fi
done
}
@ -2201,55 +2182,46 @@ function is_pool_resilvering #pool <verbose>
{
check_pool_status "$1" "scan" \
"resilver[ ()0-9A-Za-z:_-]* in progress since" $2
return $?
}
function is_pool_resilvered #pool <verbose>
{
check_pool_status "$1" "scan" "resilvered " $2
return $?
}
function is_pool_scrubbing #pool <verbose>
{
check_pool_status "$1" "scan" "scrub in progress since " $2
return $?
}
function is_pool_scrubbed #pool <verbose>
{
check_pool_status "$1" "scan" "scrub repaired" $2
return $?
}
function is_pool_scrub_stopped #pool <verbose>
{
check_pool_status "$1" "scan" "scrub canceled" $2
return $?
}
function is_pool_scrub_paused #pool <verbose>
{
check_pool_status "$1" "scan" "scrub paused since " $2
return $?
}
function is_pool_removing #pool
{
check_pool_status "$1" "remove" "in progress since "
return $?
}
function is_pool_removed #pool
{
check_pool_status "$1" "remove" "completed on"
return $?
}
function is_pool_discarding #pool
{
check_pool_status "$1" "checkpoint" "discarding"
return $?
}
function wait_for_degraded
@ -2338,22 +2310,17 @@ BEGIN { FS="."; }
unused=""
for disk in $disks; do
# Check for mounted
grep "${disk}[sp]" /etc/mnttab >/dev/null
(($? == 0)) && continue
grep -q "${disk}[sp]" /etc/mnttab && continue
# Check for swap
grep "${disk}[sp]" $sfi >/dev/null
(($? == 0)) && continue
grep -q "${disk}[sp]" $sfi && continue
# check for dump device
grep "${disk}[sp]" $dmpi >/dev/null
(($? == 0)) && continue
grep -q "${disk}[sp]" $dmpi && continue
# check to see if this disk hasn't been explicitly excluded
# by a user-set environment variable
echo "${ZFS_HOST_DEVICES_IGNORE}" | grep "${disk}" > /dev/null
(($? == 0)) && continue
echo "${ZFS_HOST_DEVICES_IGNORE}" | grep -q "${disk}" && continue
unused_candidates="$unused_candidates $disk"
done
rm $sfi
rm $dmpi
rm $sfi $dmpi
# now just check to see if those disks do actually exist
# by looking for a device pointing to the first slice in
@ -2386,10 +2353,8 @@ function add_user_freebsd #<group_name> <user_name> <basedir>
# Assign 1000 as the base uid
typeset -i uid=1000
while true; do
typeset -i ret
pw useradd -u $uid -g $group -d $basedir/$user -m -n $user
ret=$?
case $ret in
case $? in
0) break ;;
# The uid is not unique
65) ((uid += 1)) ;;
@ -2440,8 +2405,7 @@ function add_group_freebsd #<group_name>
typeset -i gid=1000
while true; do
pw groupadd -g $gid -n $group > /dev/null 2>&1
typeset -i ret=$?
case $ret in
case $? in
0) return 0 ;;
# The gid is not unique
65) ((gid += 1)) ;;
@ -2463,8 +2427,7 @@ function del_group_freebsd #<group_name>
typeset group=$1
pw groupdel -n $group > /dev/null 2>&1
typeset -i ret=$?
case $ret in
case $? in
# Group does not exist, or was deleted successfully.
0|6|65) return 0 ;;
# Name already exists as a group name
@ -2504,8 +2467,7 @@ function add_group_illumos #<group_name>
typeset -i gid=100
while true; do
groupadd -g $gid $group > /dev/null 2>&1
typeset -i ret=$?
case $ret in
case $? in
0) return 0 ;;
# The gid is not unique
4) ((gid += 1)) ;;
@ -2519,8 +2481,7 @@ function del_group_illumos #<group_name>
typeset group=$1
groupmod -n $grp $grp > /dev/null 2>&1
typeset -i ret=$?
case $ret in
case $? in
# Group does not exist.
6) return 0 ;;
# Name already exists as a group name
@ -2553,8 +2514,6 @@ function del_user_linux #<user_name>
if id $user > /dev/null 2>&1; then
log_must_retry "currently used" 6 userdel $user
fi
return 0
}
function add_group_linux #<group_name>
@ -2565,8 +2524,7 @@ function add_group_linux #<group_name>
# Linux because for many distributions 1000 and under are reserved.
while true; do
groupadd $group > /dev/null 2>&1
typeset -i ret=$?
case $ret in
case $? in
0) return 0 ;;
*) return 1 ;;
esac
@ -2578,8 +2536,7 @@ function del_group_linux #<group_name>
typeset group=$1
getent group $group > /dev/null 2>&1
typeset -i ret=$?
case $ret in
case $? in
# Group does not exist.
2) return 0 ;;
# Name already exists as a group name
@ -2858,7 +2815,6 @@ function get_config
{
typeset pool=$1
typeset config=$2
typeset alt_root
if ! poolexists "$pool" ; then
return 1
@ -2987,8 +2943,7 @@ function get_rootfs
if [[ -z "$rootfs" ]]; then
log_fail "Can not get rootfs"
fi
zfs list $rootfs > /dev/null 2>&1
if (($? == 0)); then
if datasetexists $rootfs; then
echo $rootfs
else
log_fail "This is not a zfsroot system."
@ -3119,14 +3074,12 @@ function vdevs_in_pool
# therefore we use the 'zpool status' output.
typeset tmpfile=$(mktemp)
zpool status -v "$pool" | grep -A 1000 "config:" >$tmpfile
for vdev in $@; do
grep -w ${vdev##*/} $tmpfile >/dev/null 2>&1
[[ $? -ne 0 ]] && return 1
for vdev in "$@"; do
grep -wq ${vdev##*/} $tmpfile || && return 1
done
rm -f $tmpfile
return 0;
return 0
}
function get_max
@ -3385,9 +3338,7 @@ function zed_check
return
fi
zedpids="$(pgrep -x zed)"
# ret1=$?
zedpids2="$(pgrep -x lt-zed)"
# ret2=$?
echo ${zedpids} ${zedpids2}
}
@ -3589,18 +3540,14 @@ function set_tunable_impl
case "$(uname)" in
Linux)
typeset zfs_tunables="/sys/module/$module/parameters"
[[ -w "$zfs_tunables/$tunable" ]] || return 1
cat >"$zfs_tunables/$tunable" <<<"$value"
return $?
echo "$value" >"$zfs_tunables/$tunable"
;;
FreeBSD)
sysctl vfs.zfs.$tunable=$value
return "$?"
;;
SunOS)
[[ "$module" -eq "zfs" ]] || return 1
echo "${tunable}/${mdb_cmd}0t${value}" | mdb -kw
return $?
;;
esac
}
@ -3635,9 +3582,7 @@ function get_tunable_impl
case "$(uname)" in
Linux)
typeset zfs_tunables="/sys/module/$module/parameters"
[[ -f "$zfs_tunables/$tunable" ]] || return 1
cat $zfs_tunables/$tunable
return $?
;;
FreeBSD)
sysctl -n vfs.zfs.$tunable
@ -3646,69 +3591,6 @@ function get_tunable_impl
[[ "$module" -eq "zfs" ]] || return 1
;;
esac
return 1
}
#
# Prints the current time in seconds since UNIX Epoch.
#
function current_epoch
{
printf '%(%s)T'
}
#
# Get decimal value of global uint32_t variable using mdb.
#
function mdb_get_uint32
{
typeset variable=$1
typeset value
value=$(mdb -k -e "$variable/X | ::eval .=U")
if [[ $? -ne 0 ]]; then
log_fail "Failed to get value of '$variable' from mdb."
return 1
fi
echo $value
return 0
}
#
# Set global uint32_t variable to a decimal value using mdb.
#
function mdb_set_uint32
{
typeset variable=$1
typeset value=$2
mdb -kw -e "$variable/W 0t$value" > /dev/null
if [[ $? -ne 0 ]]; then
echo "Failed to set '$variable' to '$value' in mdb."
return 1
fi
return 0
}
#
# Set global scalar integer variable to a hex value using mdb.
# Note: Target should have CTF data loaded.
#
function mdb_ctf_set_int
{
typeset variable=$1
typeset value=$2
mdb -kw -e "$variable/z $value" > /dev/null
if [[ $? -ne 0 ]]; then
echo "Failed to set '$variable' to '$value' in mdb."
return 1
fi
return 0
}
#
@ -4117,5 +3999,4 @@ function directory_diff # dir_a dir_b
function replay_directory_diff # dir_a dir_b
{
LIBTEST_DIFF_ZIL_REPLAY=1 directory_diff "$@"
return $?
}

View File

@ -98,7 +98,7 @@ function compare_acls #<src> <tgt>
get_acl $src > $tmpsrc
get_acl $tgt > $tmptgt
typeset -i ret=0
diff $tmpsrc $tmptgt > /dev/null 2>&1
cmp $tmpsrc $tmptgt > /dev/null
ret=$?
rm -f $tmpsrc $tmptgt
@ -108,7 +108,7 @@ function compare_acls #<src> <tgt>
get_compact_acl $src > $tmpsrc
get_compact_acl $tgt > $tmptgt
diff $tmpsrc $tmptgt > /dev/null 2>&1
cmp $tmpsrc $tmptgt > /dev/null
ret=$?
rm -f $tmpsrc $tmptgt
@ -166,7 +166,7 @@ function compare_xattrs #<src> <tgt>
get_xattr $src > $tmpsrc
get_xattr $tgt > $tmptgt
typeset -i ret=0
diff $tmpsrc $tmptgt > /dev/null 2>&1
cmp $tmpsrc $tmptgt > /dev/null
ret=$?
rm -f $tmpsrc $tmptgt
@ -284,8 +284,7 @@ function get_ACE #<file or dir name> <specified number> <verbose|compact>
;;
esac
ls $args $file > $tmpfile
(( $? != 0 )) && log_fail "FAIL: ls $args $file > $tmpfile"
log_must eval "ls $args $file > $tmpfile"
while read line; do
[[ -z $line ]] && continue
if [[ $args == -vd ]]; then
@ -306,8 +305,7 @@ function get_ACE #<file or dir name> <specified number> <verbose|compact>
fi
done < $tmpfile
rm -f $tmpfile
(( $? != 0 )) && log_fail "FAIL: rm -f $tmpfile"
log_must rm -f $tmpfile
}
#
@ -362,30 +360,30 @@ function rwx_node #user node acl_spec|access
case $acl_spec in
*:read_data:*|read_data)
chgusr_exec $user ls -l $node > /dev/null 2>&1
return $? ;;
;;
*:write_data:*|write_data)
if [[ -f ${node}/tmpfile ]]; then
log_must rm -f ${node}/tmpfile
fi
chgusr_exec $user touch ${node}/tmpfile > \
/dev/null 2>&1
return $? ;;
;;
*"execute:"*|execute)
chgusr_exec $user find $node > /dev/null 2>&1
return $? ;;
;;
esac
else
case $acl_spec in
*:read_data:*|read_data)
chgusr_exec $user cat $node > /dev/null 2>&1
return $? ;;
;;
*:write_data:*|write_data)
chgusr_exec $user dd if=/usr/bin/ls of=$node > \
/dev/null 2>&1
return $? ;;
;;
*"execute:"*|execute)
ZFS_ACL_ERR_STR=$(chgusr_exec $user $node 2>&1)
return $? ;;
;;
esac
fi
}
@ -459,9 +457,7 @@ function get_user_group #uid
log_fail "UID not defined."
fi
value=$(id $uid)
if [[ $? -eq 0 ]]; then
if value=$(id $uid); then
value=${value##*\(}
value=${value%%\)*}
echo $value

View File

@ -57,9 +57,13 @@ log_onexit cleanup
log_note "Testing access to FILE"
log_must touch $TESTDIR/file.0
log_must setfacl -m g:$ZFS_ACL_STAFF_GROUP:rw $TESTDIR/file.0
getfacl $TESTDIR/file.0 2> /dev/null | grep -q \
"^group:$ZFS_ACL_STAFF_GROUP:rw-$"
if [ "$?" -eq "0" ]; then
if ! getfacl $TESTDIR/file.0 2> /dev/null |
grep -qFx "group:$ZFS_ACL_STAFF_GROUP:rw-"
then
log_note "$(getfacl $TESTDIR/file.0 2> /dev/null)"
log_fail "Group '$ZFS_ACL_STAFF_GROUP' does not have 'rw' as specified"
fi
# Should be able to write to file
log_must user_run $ZFS_ACL_STAFF1 \
"echo 'echo test > /dev/null' > $TESTDIR/file.0"
@ -70,16 +74,16 @@ if [ "$?" -eq "0" ]; then
log_must chmod 700 $TESTDIR/dir.0
log_must setfacl -m g:$ZFS_ACL_STAFF_GROUP:rw $TESTDIR/dir.0
# Confirm permissions
if ! ls -l $TESTDIR | grep "dir.0" | grep -q "drwxrw----+"; then
msk=$(ls -l $TESTDIR | awk '/dir.0/ {print $1}')
msk=$(ls -ld $TESTDIR/dir.0 | awk '{print $1}')
if ! [ "$msk" = "drwxrw----+" ]; then
log_note "expected mask drwxrw----+ but found $msk"
log_fail "Expected permissions were not set."
fi
getfacl $TESTDIR/dir.0 2> /dev/null | grep -q \
"^group:$ZFS_ACL_STAFF_GROUP:rw-$"
if [ "$?" -ne "0" ]; then
acl=$(getfacl $TESTDIR/dir.0 2> /dev/null)
log_note $acl
if ! getfacl $TESTDIR/dir.0 2> /dev/null |
grep -qFx "group:$ZFS_ACL_STAFF_GROUP:rw-"
then
log_note "$(getfacl $TESTDIR/dir.0 2> /dev/null)"
log_fail "ACL group:$ZFS_ACL_STAFF_GROUP:rw- was not set."
fi
# Should NOT be able to create new file
@ -91,6 +95,3 @@ if [ "$?" -eq "0" ]; then
log_mustnot user_run $ZFS_ACL_STAFF1 $TESTDIR/file.0
log_pass "POSIX ACL mode works on files"
else
log_fail "Group '$ZFS_ACL_STAFF_GROUP' does not have 'rw' as specified"
fi

View File

@ -58,9 +58,9 @@ if ! ls -l $TESTDIR | grep "dir.0" | grep -q "drwx-wx---+"; then
log_note "expected mask drwx-wx---+ but found $msk"
log_fail "Expected permissions were not set."
fi
getfacl $TESTDIR/dir.0 2> /dev/null | grep -q \
"^group:$ZFS_ACL_STAFF_GROUP:-wx$"
if [ "$?" -eq "0" ]; then
if getfacl $TESTDIR/dir.0 2> /dev/null |
grep -q "^group:$ZFS_ACL_STAFF_GROUP:-wx$"
then
# Should be able to create file in directory
log_must user_run $ZFS_ACL_STAFF1 "touch $TESTDIR/dir.0/file.0"

View File

@ -59,12 +59,6 @@ function cleanup {
fi
}
zpool set 2>&1 | grep bootfs > /dev/null
if [ $? -ne 0 ]
then
log_unsupported "bootfs pool property not supported on this release."
fi
log_assert "Valid datasets are accepted as bootfs property values"
log_onexit cleanup

View File

@ -60,12 +60,6 @@ function cleanup {
}
zpool set 2>&1 | grep bootfs > /dev/null
if [ $? -ne 0 ]
then
log_unsupported "bootfs pool property not supported on this release."
fi
log_assert "Invalid datasets are rejected as boot property values"
log_onexit cleanup

View File

@ -54,12 +54,6 @@ function cleanup {
}
zpool set 2>&1 | grep bootfs > /dev/null
if [ $? -ne 0 ]
then
log_unsupported "bootfs pool property not supported on this release."
fi
log_onexit cleanup
log_assert "Valid pool names are accepted by zpool set bootfs"

View File

@ -55,12 +55,6 @@ function cleanup {
}
zpool set 2>&1 | grep bootfs > /dev/null
if [ $? -ne 0 ]
then
log_unsupported "bootfs pool property not supported on this release."
fi
log_assert "Invalid pool names are rejected by zpool set bootfs"
log_onexit cleanup

View File

@ -44,12 +44,6 @@
verify_runnable "global"
zpool set 2>&1 | grep bootfs > /dev/null
if [ $? -ne 0 ]
then
log_unsupported "bootfs pool property not supported on this release."
fi
VDEV1=$TESTDIR/bootfs_006_pos_a.$$.dat
VDEV2=$TESTDIR/bootfs_006_pos_b.$$.dat
VDEV3=$TESTDIR/bootfs_006_pos_c.$$.dat

View File

@ -29,10 +29,7 @@
# looks for return values that correspond to a core dump and cause a test
# failure.
btree_test -n insert_duplicate
[[ $? -eq 0 ]] && log_fail "Failure from insert_duplicate"
btree_test -n remove_missing
[[ $? -eq 0 ]] && log_fail "Failure from remove_missing"
btree_test -n insert_duplicate && log_fail "Failure from insert_duplicate"
btree_test -n remove_missing && log_fail "Failure from remove_missing"
log_pass "Btree negative tests passed"

View File

@ -146,9 +146,3 @@ function verify_cache_device
log_note "Can not find device: $device"
return 1
}
function verify_cache_support
{
zpool upgrade -v | grep "Cache devices" > /dev/null 2>&1
return $?
}

View File

@ -50,13 +50,8 @@ function delete_file
{
typeset name=$TESTDIR/$1
rm $name >/dev/null 2>&1
if [[ $? -ne 0 ]] ; then
return 1
fi
if [[ -f $name ]] ; then
rm $name >/dev/null 2>&1 || return 1
if [ -f $name ]; then
return 2
fi
}
@ -86,10 +81,7 @@ function lookup_file_ci
function lookup_any
{
for name in $NAMES_ALL ; do
lookup_file $name
if [[ $? -eq 0 ]] ; then
return 0
fi
lookup_file $name && return
done
return 1

View File

@ -47,9 +47,10 @@ function log_program
zfs program $cmdargs >$tmpout 2>$tmperr
typeset ret=$?
log_note "input:\n$(cat $tmpin)"
log_note "output:\n$(cat $tmpout)"
log_note "error:\n$(cat $tmperr)"
log_note $'input:\n'"$(<$tmpin)"
log_note $'output:\n'"$(<$tmpout)"
log_note $'error:\n'"$(<$tmperr)"
log_note "ret: $ret"
#
# Verify correct return value
@ -64,35 +65,29 @@ function log_program
# respectively.
#
if [[ -f "$basename.out" ]] && [[ $expectexit -eq 0 ]]; then
outdiff=$(diff "$basename.out" "$tmpout")
if [[ $? -ne 0 ]]; then
if ! outdiff=$(diff "$basename.out" "$tmpout"); then
output=$(<$tmpout)
rm $tmpout $tmperr $tmpin
log_fail "Output mismatch. Expected:\n" \
"$(<$basename.out)\nBut got:\n$output\n" \
"Diff:\n$outdiff"
log_fail $'Output mismatch. Expected:\n' \
"$(<$basename.out)"$'\nBut got:\n'"$output"$'\n' \
$'Diff:\n'"$outdiff"
fi
elif [[ -f "$basename.err" ]] && [[ $expectexit -ne 0 ]]; then
outdiff=$(diff "$basename.err" "$tmperr")
if [[ $? -ne 0 ]]; then
if ! outdiff=$(diff "$basename.err" "$tmperr"); then
outputerror=$(<$tmperr)
rm $tmpout $tmperr $tmpin
log_fail "Error mismatch. Expected:\n" \
"$(<$basename.err)\nBut got:\n$outputerror\n" \
"Diff:\n$outdiff"
log_fail $'Error mismatch. Expected:\n' \
"$(<$basename.err)"$'\nBut got:\n'"$outputerror"$'\n' \
$'Diff:\n'"$outdiff"
fi
elif [[ -n $expecterror ]] && [[ $expectexit -ne 0 ]]; then
grep -q "$expecterror" $tmperr
if [[ $? -ne 0 ]]; then
if ! grep -q "$expecterror" $tmperr; then
outputerror=$(<$tmperr)
rm $tmpout $tmperr $tmpin
log_fail "Error mismatch. Expected to contain:\n" \
"$expecterror\nBut got:\n$outputerror\n"
log_fail $'Error mismatch. Expected to contain:\n' \
"$expecterror"$'\nBut got:\n'"$outputerror"$'\n'
fi
elif [[ $expectexit -ne 0 ]]; then

View File

@ -47,10 +47,8 @@ log_must add_user $QGROUP $QUSER2
#
# chmod 0750 $HOME
#
user_run $QUSER1 zfs list
if [ $? -ne 0 ]; then
user_run $QUSER1 zfs list ||
log_unsupported "Test user $QUSER1 cannot execute zfs utilities"
fi
DISK=${DISKS%% *}
default_setup $DISK

View File

@ -60,8 +60,8 @@ log_note "$DEVS"
log_must dd if=/dev/${DISK[0]} of=/dev/${DISK[1]} bs=1K count=256 conv=notrunc
for x in 0 1 ; do
config_count=$(zdb -l $DEV_RDSKDIR/${DISK[$x]} | grep -c features_for_read)
(( $? != 0)) && log_fail "failed to get config_count from DISK[$x]"
config_count=$(zdb -l $DEV_RDSKDIR/${DISK[$x]} | grep -c features_for_read) ||
log_fail "failed to get config_count from DISK[$x]"
log_note "vdev $x: message_count $config_count"
[ $config_count -ne ${config_count[$x]} ] && \
log_fail "zdb produces an incorrect number of configuration dumps."

View File

@ -53,13 +53,13 @@ log_note "file $init_data has object number $obj"
sync_pool $TESTPOOL
output=$(zdb -ddddddbbbbbb $TESTPOOL/$TESTFS $obj 2> /dev/null \
|grep -m 1 "L0 DVA" |head -n1)
| grep -m 1 "L0 DVA")
dva=$(sed -Ene 's/^.+DVA\[0\]=<([^>]+)>.*$/\1/p' <<< "$output")
log_note "block 0 of $init_data has a DVA of $dva"
cksum_expected=$(sed -Ene 's/^.+ cksum=([a-z0-9:]+)$/\1/p' <<< "$output")
log_note "expecting cksum $cksum_expected"
output=$(zdb -R $TESTPOOL $dva:c 2> /dev/null)
result=$(grep $cksum_expected <<< "$output")
(( $? != 0 )) && log_fail "zdb -R failed to print the correct checksum"
grep -q $cksum_expected <<<"$output" ||
log_fail "zdb -R failed to print the correct checksum"
log_pass "zdb -R generates the correct checksum"

View File

@ -63,52 +63,44 @@ done
sync_pool $TESTPOOL true
# get object number of file
listing=$(ls -i $init_data)
set -A array $listing
obj=${array[0]}
read -r obj _ < <(ls -i $init_data)
log_note "file $init_data has object number $obj"
output=$(zdb -Zddddddbbbbbb $TESTPOOL/$TESTFS $obj 2> /dev/null \
|grep -m 1 "L0 DVA" |head -n1)
| grep -m 1 "L0 DVA")
dva=$(sed -Ene 's/^.+DVA\[0\]=<([^>]+)>.*$/\1/p' <<< "$output")
log_note "block 0 of $init_data has a DVA of $dva"
# use the length reported by zdb -ddddddbbbbbb
size_str=$(sed -Ene 's/^.+ size=([^ ]+) .*$/\1/p' <<< "$output")
# convert sizes to decimal
lsize=$(echo $size_str | cut -d/ -f 1)
IFS='/' read -r lsize psize _ <<<"$size_str"
lsize_orig=$lsize
lsize=${lsize%?}
lsize_bytes=$((16#$lsize))
psize=$(echo $size_str | cut -d/ -f 2)
psize_orig=$psize
lsize=${lsize%?}
psize=${psize%?}
lsize_bytes=$((16#$lsize))
psize_bytes=$((16#$psize))
log_note "block size $size_str"
# Get the ZSTD header reported by zdb -Z
zstd_str=$(sed -Ene 's/^.+ ZSTD:size=([^:]+):version=([^:]+):level=([^:]+):.*$/\1:\2:\3/p' <<< "$output")
zstd_size=$(echo "$zstd_str" | cut -d: -f 1)
read -r zstd_size zstd_version zstd_level < <(sed -Ene 's/^.+ ZSTD:size=([^:]+):version=([^:]+):level=([^:]+):.*$/\1 \2 \3/p' <<<"$output")
log_note "ZSTD compressed size $zstd_size"
(( $psize_bytes < $zstd_size )) && log_fail \
"zdb -Z failed: physical block size was less than header content length ($psize_bytes < $zstd_size)"
zstd_version=$(echo "$zstd_str" | cut -d: -f 2)
log_note "ZSTD version $zstd_version"
zstd_level=$(echo "$zstd_str" | cut -d: -f 3)
log_note "ZSTD level $zstd_level"
(( $zstd_level != $random_level )) && log_fail \
"zdb -Z failed: compression level did not match header level ($zstd_level < $random_level)"
vdev=$(echo "$dva" | cut -d: -f 1)
offset=$(echo "$dva" | cut -d: -f 2)
IFS=':' read -r vdev offset _ <<<"$dva"
# Check the first 1024 bytes
output=$(ZDB_NO_ZLE="true" zdb -R $TESTPOOL $vdev:$offset:$size_str:dr 2> /dev/null)
outsize=$(wc -c <<< "$output")
(( $outsize != $blksize )) && log_fail \
"zdb -Z failed to decompress the data to the expected length ($outsize != $lsize_bytes)"
cmp $init_data - <<< "$output"
(( $? != 0 )) && log_fail "zdb -R :dr failed to decompress the data properly"
(( ${#output} + 1 != $blksize )) && log_fail \
"zdb -Z failed to decompress the data to the expected length (${#output} != $lsize_bytes)"
cmp $init_data - <<< "$output" ||
log_fail "zdb -R :dr failed to decompress the data properly"
log_pass "zdb -Z flag (ZSTD compression header) works as expected"

View File

@ -65,8 +65,7 @@ while (( $j < ${#size[*]} )); do
typeset cmdline="zfs create -s -V ${size[j]} \
$TESTPOOL/${TESTVOL}${size[j]}"
str=$(eval $cmdline 2>&1)
if (( $? == 0 )); then
if str=$(eval $cmdline 2>&1); then
log_note "SUCCESS: $cmdline"
log_must datasetexists $TESTPOOL/${TESTVOL}${size[j]}
elif [[ $str == *${VOL_LIMIT_KEYWORD1}* || \

View File

@ -63,8 +63,7 @@ while (( $j < ${#size[*]} )); do
typeset cmdline="zfs create -s -V ${size[j]} \
$TESTPOOL/${LONGFSNAME}${size[j]}"
str=$(eval $cmdline 2>&1)
if (( $? == 0 )); then
if str=$(eval $cmdline 2>&1); then
log_note "SUCCESS: $cmdline"
log_must datasetexists $TESTPOOL/${LONGFSNAME}${size[j]}
elif [[ $str == *${VOL_LIMIT_KEYWORD1}* || \

View File

@ -87,12 +87,11 @@ function dry_create_parseable
typeset found_create=false
log_note "$0: ${cmd[@]}"
out=$("${cmd[@]}")
(( $? == 0 )) ||
out=$("${cmd[@]}") ||
log_fail "unexpected failure getting stdout from '${cmd[@]}'"
datasetexists "$TESTPOOL/$TESTFS1" &&
log_fail "$TESTPOOL/$TESTFS1 unexpectedly created by '${cmd[@]}'"
echo "$out" | while IFS=$'\t' read -A toks; do
while IFS=$'\t' read -A toks; do
log_note "verifying ${toks[@]}"
case ${toks[0]} in
create)
@ -118,7 +117,7 @@ function dry_create_parseable
log_fail "Unexpected line ${toks[@]}"
;;
esac
done
done <<<"$out"
log_must test "$found_create" == "yes, I found create"
log_must test "extra props: ${!exp[@]}" == "extra props: "

View File

@ -58,12 +58,11 @@ function dry_create_parseable
done
log_note "$0: ${cmd[@]}"
out=$("${cmd[@]}")
(( $? == 0 )) ||
out=$("${cmd[@]}") ||
log_fail "unexpected failure getting stdout from '${cmd[@]}'"
datasetexists "$TESTPOOL/$TESTFS1" ||
log_fail "$TESTPOOL/$TESTFS1 unexpectedly created by '${cmd[@]}'"
echo "$out" | while IFS=$'\t' read -A toks; do
while IFS=$'\t' read -A toks; do
log_note "verifying ${toks[@]}"
case ${toks[0]} in
create_ancestors)
@ -107,7 +106,7 @@ function dry_create_parseable
log_fail "Unexpected line ${toks[@]}"
;;
esac
done
done <<<"$out"
log_must test "$found_create" == "yes, I found create"
log_must test "extra props: ${!exp[@]}" == "extra props: "

View File

@ -85,7 +85,7 @@ for dst in ${dataset[@]}; do
for opt in "" $(gen_option_str "${options[*]}" "-" "" $opt_numb); do
for prop in $(gen_option_str "${props[*]}" "" "," $prop_numb)
do
log_must eval "zfs get $opt $prop $dst > /dev/null"
log_must eval "zfs get $opt $prop $dst > /dev/null 2>&1"
done
done
done

View File

@ -93,7 +93,7 @@ function test_options
for dst in ${dataset[@]}; do
for opt in $opts; do
for prop in $props; do
log_mustnot eval "zfs get $opt -- $prop $dst > /dev/null"
log_mustnot eval "zfs get $opt -- $prop $dst > /dev/null 2>&1"
done
done
done
@ -113,7 +113,7 @@ function test_options_bookmarks
for dst in ${bookmark[@]}; do
for opt in $opts; do
for prop in $props; do
log_mustnot eval "zfs get $opt -- $prop $dst > /dev/null"
log_mustnot eval "zfs get $opt -- $prop $dst > /dev/null 2>&1"
done
done
done

View File

@ -53,7 +53,7 @@ set -A options " " "-r" "-H" "-p" "-rHp" "-o name" \
set -A props type used available creation volsize referenced compressratio \
mounted origin recordsize quota reservation mountpoint sharenfs \
checksum compression atime devices exec readonly setuid snapdir \
aclinherit canmount primarycache secondarycache \
aclinherit canmount primarycache secondarycache version \
usedbychildren usedbydataset usedbyrefreservation usedbysnapshots \
userquota@root groupquota@root userused@root groupused@root
if is_freebsd; then
@ -62,11 +62,6 @@ else
set -A props ${props[*]} zoned acltype
fi
zfs upgrade -v > /dev/null 2>&1
if [[ $? -eq 0 ]]; then
set -A props ${props[*]} version
fi
set -A dataset $TESTPOOL/$TESTCTR $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL \
$TESTPOOL/$TESTFS@$TESTSNAP $TESTPOOL/$TESTVOL@$TESTSNAP

View File

@ -55,7 +55,7 @@ log_onexit depth_fs_cleanup
set -A all_props type used available creation volsize referenced \
compressratio mounted origin recordsize quota reservation mountpoint \
sharenfs checksum compression atime devices exec readonly setuid \
snapdir aclinherit canmount primarycache secondarycache \
snapdir aclinherit canmount primarycache secondarycache version \
usedbychildren usedbydataset usedbyrefreservation usedbysnapshots \
userquota@root groupquota@root userused@root groupused@root
if is_freebsd; then
@ -64,11 +64,6 @@ else
set -A all_props ${all_props[*]} zoned acltype
fi
zfs upgrade -v > /dev/null 2>&1
if [[ $? -eq 0 ]]; then
set -A all_props ${all_props[*]} version
fi
depth_fs_setup
mntpnt=$(get_prop mountpoint $DEPTH_FS)

View File

@ -47,14 +47,7 @@ verify_runnable "both"
# Define uninherited properties and their short name.
typeset props_str="type used available avail creation referenced refer \
compressratio ratio mounted origin quota reservation \
reserv volsize volblocksize volblock"
zfs upgrade -v > /dev/null 2>&1
if [[ $? -eq 0 ]]; then
props_str="$props_str version"
fi
set -A prop $props_str canmount
reserv volsize volblocksize volblock version canmount"
log_assert "'zfs inherit' should return an error when attempting to inherit" \

View File

@ -42,8 +42,7 @@ function key_available
function key_unavailable
{
key_available $1 && return 1
return 0
! key_available $1
}
function verify_keyformat

View File

@ -77,14 +77,13 @@ cd $TESTDIR || \
zfs $mountcmd $TESTPOOL/$TESTFS
ret=$?
if is_linux || is_freebsd; then
(( ret == 0 )) || \
log_fail "'zfs $mountcmd $TESTPOOL/$TESTFS' " \
"unexpected return code of $ret."
expected=0
else
(( ret == 1 )) || \
expected=1
fi
(( ret == expected )) || \
log_fail "'zfs $mountcmd $TESTPOOL/$TESTFS' " \
"unexpected return code of $ret."
fi
log_note "Make sure the filesystem $TESTPOOL/$TESTFS is unmounted"
if is_linux || is_freebsd; then

View File

@ -105,10 +105,7 @@ for orig_fs in $datasets ; do
typeset -i i=0
while (( i < ${#orig_snap[*]} )); do
file_write -o create -f ${orig_data[$i]} -b 512 \
-c 8 >/dev/null 2>&1
(( $? != 0 )) && \
log_fail "Writing data into zfs filesystem fails."
log_must eval "file_write -o create -f ${orig_data[$i]} -b 512 -c 8 >/dev/null 2>&1"
log_must zfs snapshot ${orig_snap[$i]}
if (( i < 1 )); then
log_must eval "zfs send ${orig_snap[$i]} > ${bkup[$i]}"

View File

@ -92,11 +92,10 @@ typeset -i i=0
while (( i < ${#validopts[*]} )); do
log_mustnot eval "zfs recv < $bkup"
echo ${validopts[i]} | grep "d" >/dev/null 2>&1
if (( $? != 0 )); then
log_mustnot eval "zfs recv ${validopts[i]} $fs2 $fs3 < $bkup"
else
if echo ${validopts[i]} | grep -q "d"; then
log_mustnot eval "zfs recv ${validopts[i]} $ctr1 $ctr2 < $bkup"
else
log_mustnot eval "zfs recv ${validopts[i]} $fs2 $fs3 < $bkup"
fi
(( i += 1 ))

View File

@ -33,11 +33,7 @@
default_cleanup_noexit
if [[ -d $TESTDIR2 ]]; then
rm -rf $TESTDIR2
if (( $? != 0 )); then
rm -rf $TESTDIR2 ||
log_unresolved Could not remove $TESTDIR2
fi
fi
log_pass

View File

@ -36,12 +36,9 @@ DISK=${DISKS%% *}
default_setup_noexit "$DISK" "true" "true"
if [[ -d $TESTDIR2 ]]; then
rm -rf $TESTDIR2
if (( $? != 0 )); then
rm -rf $TESTDIR2 ||
log_unresolved Could not remove $TESTDIR2
fi
fi
log_must zfs set compression=off $TESTPOOL/$TESTFS
log_must zfs create -o compression=off $TESTPOOL/$DATAFS
log_must zfs set mountpoint=$TESTDIR2 $TESTPOOL/$DATAFS

View File

@ -92,8 +92,7 @@ function cleanup
fi
if [[ ${dataset[i]}-new != *@* ]] ; then
zfs rename ${dataset[i]}-new ${dataset[i]}
if [[ $? -ne 0 ]]; then
if ! zfs rename ${dataset[i]}-new ${dataset[i]}; then
typeset newfs=${dataset[i]}-new
typeset oldfs=${dataset[i]}
typeset mntp=$(get_prop mountpoint $newfs)
@ -120,8 +119,6 @@ function cmp_data #<$1 src data, $2 tgt data>
typeset src=$1
typeset tgt=$2
cmp $src $tgt >/dev/null 2>&1
return $?
cmp $src $tgt >/dev/null
}

View File

@ -96,9 +96,7 @@ log_must zfs set mountpoint=$TESTDIR1 $rst_root
file_write -o create -f $init_data -b $BLOCK_SIZE -c $WRITE_COUNT
log_must zfs snapshot $init_snap
zfs send $init_snap > $full_bkup
(( $? != 0 )) && \
log_fail "'zfs send' fails to create full send"
log_must eval "zfs send $init_snap > $full_bkup"
log_note "Verify the send stream is valid to receive."
@ -111,9 +109,7 @@ log_note "Verify 'zfs send -i' can create incremental send stream."
file_write -o create -f $inc_data -b $BLOCK_SIZE -c $WRITE_COUNT -d 0
log_must zfs snapshot $inc_snap
zfs send -i $init_snap $inc_snap > $inc_bkup
(( $? != 0 )) && \
log_fail "'zfs send -i' fails to create incremental send"
log_must eval "zfs send -i $init_snap $inc_snap > $inc_bkup"
log_note "Verify the incremental send stream is valid to receive."

View File

@ -66,12 +66,8 @@ function do_testing # <prop> <prop_value>
log_must zfs set $property=$prop_val $fs
file_write -o create -f $origfile -b $BLOCK_SIZE -c $WRITE_COUNT
log_must zfs snapshot $snap
zfs send $snap > $stream
(( $? != 0 )) && \
log_fail "'zfs send' fails to create send streams."
zfs receive -d $ctr <$stream
(( $? != 0 )) && \
log_fail "'zfs receive' fails to receive send streams."
log_must eval "zfs send $snap > $stream"
log_must eval "zfs receive -d $ctr <$stream"
#verify receive result
! datasetexists $rstfs && \

View File

@ -91,9 +91,7 @@ typeset -i i=0
for ds in $pool $fs $vol; do
for propname in ${ro_prop[*]}; do
zfs get -pH -o value $propname $ds >/dev/null 2>&1
(( $? != 0 )) && \
log_fail "Get the property $proname of $ds failed."
log_must eval "zfs get -pH -o value $propname $ds >/dev/null 2>&1"
done
i=0
while (( i < ${#rw_prop[*]} )); do
@ -120,9 +118,7 @@ for ds in $pool $fs $vol; do
done
if [[ $ds == $vol ]]; then
for propname in "volblocksize" "volblock" ; do
zfs get -pH -o value $propname $ds >/dev/null 2>&1
(( $? != 0 )) && \
log_fail "Get the property $propname of $ds failed."
log_must eval "zfs get -pH -o value $propname $ds >/dev/null 2>&1"
done
fi
done

View File

@ -70,15 +70,7 @@ function set_n_check # data-set
j=0
while (( $j < ${#suffix[*]} )); do
zfs set \
reservation=${values[$i]}${suffix[$j]} $obj \
> /dev/null 2>&1
if [ $? -eq 0 ]
then
log_note "zfs set \
reservation=${values[$i]}${suffix[$j]} $obj"
log_fail "The above reservation set returned 0!"
fi
log_mustnot zfs set reservation=${values[$i]}${suffix[$j]} $obj
new_resv_val=$(get_prop reservation $obj)

View File

@ -55,18 +55,13 @@ typeset ro_props="type used creation referenced refer compressratio \
mounted origin"
typeset snap_ro_props="volsize recordsize recsize quota reservation reserv mountpoint \
sharenfs checksum compression compress atime devices exec readonly rdonly \
setuid"
setuid version"
if is_freebsd; then
snap_ro_props+=" jailed"
else
snap_ro_props+=" zoned"
fi
zfs upgrade -v > /dev/null 2>&1
if [[ $? -eq 0 ]]; then
snap_ro_props="$snap_ro_props version"
fi
function cleanup
{
datasetexists $TESTPOOL/$TESTVOL@$TESTSNAP && \

View File

@ -68,32 +68,19 @@ function nonexist_user_prop
log_assert "User property has no effect to snapshot until 'Snapshot properties' supported."
log_onexit cleanup
typeset snap_property=
zpool upgrade -v | grep "Snapshot properties" > /dev/null 2>&1
if (( $? == 0 )) ; then
snap_property="true"
fi
for fs in $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL $TESTPOOL ; do
typeset fssnap=$fs@snap
prop_name=$(valid_user_property 10)
value=$(user_property_value 16)
log_must eval "zfs set $prop_name='$value' $fs"
log_must eval "check_user_prop $fs $prop_name '$value'"
log_must zfs set $prop_name="$value" $fs
log_must check_user_prop $fs $prop_name "$value"
log_must zfs snapshot $fssnap
if [[ -n $snap_property ]] ; then
log_mustnot nonexist_user_prop $prop_name $fssnap
log_must eval "zfs set $prop_name='$value' $fssnap"
log_must zfs set $prop_name="$value" $fssnap
log_mustnot nonexist_user_prop $prop_name $fssnap
else
log_must nonexist_user_prop $prop_name $fssnap
log_mustnot eval "zfs set $prop_name='$value' $fssnap"
log_must nonexist_user_prop $prop_name $fssnap
fi
done
log_pass "User properties has effect upon snapshot."

View File

@ -66,11 +66,7 @@ function set_n_check # data-set
orig_val=$(get_prop version $obj)
while (($i < ${#values[*]})); do
zfs set version=${values[$i]} $obj > /dev/null 2>&1
if [[ $? -eq 0 ]]; then
log_note "zfs set version=${values[$i]} $obj"
log_fail "The above version set returned 0!"
fi
log_mustnot eval "zfs set version=${values[$i]} $obj > /dev/null 2>&1"
new_val=$(get_prop version $obj)

View File

@ -97,8 +97,8 @@ function set_n_check_prop
if [[ "$expect_value" != "" && "$cur_value" != "$old_value" ]];
then
log_fail "The '$dataset' '$prop' value '$cur_value' \
should equal with '$old_value'."
log_fail "The '$dataset' '$prop' value '$cur_value'" \
"should equal '$old_value'."
fi
fi
}
@ -119,8 +119,8 @@ function cleanup_user_prop
typeset prop
for prop in $user_prop; do
zfs inherit $prop $dt
(($? != 0)) && log_must zfs inherit $prop $dt
zfs inherit $prop $dt ||
log_must zfs inherit $prop $dt
done
done
}
@ -225,9 +225,7 @@ function user_property_value
{
typeset -i len=${1:-100}
typeset value=$(random_string ALL_CHAR $len)
echo "$value"
random_string ALL_CHAR $len
}
#
@ -254,14 +252,9 @@ function get_source
{
typeset prop=$1
typeset dataset=$2
typeset source
source=$(zfs get -H -o source $prop $dataset)
if (($? != 0)); then
zfs get -H -o source $prop $dataset ||
log_fail "Unable to get $prop source for dataset $dataset"
fi
echo "$source"
}
#
@ -330,12 +323,9 @@ function check_prop_received
typeset prop="$2"
typeset value="$3"
received=$(zfs get -H -o received "$prop" "$dataset")
if (($? != 0)); then
log_fail "Unable to get $prop received value for dataset" \
"$dataset"
fi
if [ "$received" = "$value" ]
received=$(zfs get -H -o received "$prop" "$dataset") ||
log_fail "Unable to get $prop received value for dataset $dataset"
[ "$received" = "$value" ]
}
#
@ -351,9 +341,7 @@ function check_prop_missing
typeset dataset="$1"
typeset prop="$2"
value=$(zfs get -H -o value "$prop" "$dataset")
if (($? != 0)); then
value=$(zfs get -H -o value "$prop" "$dataset") ||
log_fail "Unable to get $prop value for dataset $dataset"
fi
[ "$value" = "-" ]
}

View File

@ -72,20 +72,17 @@ while (( i < ${#shareopts[*]} ))
do
log_must zfs set sharenfs="${shareopts[i]}" $TESTPOOL/$TESTFS
option=`get_prop sharenfs $TESTPOOL/$TESTFS`
option=$(get_prop sharenfs $TESTPOOL/$TESTFS)
if [[ $option != ${shareopts[i]} ]]; then
log_fail "get sharenfs failed. ($option != ${shareopts[i]})"
fi
# Verify the single option after the leading 'ro' or 'rw'.
if is_linux; then
option=`echo "$option" | cut -f2 -d','`
IFS=',' read -r _ option _ <<<"$option"
fi
showshares_nfs | grep $option > /dev/null 2>&1
if (( $? != 0 )); then
log_fail "The '$option' option was not found in share output."
fi
log_must eval "showshares_nfs | grep -q $option"
((i = i + 1))
done

View File

@ -63,10 +63,7 @@ do
log_note "Setting sharenfs=${badopts[i]} $i "
log_mustnot zfs set sharenfs="${badopts[i]}" $TESTPOOL/$TESTFS
showshares_nfs | grep $option > /dev/null 2>&1
if (( $? == 0 )); then
log_fail "An invalid setting '$option' was propagated."
fi
log_mustnot eval "showshares_nfs | grep -q ${badopts[i]}"
#
# To global zone, sharenfs must be set 'off' before malformed testing.

View File

@ -63,8 +63,7 @@ if [[ $sharenfs_val == off ]]; then
log_must zfs set sharenfs=on $fs
fi
showshares_nfs | grep $mpt >/dev/null 2>&1
if (( $? != 0 )); then
if ! showshares_nfs | grep -q $mpt; then
log_must zfs share $fs
fi

View File

@ -59,18 +59,18 @@ while ((ret == 0)); do
ret=$?
if ((ret != 0)); then
len=$(echo $basefs| wc -c)
len=${#basefs}
log_note "The deeply-nested filesystem len: $len"
#
# Make sure there are at lease 2 characters left
# Make sure there are at least 2 characters left
# for snapshot name space, otherwise snapshot name
# is incorrect
#
if ((len >= 255)); then
datasetexists $basefs && destroy_dataset $basefs -r
basefs=${basefs%/*}
len=$(echo $basefs| wc -c)
len=${#basefs}
fi
break
fi

View File

@ -60,7 +60,7 @@ while ((ret == 0)); do
ret=$?
if ((ret != 0)); then
len=$(echo $basefs | wc -c)
len=$(( ${#basefs} + 1 )) # +1 for NUL
log_note "The deeply-nested filesystem len: $len"
#
@ -71,7 +71,7 @@ while ((ret == 0)); do
if ((len >= 255)); then
datasetexists $basefs && destroy_dataset $basefs -r
basefs=${basefs%/*}
len=$(echo $basefs| wc -c)
len=$(( ${#basefs} + 1 ))
fi
break
fi

View File

@ -72,18 +72,13 @@ typeset ro_props="type used available avail creation referenced refer compressra
mounted origin"
typeset snap_ro_props="volsize recordsize recsize quota reservation reserv mountpoint \
sharenfs checksum compression compress atime devices exec readonly rdonly \
setuid"
setuid version"
if is_freebsd; then
snap_ro_props+=" jailed"
else
snap_ro_props+=" zoned"
fi
zfs upgrade -v > /dev/null 2>&1
if [[ $? -eq 0 ]]; then
snap_ro_props="$snap_ro_props version"
fi
for fs in $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL $TESTPOOL/$TESTCTR $TESTPOOL ; do
typeset fssnap=$fs@snap

View File

@ -64,12 +64,8 @@ for ashift in ${ashifts[@]}
do
log_must zpool create $TESTPOOL $disk1
log_must zpool add -o ashift=$ashift $TESTPOOL $disk2
verify_ashift $disk2 $ashift
if [[ $? -ne 0 ]]
then
log_fail "Device was added without setting ashift value to "\
"$ashift"
fi
log_must verify_ashift $disk2 $ashift
# clean things for the next run
log_must zpool destroy $TESTPOOL
log_must zpool labelclear $disk1
@ -81,12 +77,8 @@ do
log_must zpool create $TESTPOOL $disk1
log_must set_tunable64 VDEV_FILE_PHYSICAL_ASHIFT $ashift
log_must zpool add $TESTPOOL $disk2
verify_ashift $disk2 $ashift
if [[ $? -ne 0 ]]
then
log_fail "Device was added without setting ashift value to "\
"$ashift"
fi
log_must verify_ashift $disk2 $ashift
# clean things for the next run
log_must set_tunable64 VDEV_FILE_PHYSICAL_ASHIFT $orig_ashift
log_must zpool destroy $TESTPOOL

View File

@ -70,12 +70,8 @@ for ashift in ${ashifts[@]}
do
log_must zpool create -o ashift=$ashift $TESTPOOL $disk1
log_must zpool add $TESTPOOL $disk2
verify_ashift $disk2 $ashift
if [[ $? -ne 0 ]]
then
log_fail "Device was added without setting ashift value to "\
"$ashift"
fi
log_must verify_ashift $disk2 $ashift
# clean things for the next run
log_must zpool destroy $TESTPOOL
log_must zpool labelclear $disk1
@ -88,12 +84,8 @@ do
do
log_must zpool create -o ashift=$ashift $TESTPOOL $disk1
log_must zpool add -o ashift=$cmdval $TESTPOOL $disk2
verify_ashift $disk2 $cmdval
if [[ $? -ne 0 ]]
then
log_fail "Device was added without setting ashift " \
"value to $cmdval"
fi
log_must verify_ashift $disk2 $cmdval
# clean things for the next run
log_must zpool destroy $TESTPOOL
log_must zpool labelclear $disk1

View File

@ -69,23 +69,14 @@ do
for cmdval in ${ashifts[@]}
do
log_must zpool create -o ashift=$ashift $TESTPOOL1 $disk1
verify_ashift $disk1 $ashift
if [[ $? -ne 0 ]]
then
log_fail "Pool was created without setting ashift " \
"value to $ashift"
fi
log_must verify_ashift $disk1 $ashift
# ashift_of(attached_disk) <= ashift_of(existing_vdev)
if [[ $cmdval -le $ashift ]]
then
log_must zpool attach -o ashift=$cmdval $TESTPOOL1 \
$disk1 $disk2
verify_ashift $disk2 $ashift
if [[ $? -ne 0 ]]
then
log_fail "Device was attached without " \
"setting ashift value to $ashift"
fi
log_must verify_ashift $disk2 $ashift
else
log_mustnot zpool attach -o ashift=$cmdval $TESTPOOL1 \
$disk1 $disk2

View File

@ -59,8 +59,7 @@ function write_device_uberblocks # <device> <pool>
typeset device=$1
typeset pool=$2
while [ "$(zdb -quuul $device | grep -c 'invalid')" -ne 0 ]
do
while zdb -quuul $device | grep -q 'invalid'; do
sync_pool $pool true
done
}
@ -89,8 +88,6 @@ function verify_device_uberblocks # <device> <count>
exit 1
}
}'
return $?
}
log_assert "zpool create -o ashift=<n>' works with different ashift values"
@ -114,11 +111,8 @@ do
"$ashift (current = $pprop)"
fi
write_device_uberblocks $disk $TESTPOOL
verify_device_uberblocks $disk ${ubcount[$i]}
if [[ $? -ne 0 ]]
then
log_fail "Pool was created with unexpected number of uberblocks"
fi
log_must verify_device_uberblocks $disk ${ubcount[$i]}
# clean things for the next run
log_must zpool destroy $TESTPOOL
log_must zpool labelclear $disk

View File

@ -75,11 +75,9 @@ log_onexit cleanup
for sdisk in $swap_disks; do
log_note "Executing: swap -d $sdisk"
swap -d $sdisk >/dev/null 2>&1;
if [[ $? != 0 ]]; then
swap -d $sdisk >/dev/null 2>&1 ||
log_untested "Unable to delete swap device $sdisk because of" \
"insufficient RAM"
fi
done
log_must zpool create $TESTPOOL $DISK0

View File

@ -75,25 +75,16 @@ log_must zpool get all $TESTPOOL
zpool get all $TESTPOOL > $values
# check for the cachefile property, verifying that it's set to 'none'
grep "$TESTPOOL[ ]*cachefile[ ]*none" $values > /dev/null 2>&1
if [ $? -ne 0 ]
then
log_fail "zpool property \'cachefile\' was not set to \'none\'."
fi
log_must grep -q "$TESTPOOL[ ]*cachefile[ ]*none" $values
# check that the root = /mountpoint property is set correctly
grep "$TESTPOOL[ ]*altroot[ ]*/${TESTPOOL}.root" $values > /dev/null 2>&1
if [ $? -ne 0 ]
then
log_fail "zpool property root was not found in pool output."
fi
log_must grep -q "$TESTPOOL[ ]*altroot[ ]*/${TESTPOOL}.root" $values
rm $values
# finally, check that the pool has no reference in /etc/zfs/zpool.cache
if [[ -f /etc/zfs/zpool.cache ]] ; then
REF=$(strings /etc/zfs/zpool.cache | grep ${TESTPOOL})
if [ ! -z "$REF" ]
if strings /etc/zfs/zpool.cache | grep -q ${TESTPOOL}
then
strings /etc/zfs/zpool.cache
log_fail "/etc/zfs/zpool.cache appears to have a reference to $TESTPOOL"

View File

@ -81,17 +81,13 @@ function zpool_stress
typeset retry=10
typeset j=0
truncate -s $FILESIZE $vdev0
truncate -s $FILESIZE $vdev1
truncate -s $FILESIZE $vdev0 $vdev1
while [[ $j -lt $iters ]]; do
((j = j + 1))
sleep 1
zpool create $pool $vdev0 $vdev1
if [ $? -ne 0 ]; then
return 1;
fi
zpool create $pool $vdev0 $vdev1 || return 1
# The 'zfs destroy' command is retried because it can
# transiently return EBUSY when blkid is concurrently
@ -100,13 +96,8 @@ function zpool_stress
while [[ $k -lt $retry ]]; do
((k = k + 1))
zpool destroy $pool
if [ $? -eq 0 ]; then
break;
elif [ $k -eq $retry ]; then
return 1;
fi
zpool destroy $pool && break
[ $k -eq $retry ] && return 1
sleep 3
done
done

View File

@ -37,7 +37,7 @@ function log_must_follow # <command>
sleep 3
kill $pid
if [[ $? -ne 0 ]]; then
log_fail "'$command' does not work as expected."
log_fail "'$command' exited early."
else
log_note "'$command' works successfully."
fi

View File

@ -50,10 +50,8 @@ log_must zpool create $NEWPOOL $DISK
log_must zpool events -c
# 3. Generate some ZFS events on both pools
for i in `seq 1 $EVENTS_NUM`; do
for i in {1..$EVENTS_NUM}; do
log_must zpool clear $TESTPOOL
done
for i in `seq 1 $EVENTS_NUM`; do
log_must zpool clear $NEWPOOL
done
# wait a bit to allow the kernel module to process new events
@ -61,14 +59,11 @@ zpool_events_settle
# 4. Verify 'zpool events poolname' successfully display events
zpool events -v $TESTPOOL |
awk -v POOL=$TESTPOOL '/pool = / {if ($3 != "\""POOL"\"") exit 1}'
if [[ $? -ne 0 ]]; then
awk -v POOL=$TESTPOOL '/pool = / && $3 != "\""POOL"\"" {exit 1}' ||
log_fail "Unexpected events for pools other than $TESTPOOL"
fi
zpool events -v $NEWPOOL |
awk -v POOL=$NEWPOOL '/pool = / {if ($3 != "\""POOL"\"") exit 1}'
if [[ $? -ne 0 ]]; then
awk -v POOL=$NEWPOOL '/pool = / && $3 != "\""POOL"\"" {exit 1}' ||
log_fail "Unexpected events for pools other than $NEWPOOL"
fi
log_pass "'zpool events poolname' display events only from the chosen pool."

View File

@ -128,7 +128,7 @@ for type in " " mirror raidz draid:1s; do
typeset size_addition=$(zpool history -il $TESTPOOL1 |\
grep "pool '$TESTPOOL1' size:" | \
grep "vdev online" | \
grep "(+${expansion_size}" | wc -l)
grep -c "(+${expansion_size}")
if [[ $size_addition -ne 3 ]]; then
log_fail "pool $TESTPOOL1 has not expanded, " \
@ -139,32 +139,23 @@ for type in " " mirror raidz draid:1s; do
zpool history -il $TESTPOOL1 | \
grep "pool '$TESTPOOL1' size:" | \
grep "vdev online" | \
grep "(+${expansion_size})" >/dev/null 2>&1
if [[ $? -ne 0 ]] ; then
grep -q "(+${expansion_size})" ||
log_fail "pool $TESTPOOL1 has not expanded"
fi
elif [[ $type == "draid:1s" ]]; then
typeset expansion_size=$((2*($exp_size-$org_size)))
zpool history -il $TESTPOOL1 | \
grep "pool '$TESTPOOL1' size:" | \
grep "vdev online" | \
grep "(+${expansion_size})" >/dev/null 2>&1
if [[ $? -ne 0 ]]; then
grep -q "(+${expansion_size})" ||
log_fail "pool $TESTPOOL has not expanded"
fi
else
typeset expansion_size=$((3*($exp_size-$org_size)))
zpool history -il $TESTPOOL1 | \
grep "pool '$TESTPOOL1' size:" | \
grep "vdev online" | \
grep "(+${expansion_size})" >/dev/null 2>&1
if [[ $? -ne 0 ]]; then
grep -q "(+${expansion_size})" ||
log_fail "pool $TESTPOOL has not expanded"
fi
fi
else
log_fail "pool $TESTPOOL1 is not autoexpanded after vdev " \
"expansion. Previous size: $zfs_prev_size and expanded " \

View File

@ -131,7 +131,7 @@ for type in " " mirror raidz draid:1s; do
typeset size_addition=$(zpool history -il $TESTPOOL1 \
| grep "pool '$TESTPOOL1' size:" | \
grep "vdev online" | \
grep "(+${expansion_size}" | wc -l)
grep -c "(+${expansion_size}")
if [[ $size_addition -ne $i ]]; then
log_fail "pool $TESTPOOL1 has not expanded " \
@ -143,35 +143,26 @@ for type in " " mirror raidz draid:1s; do
zpool history -il $TESTPOOL1 | \
grep "pool '$TESTPOOL1' size:" | \
grep "vdev online" | \
grep "(+${expansion_size})" >/dev/null 2>&1
if [[ $? -ne 0 ]]; then
grep -q "(+${expansion_size})" ||
log_fail "pool $TESTPOOL1 has not expanded " \
"after zpool online -e"
fi
elif [[ $type == "draid:1s" ]]; then
typeset expansion_size=$((2*($exp_size-$org_size)))
zpool history -il $TESTPOOL1 | \
grep "pool '$TESTPOOL1' size:" | \
grep "vdev online" | \
grep "(+${expansion_size})" >/dev/null 2>&1
if [[ $? -ne 0 ]] ; then
grep -q "(+${expansion_size})" ||
log_fail "pool $TESTPOOL1 has not expanded " \
"after zpool online -e"
fi
else
typeset expansion_size=$((3*($exp_size-$org_size)))
zpool history -il $TESTPOOL1 | \
grep "pool '$TESTPOOL1' size:" | \
grep "vdev online" | \
grep "(+${expansion_size})" >/dev/null 2>&1
if [[ $? -ne 0 ]] ; then
grep -q "(+${expansion_size})" ||
log_fail "pool $TESTPOOL1 has not expanded " \
"after zpool online -e"
fi
fi
else
log_fail "pool $TESTPOOL1 did not expand after vdev " \
"expansion and zpool online -e"

View File

@ -113,7 +113,7 @@ for type in "" mirror raidz draid; do
sleep 5
# check for zpool history for the pool size expansion
zpool history -il $TESTPOOL1 | grep "pool '$TESTPOOL1' size:" | \
zpool history -il $TESTPOOL1 | grep "pool '$TESTPOOL1' size:" |
grep "vdev online" &&
log_fail "pool $TESTPOOL1 is not autoexpand after vdev expansion"

View File

@ -45,9 +45,7 @@ verify_runnable "global"
function cleanup
{
cd $olddir || \
log_fail "Couldn't cd back to $olddir"
log_must cd $olddir
zpool_export_cleanup
}
@ -57,16 +55,9 @@ log_onexit cleanup
log_assert "Verify a busy ZPOOL cannot be exported."
ismounted "$TESTPOOL/$TESTFS"
(( $? != 0 )) && \
log_fail "$TESTDIR not mounted. Unable to continue."
cd $TESTDIR || \
log_fail "Couldn't cd to $TESTDIR"
log_must ismounted "$TESTPOOL/$TESTFS"
log_must cd $TESTDIR
log_mustnot zpool export $TESTPOOL
poolexists $TESTPOOL || \
log_fail "$TESTPOOL not found in 'zpool list' output."
log_must poolexists $TESTPOOL
log_pass "Unable to export a busy ZPOOL as expected."

View File

@ -66,22 +66,13 @@ log_must zpool get all $TESTPOOL
zpool get all $TESTPOOL > $values
log_note "Checking zpool get all output for a header."
grep ^"NAME " $values > /dev/null 2>&1
if [ $? -ne 0 ]
then
log_fail "The header was not printed from zpool get all"
fi
log_must grep -q ^"NAME " $values
while [ $i -lt "${#properties[@]}" ]
do
log_note "Checking for ${properties[$i]} property"
grep "$TESTPOOL *${properties[$i]}" $values > /dev/null 2>&1
if [ $? -ne 0 ]
then
log_fail "zpool property ${properties[$i]} was not found\
in pool output."
fi
log_must grep -q "$TESTPOOL *${properties[$i]}" $values
i=$(( $i + 1 ))
done

View File

@ -60,14 +60,10 @@ while [ $i -lt "${#properties[@]}" ]
do
log_note "Checking for ${properties[$i]} property"
log_must eval "zpool get ${properties[$i]} $TESTPOOL > $values"
grep "${properties[$i]}" $values > /dev/null 2>&1
if [ $? -ne 0 ]
then
log_fail "${properties[$i]} not seen in output"
fi
grep "^NAME " $values > /dev/null 2>&1
log_must grep -q "${properties[$i]}" $values
# only need to check this once.
if [ $i -eq 0 ] && [ $? -ne 0 ]
if [ $i -eq 0 ] && ! grep -q "^NAME " $values
then
log_fail "Header not seen in zpool get output"
fi

View File

@ -50,14 +50,8 @@ function dev_checksum
log_note "Compute checksum of '$dev'"
checksum=$(md5digest $dev)
if [[ $? -ne 0 ]]; then
md5digest $dev ||
log_fail "Failed to compute checksum of '$dev'"
return 1
fi
echo "$checksum"
return 0
}
function test_shared_device

View File

@ -133,12 +133,8 @@ function test_common
log_must zpool export $TESTPOOL1
zpool import -d $DEVICE_DIR -T $txg $TESTPOOL1
if (( $? == 0 )); then
verify_data_md5sums $MD5FILE
if (( $? == 0 )); then
retval=0
fi
if zpool import -d $DEVICE_DIR -T $txg $TESTPOOL1; then
verify_data_md5sums $MD5FILE && retval=0
log_must check_pool_config $TESTPOOL1 "$poolcheck"
log_must zpool destroy $TESTPOOL1

View File

@ -64,17 +64,13 @@ function write_some_data
typeset files10mb=${2:-10}
typeset ds="$pool/fillerds"
zfs create $ds
[[ $? -ne 0 ]] && return 1
zfs create $ds || return 1
# Create 100 MB of data
typeset file="/$ds/fillerfile"
for i in {1..$files10mb}; do
dd if=/dev/urandom of=$file.$i bs=128k count=80
[[ $? -ne 0 ]] && return 1
dd if=/dev/urandom of=$file.$i bs=128k count=80 || return 1
done
return 0
}
#
@ -180,20 +176,20 @@ function _translate_vdev
#
typeset keywords="mirror replacing raidz1 raidz2 raidz3 indirect draid1 draid2 draid3"
for word in $keywords; do
echo $vdev | grep -qE \
"^${word}-[0-9]+\$|^${word}:[0-9]+d:[0-9]c:[0-9]+s-[0-9]+\$"
if [[ $? -eq 0 ]]; then
if echo $vdev |
grep -qE "^${word}-[0-9]+\$|^${word}:[0-9]+d:[0-9]c:[0-9]+s-[0-9]+\$"
then
vdev=$word
break
fi
done
[[ $vdev == "logs" ]] && echo "log" && return 0
[[ $vdev == "raidz1" ]] && echo "raidz" && return 0
[[ $vdev == "draid1" ]] && echo "draid" && return 0
echo $vdev
return 0
case "$vdev" in
logs) echo "log" ;;
raidz1) echo "raidz" ;;
draid1) echo "draid" ;;
*) echo $vdev ;;
esac
}
#
@ -216,9 +212,8 @@ function check_pool_config
typeset expected=$2
typeset status
status=$(zpool status $poolname 2>&1)
if [[ $? -ne 0 ]]; then
if ( $logfailure ); then
if ! status=$(zpool status $poolname 2>&1); then
if $logfailure; then
log_note "zpool status $poolname failed: $status"
fi
return 1
@ -243,7 +238,7 @@ function check_pool_config
expected="$poolname $expected"
if [[ "$actual" != "$expected" ]]; then
if ( $logfailure ); then
if $logfailure; then
log_note "expected pool vdevs:"
log_note "> '$expected'"
log_note "actual pool vdevs:"
@ -270,13 +265,11 @@ function wait_for_pool_config
timeout=$(( $timeout + $(date +%s) ))
while (( $(date +%s) < $timeout )); do
check_pool_config -q $poolname "$expectedconfig"
[[ $? -eq 0 ]] && return 0
check_pool_config -q $poolname "$expectedconfig" && return 0
sleep 3
done
check_pool_config $poolname "$expectedconfig"
return $?
}
#
@ -285,10 +278,9 @@ function wait_for_pool_config
function check_pool_healthy
{
typeset pool=$1
typeset status
status=$(zpool status $pool 2>&1)
if [[ $? -ne 0 ]]; then
if ! status=$(zpool status $pool 2>&1); then
log_note "zpool status $pool failed: $status"
return 1
fi

View File

@ -165,10 +165,9 @@ for option in "" "-Df"; do
fi
log_note "Import with $nfs_flag and " \
"$guid_flag"
zpool import $option ${devs[i]} \
${options[j]} $target
if ! zpool import $option ${devs[i]} \
${options[j]} $target; then
# import by GUID if import by pool name fails
if [[ $? != 0 ]]; then
log_note "Possible pool name" \
"duplicates. Try GUID import"
target=$guid

View File

@ -55,10 +55,7 @@ function cleanup
#
for disk in $DISKLIST; do
log_must zpool online $TESTPOOL $disk
check_state $TESTPOOL $disk "online"
if [[ $? != 0 ]]; then
log_fail "Unable to online $disk"
fi
log_must check_state $TESTPOOL $disk "online"
done
}
@ -79,16 +76,10 @@ for disk in $DISKLIST; do
while [[ $i -lt ${#args[*]} ]]; do
if (( j < num )) ; then
log_must zpool offline ${args[$i]} $TESTPOOL $disk
check_state $TESTPOOL $disk "offline"
if [[ $? != 0 ]]; then
log_fail "$disk of $TESTPOOL did not match offline state"
fi
log_must check_state $TESTPOOL $disk "offline"
else
log_mustnot zpool offline ${args[$i]} $TESTPOOL $disk
check_state $TESTPOOL $disk "online"
if [[ $? != 0 ]]; then
log_fail "$disk of $TESTPOOL did not match online state"
fi
log_must check_state $TESTPOOL $disk "online"
fi
(( i = i + 1 ))
@ -106,19 +97,13 @@ for disk in $DISKLIST; do
while [[ $i -lt $iters ]]; do
index=`expr $RANDOM % ${#args[*]}`
log_must zpool offline ${args[$index]} $TESTPOOL $disk
check_state $TESTPOOL $disk "offline"
if [[ $? != 0 ]]; then
log_fail "$disk of $TESTPOOL is not offline."
fi
log_must check_state $TESTPOOL $disk "offline"
(( i = i + 1 ))
done
log_must zpool online $TESTPOOL $disk
check_state $TESTPOOL $disk "online"
if [[ $? != 0 ]]; then
log_fail "$disk of $TESTPOOL did not match online state"
fi
log_must check_state $TESTPOOL $disk "online"
done
log_pass "'zpool offline -f' succeeded"

View File

@ -54,10 +54,7 @@ function cleanup
# Ensure we don't leave disks in the offline state
for disk in $DISKLIST; do
log_must zpool online $TESTPOOL $disk
check_state $TESTPOOL $disk "online"
if [[ $? != 0 ]]; then
log_fail "Unable to online $disk"
fi
log_must check_state $TESTPOOL $disk "online"
done
}

View File

@ -54,10 +54,7 @@ function cleanup
#
for disk in $DISKLIST; do
log_must zpool online $TESTPOOL $disk
check_state $TESTPOOL $disk "online"
if [[ $? != 0 ]]; then
log_fail "Unable to online $disk"
fi
log_must check_state $TESTPOOL $disk "online"
done
}
@ -79,16 +76,10 @@ for disk in $DISKLIST; do
sync_pool $TESTPOOL
log_must zpool offline $TESTPOOL $disk
check_state $TESTPOOL $disk "offline"
if [[ $? != 0 ]]; then
log_fail "$disk of $TESTPOOL did not match offline state"
fi
log_must check_state $TESTPOOL $disk "offline"
log_must zpool online ${args[$i]} $TESTPOOL $disk
check_state $TESTPOOL $disk "online"
if [[ $? != 0 ]]; then
log_fail "$disk of $TESTPOOL did not match online state"
fi
log_must check_state $TESTPOOL $disk "online"
while [[ $j -lt 20 ]]; do
is_pool_resilvered $TESTPOOL && break
@ -112,10 +103,7 @@ for disk in $DISKLIST; do
while [[ $i -lt $iters ]]; do
index=`expr $RANDOM % ${#args[*]}`
log_must zpool online ${args[$index]} $TESTPOOL $disk
check_state $TESTPOOL $disk "online"
if [[ $? != 0 ]]; then
log_fail "$disk of $TESTPOOL did not match online state"
fi
log_must check_state $TESTPOOL $disk "online"
(( i = i + 1 ))
done

View File

@ -20,7 +20,7 @@
function clear_labels #disks
{
for disk in $@; do
if ( is_loop_device $disk ) || ( is_mpath_device $disk ); then
if is_loop_device $disk || is_mpath_device $disk; then
zpool labelclear -f /dev/$disk
else
zpool labelclear -f /dev/${disk}1
@ -90,19 +90,16 @@ function wait_for_action #pool timeout function
function wait_for_resilver_start #pool timeout
{
wait_for_action $1 $2 is_pool_resilvering
return $?
}
function wait_for_resilver_end #pool timeout
{
wait_for_action $1 $2 is_pool_resilvered
return $?
}
function wait_for_scrub_end #pool timeout
{
wait_for_action $1 $2 is_pool_scrubbed
return $?
}
#
@ -111,14 +108,10 @@ function wait_for_scrub_end #pool timeout
function is_scan_restarted #pool
{
typeset pool=$1
zpool history -i $pool | grep -q "scan aborted, restarting"
return $?
zpool history -i $1 | grep -q "scan aborted, restarting"
}
function is_deferred_scan_started #pool
{
typeset pool=$1
zpool history -i $pool | grep -q "starting deferred resilver"
return $?
zpool history -i $1 | grep -q "starting deferred resilver"
}

View File

@ -69,23 +69,13 @@ do
for cmdval in ${ashifts[@]}
do
log_must zpool create -o ashift=$ashift $TESTPOOL1 $disk1
verify_ashift $disk1 $ashift
if [[ $? -ne 0 ]]
then
log_fail "Pool was created without setting ashift " \
"value to $ashift"
fi
log_must verify_ashift $disk1 $ashift
# ashift_of(replacing_disk) <= ashift_of(existing_vdev)
if [[ $cmdval -le $ashift ]]
then
log_must zpool replace -o ashift=$cmdval $TESTPOOL1 \
$disk1 $disk2
verify_ashift $disk2 $ashift
if [[ $? -ne 0 ]]
then
log_fail "Device was replaced without " \
"setting ashift value to $ashift"
fi
log_must verify_ashift $disk2 $ashift
wait_replacing $TESTPOOL1
else
log_mustnot zpool replace -o ashift=$cmdval $TESTPOOL1 \

View File

@ -77,12 +77,7 @@ do
then
log_must zpool replace $TESTPOOL1 $disk1 $disk2
wait_replacing $TESTPOOL1
verify_ashift $disk2 $ashift
if [[ $? -ne 0 ]]
then
log_fail "Device was replaced without " \
"setting ashift value to $ashift"
fi
log_must verify_ashift $disk2 $ashift
else
# cannot replace if pool prop ashift > vdev ashift
log_mustnot zpool replace $TESTPOOL1 $disk1 $disk2
@ -90,12 +85,7 @@ do
log_must zpool replace -o ashift=$ashift $TESTPOOL1 \
$disk1 $disk2
wait_replacing $TESTPOOL1
verify_ashift $disk2 $ashift
if [[ $? -ne 0 ]]
then
log_fail "Device was replaced without " \
"setting ashift value to $ashift"
fi
log_must verify_ashift $disk2 $ashift
fi
# clean things for the next run
log_must zpool destroy $TESTPOOL1

View File

@ -51,7 +51,7 @@ then
log_fail "\"zpool set\" exit status $RET should be equal to 2."
fi
OUTPUT=$(zpool set 2>&1 | grep -i usage)
zpool set 2>&1 | grep -qi usage
if [ $? != 0 ]
then
log_fail "Usage message for zpool set did not contain the word 'usage'."

View File

@ -44,19 +44,13 @@
function check_zdb
{
$@ > $TEST_BASE_DIR/zdb.$$
grep "Dataset mos" $TEST_BASE_DIR/zdb.$$
if [ $? -eq 0 ]
then
log_fail "$@ exited 0 when run as a non root user!"
fi
rm $TEST_BASE_DIR/zdb.$$
log_mustnot eval "$* | grep -q 'Dataset mos'"
}
function cleanup
{
rm -f $TEST_BASE_DIR/zdb_001_neg.$$.txt $TEST_BASE_DIR/zdb.$$
rm -f $TEST_BASE_DIR/zdb_001_neg.$$.txt
}
verify_runnable "global"
@ -66,7 +60,7 @@ log_onexit cleanup
log_must eval "zdb > $TEST_BASE_DIR/zdb_001_neg.$$.txt"
# verify the output looks okay
log_must grep pool_guid $TEST_BASE_DIR/zdb_001_neg.$$.txt
log_must grep -q pool_guid $TEST_BASE_DIR/zdb_001_neg.$$.txt
log_must rm $TEST_BASE_DIR/zdb_001_neg.$$.txt
# we shouldn't able to run it on any dataset

View File

@ -43,19 +43,12 @@
#
#
# check to see if we have zfs unallow
zfs 2>&1 | grep "unallow" > /dev/null
if (($? != 0)) then
log_unsupported "ZFS unallow not supported on this machine."
fi
log_assert "zfs unallow returns an error when run as a user"
log_mustnot zfs unallow everyone $TESTPOOL/$TESTFS/allowed
# now check with zfs allow to see if the permissions are still there
OUTPUT=$(zfs allow $TESTPOOL/$TESTFS/allowed | grep "Local+Descendent" )
if [ -z "$OUTPUT" ]
if ! zfs allow $TESTPOOL/$TESTFS/allowed | grep -q "Local+Descendent"
then
log_fail "Error - create permissions were unallowed on \
$TESTPOOL/$TESTFS/allowed"

View File

@ -66,10 +66,7 @@ cd /tmp
for path in $TESTPOOL/$TESTFS $TESTDIR ./../$TESTDIR ; do
zfs list -rH -o name $path > $tmpfile
for fs in $children ; do
grep "^${fs}$" $tmpfile > /dev/null 2>&1
if (( $? != 0 )); then
log_fail "$fs not shown in the output list."
fi
log_must grep -qxF "$fs" $tmpfile
done
done

View File

@ -161,38 +161,29 @@ function common_perm
typeset perm=$2
typeset dtst=$3
typeset -i ret=1
case $perm in
send)
verify_send $user $perm $dtst
ret=$?
;;
allow)
verify_allow $user $perm $dtst
ret=$?
;;
userprop)
verify_userprop $user $perm $dtst
ret=$?
;;
compression|checksum|readonly)
verify_ccr $user $perm $dtst
ret=$?
;;
copies)
verify_copies $user $perm $dtst
ret=$?
;;
reservation)
verify_reservation $user $perm $dtst
ret=$?
;;
*)
ret=1
return 1
;;
esac
return $ret
}
function check_fs_perm
@ -201,99 +192,74 @@ function check_fs_perm
typeset perm=$2
typeset fs=$3
typeset -i ret=1
case $perm in
create)
verify_fs_create $user $perm $fs
ret=$?
;;
destroy)
verify_fs_destroy $user $perm $fs
ret=$?
;;
snapshot)
verify_fs_snapshot $user $perm $fs
ret=$?
;;
rollback)
verify_fs_rollback $user $perm $fs
ret=$?
;;
clone)
verify_fs_clone $user $perm $fs
ret=$?
;;
rename)
verify_fs_rename $user $perm $fs
ret=$?
;;
mount)
verify_fs_mount $user $perm $fs
ret=$?
;;
share)
verify_fs_share $user $perm $fs
ret=$?
;;
mountpoint)
verify_fs_mountpoint $user $perm $fs
ret=$?
;;
promote)
verify_fs_promote $user $perm $fs
ret=$?
;;
canmount)
verify_fs_canmount $user $perm $fs
ret=$?
;;
dnodesize)
verify_fs_dnodesize $user $perm $fs
ret=$?
;;
recordsize)
verify_fs_recordsize $user $perm $fs
ret=$?
;;
quota)
verify_fs_quota $user $perm $fs
ret=$?
;;
aclmode)
verify_fs_aclmode $user $perm $fs
ret=$?
;;
aclinherit)
verify_fs_aclinherit $user $perm $fs
ret=$?
;;
snapdir)
verify_fs_snapdir $user $perm $fs
ret=$?
;;
atime|exec|devices|setuid|xattr)
verify_fs_aedsx $user $perm $fs
ret=$?
;;
zoned)
verify_fs_zoned $user $perm $fs
ret=$?
;;
sharenfs)
verify_fs_sharenfs $user $perm $fs
ret=$?
;;
receive)
verify_fs_receive $user $perm $fs
ret=$?
;;
*)
common_perm $user $perm $fs
ret=$?
;;
esac
return $ret
}
function check_vol_perm
@ -302,43 +268,32 @@ function check_vol_perm
typeset perm=$2
typeset vol=$3
typeset -i ret=1
case $perm in
destroy)
verify_vol_destroy $user $perm $vol
ret=$?
;;
snapshot)
verify_vol_snapshot $user $perm $vol
ret=$?
;;
rollback)
verify_vol_rollback $user $perm $vol
ret=$?
;;
clone)
verify_vol_clone $user $perm $vol
ret=$?
;;
rename)
verify_vol_rename $user $perm $vol
ret=$?
;;
promote)
verify_vol_promote $user $perm $vol
ret=$?
;;
volsize)
verify_vol_volsize $user $perm $vol
ret=$?
;;
*)
common_perm $user $perm $vol
ret=$?
;;
esac
return $ret
}
function setup_unallow_testenv
@ -362,8 +317,6 @@ function setup_unallow_testenv
log_must verify_perm $SUBFS $LOCAL_DESC_SET $OTHER2
fi
done
return 0
}
#
@ -1692,20 +1645,12 @@ function verify_allow
typeset -i ret
user_run $user zfs allow $user allow $dtst
ret=$?
if [[ $ret -eq 0 ]]; then
return 1
fi
user_run $user zfs allow $user allow $dtst && return 1
log_must zfs allow $user copies $dtst
user_run $user zfs allow $user copies $dtst
ret=$?
log_must zfs unallow $user copies $dtst
if [[ $ret -eq 1 ]]; then
return 1
fi
return 0
[ $ret -ne 1 ]
}

View File

@ -68,10 +68,8 @@ log_must add_user $OTHER_GROUP $OTHER2
#
# chmod 0750 $HOME
#
user_run $STAFF1 zfs list
if [ $? -ne 0 ]; then
user_run $STAFF1 zfs list ||
log_unsupported "Test user $STAFF1 cannot execute zfs utilities"
fi
DISK=${DISKS%% *}

View File

@ -60,15 +60,9 @@ function cleanup
function exec_n_check
{
typeset expect_value=$1
shift
$@
ret=$?
if [[ $ret != $expect_value ]]; then
log_fail "Unexpected return code: '$ret'"
fi
return 0
"$@"
log_must [ $? = $expect_value ]
}
log_assert "Setting exec=off on a filesystem, processes can not be executed" \
@ -79,11 +73,11 @@ log_must cp $STF_PATH/ls $TESTDIR/myls
log_must zfs set exec=off $TESTPOOL/$TESTFS
if is_linux; then
log_must exec_n_check 126 $TESTDIR/myls
log_must exec_n_check 1 mmap_exec $TESTDIR/myls # EPERM
exp=1 # EPERM
else
log_must exec_n_check 126 $TESTDIR/myls
log_must exec_n_check 13 mmap_exec $TESTDIR/myls # EACCES
exp=13 # EACCES
fi
log_must exec_n_check 126 $TESTDIR/myls
log_must exec_n_check $exp mmap_exec $TESTDIR/myls
log_pass "Setting exec=off on filesystem testing passed."

View File

@ -114,10 +114,7 @@ do
# Reimport pool with drive missing
log_must zpool import $TESTPOOL
check_state $TESTPOOL "" "degraded"
if (($? != 0)); then
log_fail "$TESTPOOL is not degraded"
fi
log_must check_state $TESTPOOL "" "degraded"
# Clear zpool events
log_must zpool events -c
@ -143,10 +140,7 @@ do
done
# Validate auto-online was successful
check_state $TESTPOOL "" "online"
if (($? != 0)); then
log_fail "$TESTPOOL is not back online"
fi
log_must check_state $TESTPOOL "" "online"
sleep 2
done
log_must zpool destroy $TESTPOOL

View File

@ -80,7 +80,7 @@ for arch in "i386" "sparc"; do
log_must zpool destroy -f $migratedpoolname
log_must zpool import -d $import_dir $migratedpoolname
log_must eval "TZ=$TIMEZONE zpool history $migratedpoolname | grep -v "^\$" >$migrated_cmds_f"
log_must eval "TZ=$TIMEZONE zpool history $migratedpoolname | grep -v \"^\$\" >$migrated_cmds_f"
# The migrated history file should differ with original history file on
# two commands -- 'export' and 'import', which are included in migrated
@ -89,20 +89,20 @@ for arch in "i386" "sparc"; do
# then compare this filtered file with the original history file. They
# should be identical at this time.
for subcmd in "export" "import"; do
grep -q "$subcmd" $migrated_cmds_f || \
grep -q "$subcmd" $migrated_cmds_f ||
log_fail "zpool $subcmd is not logged for" \
"the imported pool $migratedpoolname."
done
tmpfile=$import_dir/cmds_tmp.$$
linenum=`wc -l < $migrated_cmds_f`
linenum=$(wc -l < $migrated_cmds_f)
(( linenum = linenum - 2 ))
head -n $linenum $migrated_cmds_f > $tmpfile
log_must diff $tmpfile $orig_cmds_f1
# cleanup for next loop testing
log_must zpool destroy -f $migratedpoolname
log_must rm -f `ls $import_dir`
log_must rm -f $(ls $import_dir)
done
log_pass "Verify command history moves with migrated pool."

View File

@ -66,10 +66,8 @@ add_user $HIST_GROUP $HIST_USER
#
# chmod 0750 $HOME
#
user_run $HIST_USER zfs list
if [ $? -ne 0 ]; then
user_run $HIST_USER zfs list ||
log_unsupported "Test user $HIST_USER cannot execute zfs utilities"
fi
run_and_verify "zfs create $root_testfs" "-l"
run_and_verify "zfs allow $HIST_GROUP snapshot,mount $root_testfs" "-l"

View File

@ -113,7 +113,7 @@ function verify_long
suffix=":freebsd"
fi
if grep -q "$cmd \[user $uid ($user) on $hname$suffix\]" $NEW_HISTORY; then
if ! grep -q "$cmd \[user $uid ($user) on $hname$suffix\]" $NEW_HISTORY; then
log_note "Couldn't find long information for \"$cmd\""
return 1
fi
@ -138,7 +138,7 @@ function verify_hold
# This works whether or not the hold was recursive
for ds in $(zfs list -r -Ho name -t snapshot $dsname | \
grep "@$snapname"); do
if grep -q "$subcmd $ds ([0-9]*) tag=$tag" $NEW_HISTORY; then
if ! grep -q "$subcmd $ds ([0-9]*) tag=$tag" $NEW_HISTORY; then
log_note "Didn't find hold on $ds with $tag"
return 1
fi
@ -167,15 +167,12 @@ function verify_rollback
typeset rb_fs=${dsname}/%rollback
typeset snapname=${fullname##*@}
grep "clone swap $rb_fs ([0-9]*) parent=$parent_fs" $NEW_HISTORY \
>/dev/null 2>&1
if [[ $? != 0 ]]; then
if ! grep -q "clone swap $rb_fs ([0-9]*) parent=$parent_fs" $NEW_HISTORY ; then
log_note "Didn't find rollback clone swap in pool history"
return 1
fi
grep "destroy $rb_fs" $NEW_HISTORY >/dev/null 2>&1
if [[ $? != 0 ]]; then
if ! grep -q "destroy $rb_fs" $NEW_HISTORY; then
log_note "Didn't find rollback destroy in pool history"
return 1
fi
@ -196,9 +193,7 @@ function verify_inherit
# This works whether or not the inherit was recursive
for ds in $(zfs list -r -Ho name -t filesystem $dsname); do
grep "$subcmd $ds ([0-9]*) ${prop}=" $NEW_HISTORY >/dev/null \
2>&1
if [[ $? != 0 ]]; then
if ! grep -q "$subcmd $ds ([0-9]*) ${prop}=" $NEW_HISTORY; then
log_note "Didn't find inherit history for $ds"
return 1
fi
@ -248,9 +243,7 @@ function verify_allow
[[ -n $is_set ]] && str="S-\$@"
tmp=${cmd#*@}
code="$str${tmp% *}"
grep "permission $subcmd $dsname ([0-9]*) $code" \
$NEW_HISTORY >/dev/null 2>&1
if [[ $? != 0 ]]; then
if ! grep -q "permission $subcmd $dsname ([0-9]*) $code" $NEW_HISTORY; then
log_note "Couldn't find $code in $NEW_HISTORY"
return 1
fi
@ -259,9 +252,7 @@ function verify_allow
[[ -n $is_set ]] && str="C-\$"
tmp=${cmd#*-c}
code="$str${tmp% *}"
grep "permission $subcmd $dsname ([0-9]*) $code" \
$NEW_HISTORY >/dev/null 2>&1
if [ $? != 0 ]]; then
if ! grep "permission $subcmd $dsname ([0-9]*) $code" $NEW_HISTORY; then
log_note "Couldn't find $code in $NEW_HISTORY"
return 1
fi
@ -273,18 +264,14 @@ function verify_allow
uid=$(id -u ${tmp%% *})
if [[ -n $lflag ]]; then
code="${str}l\$$uid $opt"
grep "permission $subcmd $dsname ([0-9]*) $code" \
$NEW_HISTORY >/dev/null 2>&1
if [ $? != 0 ]]; then
if grep -q "permission $subcmd $dsname ([0-9]*) $code" $NEW_HISTORY]; then
log_note "Couldn't find $code in $NEW_HISTORY"
return 1
fi
fi
if [[ -n $dflag ]]; then
code="${str}d\$$uid $opt"
grep "permission $subcmd $dsname ([0-9]*) $code" \
$NEW_HISTORY >/dev/null 2>&1
if [ $? != 0 ]]; then
if grep -q "permission $subcmd $dsname ([0-9]*) $code" $NEW_HISTORY]; then
log_note "Couldn't find $code in $NEW_HISTORY"
return 1
fi
@ -297,18 +284,14 @@ function verify_allow
gid=$(awk -F: "/^${tmp%% *}:/ {print \$3}" /etc/group)
if [[ -n $lflag ]]; then
code="${str}l\$$gid $opt"
grep "permission $subcmd $dsname ([0-9]*) $code" \
$NEW_HISTORY >/dev/null 2>&1
if [ $? != 0 ]]; then
if ! grep -q "permission $subcmd $dsname ([0-9]*) $code" $NEW_HISTORY; then
log_note "Couldn't find $code in $NEW_HISTORY"
return 1
fi
fi
if [[ -n $dflag ]]; then
code="${str}d\$$gid $opt"
grep "permission $subcmd $dsname ([0-9]*) $code" \
$NEW_HISTORY >/dev/null 2>&1
if [ $? != 0 ]]; then
if ! grep -q "permission $subcmd $dsname ([0-9]*) $code" $NEW_HISTORY; then
log_note "Couldn't find $code in $NEW_HISTORY"
return 1
fi
@ -320,18 +303,14 @@ function verify_allow
opt=${opt%% *}
if [[ -n $lflag ]]; then
code="${str}l\$ $opt"
grep "permission $subcmd $dsname ([0-9]*) $code" \
$NEW_HISTORY >/dev/null 2>&1
if [ $? != 0 ]]; then
if ! grep -q "permission $subcmd $dsname ([0-9]*) $code" $NEW_HISTORY; then
log_note "Couldn't find $code in $NEW_HISTORY"
return 1
fi
fi
if [[ -n $dflag ]]; then
code="${str}d\$ $opt"
grep "permission $subcmd $dsname ([0-9]*) $code" \
$NEW_HISTORY >/dev/null 2>&1
if [ $? != 0 ]]; then
if ! grep -q "permission $subcmd $dsname ([0-9]*) $code" $NEW_HISTORY; then
log_note "Couldn't find $code in $NEW_HISTORY"
return 1
fi
@ -367,16 +346,14 @@ function verify_destroy
[[ $dsname =~ "@" ]] && typeset is_snap=1
if [[ -n $is_snap ]]; then
grep "ioctl destroy_snaps" $NEW_HISTORY >/dev/null 2>&1
if [[ $? != 0 ]]; then
if ! grep -q "ioctl destroy_snaps" $NEW_HISTORY; then
log_note "Didn't find ioctl while destroying $dsname"
return 1
fi
fi
# This should be present for datasets and snapshots alike
grep "destroy $dsname" $NEW_HISTORY >/dev/null 2>&1
if [[ $? != 0 ]]; then
if ! grep -q "destroy $dsname" $NEW_HISTORY; then
log_note "Didn't find \"destroy\" for $dsname"
return 1
fi
@ -395,9 +372,7 @@ function verify_snapshot
typeset dsname=${fullname%%@*}
typeset snapname=${fullname##*@}
grep "\[txg:[0-9]*\] $subcmd $fullname ([0-9]*)" $NEW_HISTORY \
>/dev/null 2>&1
if [[ $? != 0 ]]; then
if ! grep -q "\[txg:[0-9]*\] $subcmd $fullname ([0-9]*)" $NEW_HISTORY; then
log_note "Didn't find snapshot command for $fullname"
return 1
fi
@ -405,8 +380,7 @@ function verify_snapshot
# This works whether or not the snapshot was recursive
for ds in $(zfs list -r -Ho name -t snapshot $dsname | \
grep "@$snapname"); do
grep "^[ ]* $ds$" $NEW_HISTORY >/dev/null 2>&1
if [[ $? != 0 ]]; then
if ! grep -q "^[ ]* $ds$" $NEW_HISTORY; then
log_note "Didn't find \"ioctl snapshot\" for $ds"
return 1
fi

View File

@ -34,18 +34,12 @@
#
function get_prop_src # property dataset
{
typeset prop_val
typeset prop=$1
typeset dataset=$2
prop_val=`zfs get -H -o source $prop $dataset`
if [[ $? -ne 0 ]]; then
zfs get -H -o source $prop $dataset ||
log_fail "Unable to determine the source of $prop" \
"property for dataset $dataset"
else
echo $prop_val
fi
}
#
@ -63,7 +57,7 @@ function verify_prop_src # child_dataset property expected_src
typeset prop=$2
typeset expected=$3
prop_src=`get_prop_src $prop $target`
prop_src=$(get_prop_src $prop $target)
#
# Rather than just checking if $prop_src == $expected
@ -105,7 +99,7 @@ function set_n_verify_prop #property value dataset
typeset dataset=$3
zfs set $prop=$prop_val $dataset
check_val=`get_prop $prop $dataset`
check_val=$(get_prop $prop $dataset)
if [[ $check_val != $prop_val ]]; then
log_fail "Property $prop of $dataset has value $check_val"\

View File

@ -337,9 +337,7 @@ function scan_state { #state-file
for p in ${prop[i]} ${prop[((i+1))]}; do
zfs $op $p $target
ret=$?
check_failure $ret "zfs $op $p \
$target"
check_failure $? "zfs $op $p $target"
done
fi
for check_obj in $list; do
@ -349,16 +347,14 @@ function scan_state { #state-file
# check_failure to keep journal small
verify_prop_src $check_obj $p \
$final_src
ret=$?
check_failure $ret "verify" \
check_failure $? "verify" \
"_prop_src $check_obj $p" \
"$final_src"
# Again, to keep journal size down.
verify_prop_val $p $check_obj \
$final_src $j
ret=$?
check_failure $ret "verify" \
check_failure $? "verify" \
"_prop_val $check_obj $p" \
"$final_src"
done

View File

@ -92,8 +92,8 @@ typeset -i filenum=0
typeset cwd=""
log_note "Make a ufs filesystem on source $rawdisk1"
new_fs $rawdisk1 > /dev/null 2>&1
(($? != 0)) && log_untested "Unable to create ufs filesystem on $rawdisk1"
new_fs $rawdisk1 > /dev/null 2>&1 ||
log_untested "Unable to create ufs filesystem on $rawdisk1"
log_must mkdir -p $UFSMP
@ -104,9 +104,9 @@ log_note "Now create some directories and files to be ufsdump'ed"
while (($dirnum <= 2)); do
log_must mkdir $bigdir${dirnum}
while (( $filenum <= 2 )); do
file_write -o create -f $bigdir${dirnum}/file${filenum} \
if ! file_write -o create -f $bigdir${dirnum}/file${filenum} \
-b $BLOCK_SIZE -c $BLOCK_COUNT
if [[ $? -ne 0 ]]; then
then
if [[ $dirnum -lt 3 ]]; then
log_fail "file_write only wrote" \
"<(( $dirnum * 3 + $filenum ))>" \
@ -135,9 +135,7 @@ log_note "Attempt to take the source device in use by ufsdump as spare device"
log_mustnot zpool create $TESTPOOL1 "$FS_DISK2" spare "$disk1"
log_mustnot poolexists $TESTPOOL1
wait $PIDUFSDUMP
typeset -i retval=$?
(($retval != 0)) && log_fail "ufsdump failed with error code $ret_val"
wait $PIDUFSDUMP || log_fail "ufsdump failed with error code $?"
log_must mount $disk1 $UFSMP

View File

@ -54,7 +54,7 @@ function cleanup
#
log_must zfs umount $TESTPOOL/$TESTFS
rm -rf $TESTDIR || \
rm -rf $TESTDIR ||
log_unresolved Could not remove $TESTDIR
log_must zfs destroy $TESTPOOL/$TESTFS
@ -71,21 +71,11 @@ function mini_format
if is_linux; then
parted $disk -s -- mklabel gpt
typeset -i retval=$?
elif is_freebsd; then
gpart create -s gpt $disk
typeset -i retval=$?
else
typeset format_file=$TEST_BASE_DIR/format_in.$$.1
echo "partition" > $format_file
echo "modify" >> $format_file
format -e -s -d $disk -f $format_file
typeset -i retval=$?
rm -rf $format_file
format -e -s -d $disk -f <(printf '%s\n' partition modify)
fi
return $retval
}
log_assert "format will disallow modification of a mounted zfs disk partition"\

View File

@ -117,15 +117,12 @@ log_onexit cleanup
# units for 'df'. It must be greater than one.
# -----------------------------------------------------------------------
typeset str
typeset -i ret
for volsize in $VOLSIZES; do
log_note "Create a pool which will contain a volume device"
log_must create_pool $TESTPOOL2 "$DISKS"
log_note "Create a volume device of desired sizes: $volsize"
str=$(zfs create -sV $volsize $TESTPOOL2/$TESTVOL 2>&1)
ret=$?
if (( ret != 0 )); then
if ! str=$(zfs create -sV $volsize $TESTPOOL2/$TESTVOL 2>&1); then
if [[ is_32bit && \
$str == *${VOL_LIMIT_KEYWORD1}* || \
$str == *${VOL_LIMIT_KEYWORD2}* || \

View File

@ -34,11 +34,9 @@
verify_runnable "global"
ismounted $NONZFS_TESTDIR $NEWFS_DEFAULT_FS
(( $? == 0 )) && log_must umount -f $NONZFS_TESTDIR
ismounted $NONZFS_TESTDIR $NEWFS_DEFAULT_FS && log_must umount -f $NONZFS_TESTDIR
ismounted $TESTPOOL/$TESTFS
[[ $? == 0 ]] && log_must zfs umount -f $TESTDIR
ismounted $TESTPOOL/$TESTFS && log_must zfs umount -f $TESTDIR
destroy_pool $TESTPOOL
DISK=${DISKS%% *}

View File

@ -49,19 +49,11 @@ function prepare #srcdir cmd
{
typeset srcdir=$1
typeset cmd=$2
typeset -i retval=0
cwd=$PWD
cd $srcdir
(( $? != 0 )) && return 1
$cmd
(( $? != 0 )) && return 1
cd $cwd
(( $? != 0 )) && return 1
return 0
cd $srcdir || return 1
$cmd || return 1
cd $cwd || return 1
}
#
@ -90,30 +82,22 @@ function migrate #destdir oldsuma oldsumb cmd
typeset oldsuma=$2
typeset oldsumb=$3
typeset cmd=$4
typeset -i retval=0
cwd=$PWD
cd $destdir
(( $? != 0 )) && return 1
$cmd
(( $? != 0 )) && return 1
cd $destdir || return 1
$cmd || return 1
read -r suma sumb _ < <(cksum ./$BNAME)
cd $cwd || return 1
if (( $oldsuma != $suma )); then
log_note "sum values are not the same"
retval=1
return 1
fi
if (( $oldsumb != $sumb )); then
log_note "sum values are not the same"
retval=1
return 1
fi
cd $cwd
(( $? != 0 )) && return 1
return $retval
}
function migrate_cpio
@ -122,28 +106,20 @@ function migrate_cpio
typeset archive=$2
typeset oldsuma=$3
typeset oldsumb=$4
typeset -i retval=0
cwd=$PWD
cd $destdir
(( $? != 0 )) && return 1
cpio -iv < $archive
(( $? != 0 )) && return 1
cd $destdir || return 1
cpio -iv < $archive || return 1
read -r suma sumb _ < <(cksum ./$BNAME)
cd $cwd
if (( $oldsuma != $suma )); then
log_note "sum values are not the same"
retval=1
return 1
fi
if (( $oldsumb != $sumb )); then
log_note "sum values are not the same"
retval=1
return 1
fi
cd $cwd
(( $? != 0 )) && return 1
return $retval
}

View File

@ -48,19 +48,14 @@ verify_runnable "both"
function cleanup
{
rm -rf $TESTDIR/tar$$.tar
rm -rf $TESTDIR/$BNAME
rm -rf $TESTDIR/tar$$.tar $TESTDIR/$BNAME
}
log_assert "Migrating test file from ZFS fs to ZFS fs using tar"
log_onexit cleanup
prepare $DNAME "tar cf $TESTDIR/tar$$.tar $BNAME"
(( $? != 0 )) && log_fail "Unable to create src archive"
migrate $TESTDIR $SUMA $SUMB "tar xf $TESTDIR/tar$$.tar"
(( $? != 0 )) && log_fail "Unable to successfully migrate test file from" \
"ZFS fs to ZFS fs"
log_must prepare $DNAME "tar cf $TESTDIR/tar$$.tar $BNAME"
log_must migrate $TESTDIR $SUMA $SUMB "tar xf $TESTDIR/tar$$.tar"
log_pass "Successfully migrated test file from ZFS fs to ZFS fs".

View File

@ -34,12 +34,12 @@
#
# DESCRIPTION:
# Migrating test file from ZFS fs to UFS fs using tar.
# Migrating test file from ZFS fs to platform native fs using tar.
#
# STRATEGY:
# 1. Calculate chksum of testfile
# 2. Tar up test file and place on a ZFS filesystem
# 3. Extract tar contents to a UFS file system
# 3. Extract tar contents to a platform native file system
# 4. Calculate chksum of extracted file
# 5. Compare old and new chksums.
#
@ -48,19 +48,14 @@ verify_runnable "both"
function cleanup
{
rm -rf $TESTDIR/tar$$.tar
rm -rf $NONZFS_TESTDIR/$BNAME
rm -rf $TESTDIR/tar$$.tar $NONZFS_TESTDIR/$BNAME
}
log_assert "Migrating test file from ZFS fs to UFS fs using tar"
log_assert "Migrating test file from ZFS fs to $NEWFS_DEFAULT_FS fs using tar"
log_onexit cleanup
prepare $DNAME "tar cf $TESTDIR/tar$$.tar $BNAME"
(( $? != 0 )) && log_fail "Unable to create src archive"
log_must prepare $DNAME "tar cf $TESTDIR/tar$$.tar $BNAME"
log_must migrate $NONZFS_TESTDIR $SUMA $SUMB "tar xf $TESTDIR/tar$$.tar"
migrate $NONZFS_TESTDIR $SUMA $SUMB "tar xf $TESTDIR/tar$$.tar"
(( $? != 0 )) && log_fail "Unable to successfully migrate test file from" \
"ZFS fs to UFS fs"
log_pass "Successfully migrated test file from ZFS fs to UFS fs".
log_pass "Successfully migrated test file from ZFS fs to $NEWFS_DEFAULT_FS fs".

View File

@ -34,11 +34,11 @@
#
# DESCRIPTION:
# Migrating test file from UFS fs to ZFS fs using tar.
# Migrating test file from platform native fs to ZFS fs using tar.
#
# STRATEGY:
# 1. Calculate chksum of testfile
# 2. Tar up test file and place on a UFS filesystem
# 2. Tar up test file and place on a platform native filesystem
# 3. Extract tar contents to a ZFS file system
# 4. Calculate chksum of extracted file
# 5. Compare old and new chksums.
@ -48,19 +48,14 @@ verify_runnable "both"
function cleanup
{
rm -rf $NONZFS_TESTDIR/tar$$.tar
rm -rf $TESTDIR/$BNAME
rm -rf $NONZFS_TESTDIR/tar$$.tar $TESTDIR/$BNAME
}
log_assert "Migrating test file from UFS fs to ZFS fs using tar"
log_assert "Migrating test file from $NEWFS_DEFAULT_FS fs to ZFS fs using tar"
log_onexit cleanup
prepare $DNAME "tar cf $NONZFS_TESTDIR/tar$$.tar $BNAME"
(( $? != 0 )) && log_fail "Unable to create src archive"
log_must prepare $DNAME "tar cf $NONZFS_TESTDIR/tar$$.tar $BNAME"
log_must migrate $TESTDIR $SUMA $SUMB "tar xvf $NONZFS_TESTDIR/tar$$.tar"
migrate $TESTDIR $SUMA $SUMB "tar xvf $NONZFS_TESTDIR/tar$$.tar"
(( $? != 0 )) && log_fail "Unable to successfully migrate test file from" \
"UFS fs to ZFS fs"
log_pass "Successfully migrated test file from UFS fs to ZFS fs".
log_pass "Successfully migrated test file from $NEWFS_DEFAULT_FS fs to ZFS fs".

View File

@ -48,8 +48,7 @@ verify_runnable "both"
function cleanup
{
rm -rf $TESTDIR/cpio$$.cpio
rm -rf $TESTDIR/$BNAME
rm -rf $TESTDIR/cpio$$.cpio $TESTDIR/$BNAME
}
log_assert "Migrating test file from ZFS fs to ZFS fs using cpio"
@ -57,17 +56,9 @@ log_assert "Migrating test file from ZFS fs to ZFS fs using cpio"
log_onexit cleanup
cwd=$PWD
cd $DNAME
(( $? != 0 )) && log_untested "Could not change directory to $DNAME"
ls $BNAME | cpio -oc > $TESTDIR/cpio$$.cpio
(( $? != 0 )) && log_fail "Unable to create cpio archive"
cd $cwd
(( $? != 0 )) && log_untested "Could not change directory to $cwd"
migrate_cpio $TESTDIR "$TESTDIR/cpio$$.cpio" $SUMA $SUMB
(( $? != 0 )) && log_fail "Unable to successfully migrate test file from" \
"ZFS fs to ZFS fs"
log_must cd $DNAME
log_must eval "find $BNAME | cpio -oc > $TESTDIR/cpio$$.cpio"
log_must cd $cwd
log_must migrate_cpio $TESTDIR "$TESTDIR/cpio$$.cpio" $SUMA $SUMB
log_pass "Successfully migrated test file from ZFS fs to ZFS fs".

View File

@ -34,12 +34,12 @@
#
# DESCRIPTION:
# Migrating test file from ZFS fs to UFS fs using cpio
# Migrating test file from ZFS fs to platform native fs using cpio
#
# STRATEGY:
# 1. Calculate chksum of testfile
# 2. Cpio up test file and place on a ZFS filesystem
# 3. Extract cpio contents to a UFS file system
# 3. Extract cpio contents to a platform native file system
# 4. Calculate chksum of extracted file
# 5. Compare old and new chksums.
#
@ -48,26 +48,17 @@ verify_runnable "both"
function cleanup
{
rm -rf $TESTDIR/cpio$$.cpio
rm -rf $NONZFS_TESTDIR/$BNAME
rm -rf $TESTDIR/cpio$$.cpio $NONZFS_TESTDIR/$BNAME
}
log_assert "Migrating test file from ZFS fs to uFS fs using cpio"
log_assert "Migrating test file from ZFS fs to $NEWFS_DEFAULT_FS fs using cpio"
log_onexit cleanup
cwd=$PWD
cd $DNAME
(( $? != 0 )) && log_untested "Could not change directory to $DNAME"
log_must cd $DNAME
log_must eval "find $BNAME | cpio -oc > $TESTDIR/cpio$$.cpio"
log_must cd $cwd
log_must migrate_cpio $NONZFS_TESTDIR "$TESTDIR/cpio$$.cpio" $SUMA $SUMB
ls $BNAME | cpio -oc > $TESTDIR/cpio$$.cpio
(( $? != 0 )) && log_fail "Unable to create cpio archive"
cd $cwd
(( $? != 0 )) && log_untested "Could not change directory to $cwd"
migrate_cpio $NONZFS_TESTDIR "$TESTDIR/cpio$$.cpio" $SUMA $SUMB
(( $? != 0 )) && log_fail "Unable to successfully migrate test file from" \
"ZFS fs to UFS fs"
log_pass "Successfully migrated test file from ZFS fs to UFS fs".
log_pass "Successfully migrated test file from ZFS fs to $NEWFS_DEFAULT_FS fs".

View File

@ -48,8 +48,7 @@ verify_runnable "both"
function cleanup
{
rm -rf $NONZFS_TESTDIR/cpio$$.cpio
rm -rf $TESTDIR/$BNAME
rm -rf $NONZFS_TESTDIR/cpio$$.cpio $TESTDIR/$BNAME
}
log_assert "Migrating test file from UFS fs to ZFS fs using cpio"
@ -57,17 +56,9 @@ log_assert "Migrating test file from UFS fs to ZFS fs using cpio"
log_onexit cleanup
cwd=$PWD
cd $DNAME
(( $? != 0 )) && log_untested "Could not change directory to $DNAME"
ls $BNAME | cpio -oc > $NONZFS_TESTDIR/cpio$$.cpio
(( $? != 0 )) && log_fail "Unable to create cpio archive"
cd $cwd
(( $? != 0 )) && log_untested "Could not change directory to $cwd"
migrate_cpio $TESTDIR "$NONZFS_TESTDIR/cpio$$.cpio" $SUMA $SUMB
(( $? != 0 )) && log_fail "Unable to successfully migrate test file from" \
"ZFS fs to ZFS fs"
log_must cd $DNAME
log_must eval "find $BNAME | cpio -oc > $NONZFS_TESTDIR/cpio$$.cpio"
log_must cd $cwd
log_must migrate_cpio $TESTDIR "$NONZFS_TESTDIR/cpio$$.cpio" $SUMA $SUMB
log_pass "Successfully migrated test file from UFS fs to ZFS fs".

View File

@ -48,19 +48,14 @@ verify_runnable "both"
function cleanup
{
rm -rf $TESTDIR/dd$$.dd
rm -rf $TESTDIR/$BNAME
rm -rf $TESTDIR/dd$$.dd $TESTDIR/$BNAME
}
log_assert "Migrating test file from ZFS fs to ZFS fs using dd"
log_onexit cleanup
prepare $DNAME "dd if=$BNAME obs=128k of=$TESTDIR/dd$$.dd"
(( $? != 0 )) && log_fail "Unable to create src archive"
migrate $TESTDIR $SUMA $SUMB "dd if=$TESTDIR/dd$$.dd obs=128k of=$BNAME"
(( $? != 0 )) && log_fail "Unable to successfully migrate test file from" \
"ZFS fs to ZFS fs"
log_must prepare $DNAME "dd if=$BNAME obs=128k of=$TESTDIR/dd$$.dd"
log_must migrate $TESTDIR $SUMA $SUMB "dd if=$TESTDIR/dd$$.dd obs=128k of=$BNAME"
log_pass "Successfully migrated test file from ZFS fs to ZFS fs".

View File

@ -34,12 +34,12 @@
#
# DESCRIPTION:
# Migrating test file from ZFS fs to UFS fs using dd.
# Migrating test file from ZFS fs to platform native fs using dd.
#
# STRATEGY:
# 1. Calculate chksum of testfile
# 2. Dd up test file and place on a ZFS filesystem
# 3. Extract dd contents to a UFS file system
# 3. Extract dd contents to a platform native file system
# 4. Calculate chksum of extracted file
# 5. Compare old and new chksums.
#
@ -48,19 +48,14 @@ verify_runnable "both"
function cleanup
{
rm -rf $TESTDIR/dd$$.dd
rm -rf $NONZFS_TESTDIR/$BNAME
rm -rf $TESTDIR/dd$$.dd $NONZFS_TESTDIR/$BNAME
}
log_assert "Migrating test file from ZFS fs to UFS fs using dd"
log_assert "Migrating test file from ZFS fs to $NEWFS_DEFAULT_FS fs using dd"
log_onexit cleanup
prepare $DNAME "dd if=$BNAME obs=128k of=$TESTDIR/dd$$.dd"
(( $? != 0 )) && log_fail "Unable to create src archive"
log_must prepare $DNAME "dd if=$BNAME obs=128k of=$TESTDIR/dd$$.dd"
log_must migrate $NONZFS_TESTDIR $SUMA $SUMB "dd if=$TESTDIR/dd$$.dd obs=128k of=$BNAME"
migrate $NONZFS_TESTDIR $SUMA $SUMB "dd if=$TESTDIR/dd$$.dd obs=128k of=$BNAME"
(( $? != 0 )) && log_fail "Unable to successfully migrate test file from" \
"ZFS fs to ZFS fs"
log_pass "Successfully migrated test file from ZFS fs to UFS fs".
log_pass "Successfully migrated test file from ZFS fs to $NEWFS_DEFAULT_FS fs".

View File

@ -34,11 +34,11 @@
#
# DESCRIPTION:
# Migrating test file from UFS fs to ZFS fs using dd.
# Migrating test file from platform native fs to ZFS fs using dd.
#
# STRATEGY:
# 1. Calculate chksum of testfile
# 2. Dd up test file and place on a UFS filesystem
# 2. Dd up test file and place on a platform native filesystem
# 3. Extract dd contents to a ZFS file system
# 4. Calculate chksum of extracted file
# 5. Compare old and new chksums.
@ -48,19 +48,14 @@ verify_runnable "both"
function cleanup
{
rm -rf $TESTDIR/dd$$.dd
rm -rf $NONZFS_TESTDIR/$BNAME
rm -rf $TESTDIR/dd$$.dd $NONZFS_TESTDIR/$BNAME
}
log_assert "Migrating test file from UFS fs to ZFS fs using dd"
log_assert "Migrating test file from $NEWFS_DEFAULT_FS fs to ZFS fs using dd"
log_onexit cleanup
prepare $DNAME "dd if=$BNAME obs=128k of=$NONZFS_TESTDIR/dd$$.dd"
(( $? != 0 )) && log_fail "Unable to create src archive"
log_must prepare $DNAME "dd if=$BNAME obs=128k of=$NONZFS_TESTDIR/dd$$.dd"
log_must migrate $TESTDIR $SUMA $SUMB "dd if=$NONZFS_TESTDIR/dd$$.dd obs=128k of=$BNAME"
migrate $TESTDIR $SUMA $SUMB "dd if=$NONZFS_TESTDIR/dd$$.dd obs=128k of=$BNAME"
(( $? != 0 )) && log_fail "Unable to successfully migrate test file from" \
"ZFS fs to ZFS fs"
log_pass "Successfully migrated test file from UFS fs to ZFS fs".
log_pass "Successfully migrated test file from $NEWFS_DEFAULT_FS fs to ZFS fs".

Some files were not shown because too many files have changed in this diff Show More