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

View File

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

View File

@ -57,40 +57,41 @@ log_onexit cleanup
log_note "Testing access to FILE" log_note "Testing access to FILE"
log_must touch $TESTDIR/file.0 log_must touch $TESTDIR/file.0
log_must setfacl -m g:$ZFS_ACL_STAFF_GROUP:rw $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 \ if ! getfacl $TESTDIR/file.0 2> /dev/null |
"^group:$ZFS_ACL_STAFF_GROUP:rw-$" grep -qFx "group:$ZFS_ACL_STAFF_GROUP:rw-"
if [ "$?" -eq "0" ]; then then
# Should be able to write to file log_note "$(getfacl $TESTDIR/file.0 2> /dev/null)"
log_must user_run $ZFS_ACL_STAFF1 \
"echo 'echo test > /dev/null' > $TESTDIR/file.0"
# Since $TESTDIR is 777, create a new dir with controlled permissions
# for testing that creating a new file is not allowed.
log_must mkdir $TESTDIR/dir.0
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}')
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
log_fail "ACL group:$ZFS_ACL_STAFF_GROUP:rw- was not set."
fi
# Should NOT be able to create new file
log_mustnot user_run $ZFS_ACL_STAFF1 "touch $TESTDIR/dir.0/file.1"
# Root should be able to run file, but not user
chmod +x $TESTDIR/file.0
log_must $TESTDIR/file.0
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" log_fail "Group '$ZFS_ACL_STAFF_GROUP' does not have 'rw' as specified"
fi fi
# Should be able to write to file
log_must user_run $ZFS_ACL_STAFF1 \
"echo 'echo test > /dev/null' > $TESTDIR/file.0"
# Since $TESTDIR is 777, create a new dir with controlled permissions
# for testing that creating a new file is not allowed.
log_must mkdir $TESTDIR/dir.0
log_must chmod 700 $TESTDIR/dir.0
log_must setfacl -m g:$ZFS_ACL_STAFF_GROUP:rw $TESTDIR/dir.0
# Confirm permissions
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
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
log_mustnot user_run $ZFS_ACL_STAFF1 "touch $TESTDIR/dir.0/file.1"
# Root should be able to run file, but not user
chmod +x $TESTDIR/file.0
log_must $TESTDIR/file.0
log_mustnot user_run $ZFS_ACL_STAFF1 $TESTDIR/file.0
log_pass "POSIX ACL mode works on files"

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

View File

@ -59,12 +59,6 @@ function cleanup {
fi 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_assert "Valid datasets are accepted as bootfs property values"
log_onexit cleanup 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_assert "Invalid datasets are rejected as boot property values"
log_onexit cleanup 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_onexit cleanup
log_assert "Valid pool names are accepted by zpool set bootfs" 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_assert "Invalid pool names are rejected by zpool set bootfs"
log_onexit cleanup log_onexit cleanup

View File

@ -44,12 +44,6 @@
verify_runnable "global" 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 VDEV1=$TESTDIR/bootfs_006_pos_a.$$.dat
VDEV2=$TESTDIR/bootfs_006_pos_b.$$.dat VDEV2=$TESTDIR/bootfs_006_pos_b.$$.dat
VDEV3=$TESTDIR/bootfs_006_pos_c.$$.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 # looks for return values that correspond to a core dump and cause a test
# failure. # failure.
btree_test -n insert_duplicate btree_test -n insert_duplicate && log_fail "Failure from insert_duplicate"
[[ $? -eq 0 ]] && log_fail "Failure from insert_duplicate" btree_test -n remove_missing && log_fail "Failure from remove_missing"
btree_test -n remove_missing
[[ $? -eq 0 ]] && log_fail "Failure from remove_missing"
log_pass "Btree negative tests passed" log_pass "Btree negative tests passed"

View File

@ -146,9 +146,3 @@ function verify_cache_device
log_note "Can not find device: $device" log_note "Can not find device: $device"
return 1 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 typeset name=$TESTDIR/$1
rm $name >/dev/null 2>&1 rm $name >/dev/null 2>&1 || return 1
if [ -f $name ]; then
if [[ $? -ne 0 ]] ; then
return 1
fi
if [[ -f $name ]] ; then
return 2 return 2
fi fi
} }
@ -86,10 +81,7 @@ function lookup_file_ci
function lookup_any function lookup_any
{ {
for name in $NAMES_ALL ; do for name in $NAMES_ALL ; do
lookup_file $name lookup_file $name && return
if [[ $? -eq 0 ]] ; then
return 0
fi
done done
return 1 return 1

View File

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

View File

@ -47,10 +47,8 @@ log_must add_user $QGROUP $QUSER2
# #
# chmod 0750 $HOME # chmod 0750 $HOME
# #
user_run $QUSER1 zfs list user_run $QUSER1 zfs list ||
if [ $? -ne 0 ]; then
log_unsupported "Test user $QUSER1 cannot execute zfs utilities" log_unsupported "Test user $QUSER1 cannot execute zfs utilities"
fi
DISK=${DISKS%% *} DISK=${DISKS%% *}
default_setup $DISK 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 log_must dd if=/dev/${DISK[0]} of=/dev/${DISK[1]} bs=1K count=256 conv=notrunc
for x in 0 1 ; do for x in 0 1 ; do
config_count=$(zdb -l $DEV_RDSKDIR/${DISK[$x]} | grep -c features_for_read) config_count=$(zdb -l $DEV_RDSKDIR/${DISK[$x]} | grep -c features_for_read) ||
(( $? != 0)) && log_fail "failed to get config_count from DISK[$x]" log_fail "failed to get config_count from DISK[$x]"
log_note "vdev $x: message_count $config_count" log_note "vdev $x: message_count $config_count"
[ $config_count -ne ${config_count[$x]} ] && \ [ $config_count -ne ${config_count[$x]} ] && \
log_fail "zdb produces an incorrect number of configuration dumps." 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 sync_pool $TESTPOOL
output=$(zdb -ddddddbbbbbb $TESTPOOL/$TESTFS $obj 2> /dev/null \ 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") dva=$(sed -Ene 's/^.+DVA\[0\]=<([^>]+)>.*$/\1/p' <<< "$output")
log_note "block 0 of $init_data has a DVA of $dva" log_note "block 0 of $init_data has a DVA of $dva"
cksum_expected=$(sed -Ene 's/^.+ cksum=([a-z0-9:]+)$/\1/p' <<< "$output") cksum_expected=$(sed -Ene 's/^.+ cksum=([a-z0-9:]+)$/\1/p' <<< "$output")
log_note "expecting cksum $cksum_expected" log_note "expecting cksum $cksum_expected"
output=$(zdb -R $TESTPOOL $dva:c 2> /dev/null) output=$(zdb -R $TESTPOOL $dva:c 2> /dev/null)
result=$(grep $cksum_expected <<< "$output") grep -q $cksum_expected <<<"$output" ||
(( $? != 0 )) && log_fail "zdb -R failed to print the correct checksum" log_fail "zdb -R failed to print the correct checksum"
log_pass "zdb -R generates the correct checksum" log_pass "zdb -R generates the correct checksum"

View File

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

View File

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

View File

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

View File

@ -58,12 +58,11 @@ function dry_create_parseable
done done
log_note "$0: ${cmd[@]}" log_note "$0: ${cmd[@]}"
out=$("${cmd[@]}") out=$("${cmd[@]}") ||
(( $? == 0 )) ||
log_fail "unexpected failure getting stdout from '${cmd[@]}'" log_fail "unexpected failure getting stdout from '${cmd[@]}'"
datasetexists "$TESTPOOL/$TESTFS1" || datasetexists "$TESTPOOL/$TESTFS1" ||
log_fail "$TESTPOOL/$TESTFS1 unexpectedly created by '${cmd[@]}'" 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[@]}" log_note "verifying ${toks[@]}"
case ${toks[0]} in case ${toks[0]} in
create_ancestors) create_ancestors)
@ -107,7 +106,7 @@ function dry_create_parseable
log_fail "Unexpected line ${toks[@]}" log_fail "Unexpected line ${toks[@]}"
;; ;;
esac esac
done done <<<"$out"
log_must test "$found_create" == "yes, I found create" log_must test "$found_create" == "yes, I found create"
log_must test "extra props: ${!exp[@]}" == "extra props: " 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 opt in "" $(gen_option_str "${options[*]}" "-" "" $opt_numb); do
for prop in $(gen_option_str "${props[*]}" "" "," $prop_numb) for prop in $(gen_option_str "${props[*]}" "" "," $prop_numb)
do do
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 done
done done

View File

@ -93,7 +93,7 @@ function test_options
for dst in ${dataset[@]}; do for dst in ${dataset[@]}; do
for opt in $opts; do for opt in $opts; do
for prop in $props; do for prop in $props; do
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 done
done done
@ -113,7 +113,7 @@ function test_options_bookmarks
for dst in ${bookmark[@]}; do for dst in ${bookmark[@]}; do
for opt in $opts; do for opt in $opts; do
for prop in $props; do for prop in $props; do
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 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 \ set -A props type used available creation volsize referenced compressratio \
mounted origin recordsize quota reservation mountpoint sharenfs \ mounted origin recordsize quota reservation mountpoint sharenfs \
checksum compression atime devices exec readonly setuid snapdir \ checksum compression atime devices exec readonly setuid snapdir \
aclinherit canmount primarycache secondarycache \ aclinherit canmount primarycache secondarycache version \
usedbychildren usedbydataset usedbyrefreservation usedbysnapshots \ usedbychildren usedbydataset usedbyrefreservation usedbysnapshots \
userquota@root groupquota@root userused@root groupused@root userquota@root groupquota@root userused@root groupused@root
if is_freebsd; then if is_freebsd; then
@ -62,11 +62,6 @@ else
set -A props ${props[*]} zoned acltype set -A props ${props[*]} zoned acltype
fi 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 \ set -A dataset $TESTPOOL/$TESTCTR $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL \
$TESTPOOL/$TESTFS@$TESTSNAP $TESTPOOL/$TESTVOL@$TESTSNAP $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 \ set -A all_props type used available creation volsize referenced \
compressratio mounted origin recordsize quota reservation mountpoint \ compressratio mounted origin recordsize quota reservation mountpoint \
sharenfs checksum compression atime devices exec readonly setuid \ sharenfs checksum compression atime devices exec readonly setuid \
snapdir aclinherit canmount primarycache secondarycache \ snapdir aclinherit canmount primarycache secondarycache version \
usedbychildren usedbydataset usedbyrefreservation usedbysnapshots \ usedbychildren usedbydataset usedbyrefreservation usedbysnapshots \
userquota@root groupquota@root userused@root groupused@root userquota@root groupquota@root userused@root groupused@root
if is_freebsd; then if is_freebsd; then
@ -64,11 +64,6 @@ else
set -A all_props ${all_props[*]} zoned acltype set -A all_props ${all_props[*]} zoned acltype
fi fi
zfs upgrade -v > /dev/null 2>&1
if [[ $? -eq 0 ]]; then
set -A all_props ${all_props[*]} version
fi
depth_fs_setup depth_fs_setup
mntpnt=$(get_prop mountpoint $DEPTH_FS) mntpnt=$(get_prop mountpoint $DEPTH_FS)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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 file_write -o create -f $init_data -b $BLOCK_SIZE -c $WRITE_COUNT
log_must zfs snapshot $init_snap log_must zfs snapshot $init_snap
zfs send $init_snap > $full_bkup log_must eval "zfs send $init_snap > $full_bkup"
(( $? != 0 )) && \
log_fail "'zfs send' fails to create full send"
log_note "Verify the send stream is valid to receive." 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 file_write -o create -f $inc_data -b $BLOCK_SIZE -c $WRITE_COUNT -d 0
log_must zfs snapshot $inc_snap log_must zfs snapshot $inc_snap
zfs send -i $init_snap $inc_snap > $inc_bkup log_must eval "zfs send -i $init_snap $inc_snap > $inc_bkup"
(( $? != 0 )) && \
log_fail "'zfs send -i' fails to create incremental send"
log_note "Verify the incremental send stream is valid to receive." 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 log_must zfs set $property=$prop_val $fs
file_write -o create -f $origfile -b $BLOCK_SIZE -c $WRITE_COUNT file_write -o create -f $origfile -b $BLOCK_SIZE -c $WRITE_COUNT
log_must zfs snapshot $snap log_must zfs snapshot $snap
zfs send $snap > $stream log_must eval "zfs send $snap > $stream"
(( $? != 0 )) && \ log_must eval "zfs receive -d $ctr <$stream"
log_fail "'zfs send' fails to create send streams."
zfs receive -d $ctr <$stream
(( $? != 0 )) && \
log_fail "'zfs receive' fails to receive send streams."
#verify receive result #verify receive result
! datasetexists $rstfs && \ ! datasetexists $rstfs && \

View File

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

View File

@ -70,15 +70,7 @@ function set_n_check # data-set
j=0 j=0
while (( $j < ${#suffix[*]} )); do while (( $j < ${#suffix[*]} )); do
zfs set \ log_mustnot zfs set reservation=${values[$i]}${suffix[$j]} $obj
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
new_resv_val=$(get_prop reservation $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" mounted origin"
typeset snap_ro_props="volsize recordsize recsize quota reservation reserv mountpoint \ typeset snap_ro_props="volsize recordsize recsize quota reservation reserv mountpoint \
sharenfs checksum compression compress atime devices exec readonly rdonly \ sharenfs checksum compression compress atime devices exec readonly rdonly \
setuid" setuid version"
if is_freebsd; then if is_freebsd; then
snap_ro_props+=" jailed" snap_ro_props+=" jailed"
else else
snap_ro_props+=" zoned" snap_ro_props+=" zoned"
fi fi
zfs upgrade -v > /dev/null 2>&1
if [[ $? -eq 0 ]]; then
snap_ro_props="$snap_ro_props version"
fi
function cleanup function cleanup
{ {
datasetexists $TESTPOOL/$TESTVOL@$TESTSNAP && \ 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_assert "User property has no effect to snapshot until 'Snapshot properties' supported."
log_onexit cleanup 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 for fs in $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL $TESTPOOL ; do
typeset fssnap=$fs@snap typeset fssnap=$fs@snap
prop_name=$(valid_user_property 10) prop_name=$(valid_user_property 10)
value=$(user_property_value 16) value=$(user_property_value 16)
log_must eval "zfs set $prop_name='$value' $fs" log_must zfs set $prop_name="$value" $fs
log_must eval "check_user_prop $fs $prop_name '$value'" log_must check_user_prop $fs $prop_name "$value"
log_must zfs snapshot $fssnap log_must zfs snapshot $fssnap
if [[ -n $snap_property ]] ; then log_mustnot nonexist_user_prop $prop_name $fssnap
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 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 done
log_pass "User properties has effect upon snapshot." 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) orig_val=$(get_prop version $obj)
while (($i < ${#values[*]})); do while (($i < ${#values[*]})); do
zfs set version=${values[$i]} $obj > /dev/null 2>&1 log_mustnot eval "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
new_val=$(get_prop version $obj) new_val=$(get_prop version $obj)

View File

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

View File

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

View File

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

View File

@ -59,18 +59,18 @@ while ((ret == 0)); do
ret=$? ret=$?
if ((ret != 0)); then if ((ret != 0)); then
len=$(echo $basefs| wc -c) len=${#basefs}
log_note "The deeply-nested filesystem len: $len" 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 # for snapshot name space, otherwise snapshot name
# is incorrect # is incorrect
# #
if ((len >= 255)); then if ((len >= 255)); then
datasetexists $basefs && destroy_dataset $basefs -r datasetexists $basefs && destroy_dataset $basefs -r
basefs=${basefs%/*} basefs=${basefs%/*}
len=$(echo $basefs| wc -c) len=${#basefs}
fi fi
break break
fi fi

View File

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

View File

@ -72,18 +72,13 @@ typeset ro_props="type used available avail creation referenced refer compressra
mounted origin" mounted origin"
typeset snap_ro_props="volsize recordsize recsize quota reservation reserv mountpoint \ typeset snap_ro_props="volsize recordsize recsize quota reservation reserv mountpoint \
sharenfs checksum compression compress atime devices exec readonly rdonly \ sharenfs checksum compression compress atime devices exec readonly rdonly \
setuid" setuid version"
if is_freebsd; then if is_freebsd; then
snap_ro_props+=" jailed" snap_ro_props+=" jailed"
else else
snap_ro_props+=" zoned" snap_ro_props+=" zoned"
fi 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 for fs in $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL $TESTPOOL/$TESTCTR $TESTPOOL ; do
typeset fssnap=$fs@snap typeset fssnap=$fs@snap

View File

@ -53,7 +53,7 @@ function do_unmount #cmd #opt #mnt #expect
zfs $cmd $opt $mnt zfs $cmd $opt $mnt
ret=$? ret=$?
if (( ret != expect)); then if (( ret != expect )); then
log_fail "'zfs $cmd $opt $mnt' " \ log_fail "'zfs $cmd $opt $mnt' " \
"unexpected return code of $ret." "unexpected return code of $ret."
fi fi

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -75,25 +75,16 @@ log_must zpool get all $TESTPOOL
zpool get all $TESTPOOL > $values zpool get all $TESTPOOL > $values
# check for the cachefile property, verifying that it's set to 'none' # check for the cachefile property, verifying that it's set to 'none'
grep "$TESTPOOL[ ]*cachefile[ ]*none" $values > /dev/null 2>&1 log_must grep -q "$TESTPOOL[ ]*cachefile[ ]*none" $values
if [ $? -ne 0 ]
then
log_fail "zpool property \'cachefile\' was not set to \'none\'."
fi
# check that the root = /mountpoint property is set correctly # check that the root = /mountpoint property is set correctly
grep "$TESTPOOL[ ]*altroot[ ]*/${TESTPOOL}.root" $values > /dev/null 2>&1 log_must grep -q "$TESTPOOL[ ]*altroot[ ]*/${TESTPOOL}.root" $values
if [ $? -ne 0 ]
then
log_fail "zpool property root was not found in pool output."
fi
rm $values rm $values
# finally, check that the pool has no reference in /etc/zfs/zpool.cache # finally, check that the pool has no reference in /etc/zfs/zpool.cache
if [[ -f /etc/zfs/zpool.cache ]] ; then if [[ -f /etc/zfs/zpool.cache ]] ; then
REF=$(strings /etc/zfs/zpool.cache | grep ${TESTPOOL}) if strings /etc/zfs/zpool.cache | grep -q ${TESTPOOL}
if [ ! -z "$REF" ]
then then
strings /etc/zfs/zpool.cache strings /etc/zfs/zpool.cache
log_fail "/etc/zfs/zpool.cache appears to have a reference to $TESTPOOL" 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 retry=10
typeset j=0 typeset j=0
truncate -s $FILESIZE $vdev0 truncate -s $FILESIZE $vdev0 $vdev1
truncate -s $FILESIZE $vdev1
while [[ $j -lt $iters ]]; do while [[ $j -lt $iters ]]; do
((j = j + 1)) ((j = j + 1))
sleep 1 sleep 1
zpool create $pool $vdev0 $vdev1 zpool create $pool $vdev0 $vdev1 || return 1
if [ $? -ne 0 ]; then
return 1;
fi
# The 'zfs destroy' command is retried because it can # The 'zfs destroy' command is retried because it can
# transiently return EBUSY when blkid is concurrently # transiently return EBUSY when blkid is concurrently
@ -100,13 +96,8 @@ function zpool_stress
while [[ $k -lt $retry ]]; do while [[ $k -lt $retry ]]; do
((k = k + 1)) ((k = k + 1))
zpool destroy $pool zpool destroy $pool && break
if [ $? -eq 0 ]; then [ $k -eq $retry ] && return 1
break;
elif [ $k -eq $retry ]; then
return 1;
fi
sleep 3 sleep 3
done done
done done

View File

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

View File

@ -50,10 +50,8 @@ log_must zpool create $NEWPOOL $DISK
log_must zpool events -c log_must zpool events -c
# 3. Generate some ZFS events on both pools # 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 log_must zpool clear $TESTPOOL
done
for i in `seq 1 $EVENTS_NUM`; do
log_must zpool clear $NEWPOOL log_must zpool clear $NEWPOOL
done done
# wait a bit to allow the kernel module to process new events # 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 # 4. Verify 'zpool events poolname' successfully display events
zpool events -v $TESTPOOL | zpool events -v $TESTPOOL |
awk -v POOL=$TESTPOOL '/pool = / {if ($3 != "\""POOL"\"") exit 1}' awk -v POOL=$TESTPOOL '/pool = / && $3 != "\""POOL"\"" {exit 1}' ||
if [[ $? -ne 0 ]]; then
log_fail "Unexpected events for pools other than $TESTPOOL" log_fail "Unexpected events for pools other than $TESTPOOL"
fi
zpool events -v $NEWPOOL | zpool events -v $NEWPOOL |
awk -v POOL=$NEWPOOL '/pool = / {if ($3 != "\""POOL"\"") exit 1}' awk -v POOL=$NEWPOOL '/pool = / && $3 != "\""POOL"\"" {exit 1}' ||
if [[ $? -ne 0 ]]; then
log_fail "Unexpected events for pools other than $NEWPOOL" log_fail "Unexpected events for pools other than $NEWPOOL"
fi
log_pass "'zpool events poolname' display events only from the chosen pool." 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 |\ typeset size_addition=$(zpool history -il $TESTPOOL1 |\
grep "pool '$TESTPOOL1' size:" | \ grep "pool '$TESTPOOL1' size:" | \
grep "vdev online" | \ grep "vdev online" | \
grep "(+${expansion_size}" | wc -l) grep -c "(+${expansion_size}")
if [[ $size_addition -ne 3 ]]; then if [[ $size_addition -ne 3 ]]; then
log_fail "pool $TESTPOOL1 has not expanded, " \ log_fail "pool $TESTPOOL1 has not expanded, " \
@ -139,31 +139,22 @@ for type in " " mirror raidz draid:1s; do
zpool history -il $TESTPOOL1 | \ zpool history -il $TESTPOOL1 | \
grep "pool '$TESTPOOL1' size:" | \ grep "pool '$TESTPOOL1' size:" | \
grep "vdev online" | \ grep "vdev online" | \
grep "(+${expansion_size})" >/dev/null 2>&1 grep -q "(+${expansion_size})" ||
if [[ $? -ne 0 ]] ; then
log_fail "pool $TESTPOOL1 has not expanded" log_fail "pool $TESTPOOL1 has not expanded"
fi
elif [[ $type == "draid:1s" ]]; then elif [[ $type == "draid:1s" ]]; then
typeset expansion_size=$((2*($exp_size-$org_size))) typeset expansion_size=$((2*($exp_size-$org_size)))
zpool history -il $TESTPOOL1 | \ zpool history -il $TESTPOOL1 | \
grep "pool '$TESTPOOL1' size:" | \ grep "pool '$TESTPOOL1' size:" | \
grep "vdev online" | \ grep "vdev online" | \
grep "(+${expansion_size})" >/dev/null 2>&1 grep -q "(+${expansion_size})" ||
log_fail "pool $TESTPOOL has not expanded"
if [[ $? -ne 0 ]]; then
log_fail "pool $TESTPOOL has not expanded"
fi
else else
typeset expansion_size=$((3*($exp_size-$org_size))) typeset expansion_size=$((3*($exp_size-$org_size)))
zpool history -il $TESTPOOL1 | \ zpool history -il $TESTPOOL1 | \
grep "pool '$TESTPOOL1' size:" | \ grep "pool '$TESTPOOL1' size:" | \
grep "vdev online" | \ grep "vdev online" | \
grep "(+${expansion_size})" >/dev/null 2>&1 grep -q "(+${expansion_size})" ||
log_fail "pool $TESTPOOL has not expanded"
if [[ $? -ne 0 ]]; then
log_fail "pool $TESTPOOL has not expanded"
fi
fi fi
else else
log_fail "pool $TESTPOOL1 is not autoexpanded after vdev " \ log_fail "pool $TESTPOOL1 is not autoexpanded after vdev " \

View File

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

View File

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

View File

@ -45,9 +45,7 @@ verify_runnable "global"
function cleanup function cleanup
{ {
cd $olddir || \ log_must cd $olddir
log_fail "Couldn't cd back to $olddir"
zpool_export_cleanup zpool_export_cleanup
} }
@ -57,16 +55,9 @@ log_onexit cleanup
log_assert "Verify a busy ZPOOL cannot be exported." log_assert "Verify a busy ZPOOL cannot be exported."
ismounted "$TESTPOOL/$TESTFS" log_must ismounted "$TESTPOOL/$TESTFS"
(( $? != 0 )) && \ log_must cd $TESTDIR
log_fail "$TESTDIR not mounted. Unable to continue."
cd $TESTDIR || \
log_fail "Couldn't cd to $TESTDIR"
log_mustnot zpool export $TESTPOOL log_mustnot zpool export $TESTPOOL
log_must poolexists $TESTPOOL
poolexists $TESTPOOL || \
log_fail "$TESTPOOL not found in 'zpool list' output."
log_pass "Unable to export a busy ZPOOL as expected." 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 zpool get all $TESTPOOL > $values
log_note "Checking zpool get all output for a header." log_note "Checking zpool get all output for a header."
grep ^"NAME " $values > /dev/null 2>&1 log_must grep -q ^"NAME " $values
if [ $? -ne 0 ]
then
log_fail "The header was not printed from zpool get all"
fi
while [ $i -lt "${#properties[@]}" ] while [ $i -lt "${#properties[@]}" ]
do do
log_note "Checking for ${properties[$i]} property" log_note "Checking for ${properties[$i]} property"
grep "$TESTPOOL *${properties[$i]}" $values > /dev/null 2>&1 log_must grep -q "$TESTPOOL *${properties[$i]}" $values
if [ $? -ne 0 ]
then
log_fail "zpool property ${properties[$i]} was not found\
in pool output."
fi
i=$(( $i + 1 )) i=$(( $i + 1 ))
done done

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -20,7 +20,7 @@
function clear_labels #disks function clear_labels #disks
{ {
for disk in $@; do 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 zpool labelclear -f /dev/$disk
else else
zpool labelclear -f /dev/${disk}1 zpool labelclear -f /dev/${disk}1
@ -90,19 +90,16 @@ function wait_for_action #pool timeout function
function wait_for_resilver_start #pool timeout function wait_for_resilver_start #pool timeout
{ {
wait_for_action $1 $2 is_pool_resilvering wait_for_action $1 $2 is_pool_resilvering
return $?
} }
function wait_for_resilver_end #pool timeout function wait_for_resilver_end #pool timeout
{ {
wait_for_action $1 $2 is_pool_resilvered wait_for_action $1 $2 is_pool_resilvered
return $?
} }
function wait_for_scrub_end #pool timeout function wait_for_scrub_end #pool timeout
{ {
wait_for_action $1 $2 is_pool_scrubbed 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 function is_scan_restarted #pool
{ {
typeset pool=$1 zpool history -i $1 | grep -q "scan aborted, restarting"
zpool history -i $pool | grep -q "scan aborted, restarting"
return $?
} }
function is_deferred_scan_started #pool function is_deferred_scan_started #pool
{ {
typeset pool=$1 zpool history -i $1 | grep -q "starting deferred resilver"
zpool history -i $pool | grep -q "starting deferred resilver"
return $?
} }

View File

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

View File

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

View File

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

View File

@ -44,19 +44,13 @@
function check_zdb function check_zdb
{ {
$@ > $TEST_BASE_DIR/zdb.$$ log_mustnot eval "$* | grep -q 'Dataset mos'"
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.$$
} }
function cleanup 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" verify_runnable "global"
@ -66,7 +60,7 @@ log_onexit cleanup
log_must eval "zdb > $TEST_BASE_DIR/zdb_001_neg.$$.txt" log_must eval "zdb > $TEST_BASE_DIR/zdb_001_neg.$$.txt"
# verify the output looks okay # 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 log_must rm $TEST_BASE_DIR/zdb_001_neg.$$.txt
# we shouldn't able to run it on any dataset # 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_assert "zfs unallow returns an error when run as a user"
log_mustnot zfs unallow everyone $TESTPOOL/$TESTFS/allowed log_mustnot zfs unallow everyone $TESTPOOL/$TESTFS/allowed
# now check with zfs allow to see if the permissions are still there # now check with zfs allow to see if the permissions are still there
OUTPUT=$(zfs allow $TESTPOOL/$TESTFS/allowed | grep "Local+Descendent" ) if ! zfs allow $TESTPOOL/$TESTFS/allowed | grep -q "Local+Descendent"
if [ -z "$OUTPUT" ]
then then
log_fail "Error - create permissions were unallowed on \ log_fail "Error - create permissions were unallowed on \
$TESTPOOL/$TESTFS/allowed" $TESTPOOL/$TESTFS/allowed"

View File

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

View File

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

View File

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

View File

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

View File

@ -114,10 +114,7 @@ do
# Reimport pool with drive missing # Reimport pool with drive missing
log_must zpool import $TESTPOOL log_must zpool import $TESTPOOL
check_state $TESTPOOL "" "degraded" log_must check_state $TESTPOOL "" "degraded"
if (($? != 0)); then
log_fail "$TESTPOOL is not degraded"
fi
# Clear zpool events # Clear zpool events
log_must zpool events -c log_must zpool events -c
@ -143,10 +140,7 @@ do
done done
# Validate auto-online was successful # Validate auto-online was successful
check_state $TESTPOOL "" "online" log_must check_state $TESTPOOL "" "online"
if (($? != 0)); then
log_fail "$TESTPOOL is not back online"
fi
sleep 2 sleep 2
done done
log_must zpool destroy $TESTPOOL 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 destroy -f $migratedpoolname
log_must zpool import -d $import_dir $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 # The migrated history file should differ with original history file on
# two commands -- 'export' and 'import', which are included in migrated # two commands -- 'export' and 'import', which are included in migrated
@ -89,20 +89,20 @@ for arch in "i386" "sparc"; do
# then compare this filtered file with the original history file. They # then compare this filtered file with the original history file. They
# should be identical at this time. # should be identical at this time.
for subcmd in "export" "import"; do for subcmd in "export" "import"; do
grep -q "$subcmd" $migrated_cmds_f || \ grep -q "$subcmd" $migrated_cmds_f ||
log_fail "zpool $subcmd is not logged for" \ log_fail "zpool $subcmd is not logged for" \
"the imported pool $migratedpoolname." "the imported pool $migratedpoolname."
done done
tmpfile=$import_dir/cmds_tmp.$$ tmpfile=$import_dir/cmds_tmp.$$
linenum=`wc -l < $migrated_cmds_f` linenum=$(wc -l < $migrated_cmds_f)
(( linenum = linenum - 2 )) (( linenum = linenum - 2 ))
head -n $linenum $migrated_cmds_f > $tmpfile head -n $linenum $migrated_cmds_f > $tmpfile
log_must diff $tmpfile $orig_cmds_f1 log_must diff $tmpfile $orig_cmds_f1
# cleanup for next loop testing # cleanup for next loop testing
log_must zpool destroy -f $migratedpoolname log_must zpool destroy -f $migratedpoolname
log_must rm -f `ls $import_dir` log_must rm -f $(ls $import_dir)
done done
log_pass "Verify command history moves with migrated pool." log_pass "Verify command history moves with migrated pool."

View File

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

View File

@ -34,18 +34,12 @@
# #
function get_prop_src # property dataset function get_prop_src # property dataset
{ {
typeset prop_val
typeset prop=$1 typeset prop=$1
typeset dataset=$2 typeset dataset=$2
prop_val=`zfs get -H -o source $prop $dataset` zfs get -H -o source $prop $dataset ||
log_fail "Unable to determine the source of $prop" \
if [[ $? -ne 0 ]]; then
log_fail "Unable to determine the source of $prop " \
"property for dataset $dataset" "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 prop=$2
typeset expected=$3 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 # Rather than just checking if $prop_src == $expected
@ -105,7 +99,7 @@ function set_n_verify_prop #property value dataset
typeset dataset=$3 typeset dataset=$3
zfs set $prop=$prop_val $dataset zfs set $prop=$prop_val $dataset
check_val=`get_prop $prop $dataset` check_val=$(get_prop $prop $dataset)
if [[ $check_val != $prop_val ]]; then if [[ $check_val != $prop_val ]]; then
log_fail "Property $prop of $dataset has value $check_val"\ 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 for p in ${prop[i]} ${prop[((i+1))]}; do
zfs $op $p $target zfs $op $p $target
ret=$? check_failure $? "zfs $op $p $target"
check_failure $ret "zfs $op $p \
$target"
done done
fi fi
for check_obj in $list; do for check_obj in $list; do
@ -349,16 +347,14 @@ function scan_state { #state-file
# check_failure to keep journal small # check_failure to keep journal small
verify_prop_src $check_obj $p \ verify_prop_src $check_obj $p \
$final_src $final_src
ret=$? check_failure $? "verify" \
check_failure $ret "verify" \
"_prop_src $check_obj $p" \ "_prop_src $check_obj $p" \
"$final_src" "$final_src"
# Again, to keep journal size down. # Again, to keep journal size down.
verify_prop_val $p $check_obj \ verify_prop_val $p $check_obj \
$final_src $j $final_src $j
ret=$? check_failure $? "verify" \
check_failure $ret "verify" \
"_prop_val $check_obj $p" \ "_prop_val $check_obj $p" \
"$final_src" "$final_src"
done done

View File

@ -92,8 +92,8 @@ typeset -i filenum=0
typeset cwd="" typeset cwd=""
log_note "Make a ufs filesystem on source $rawdisk1" log_note "Make a ufs filesystem on source $rawdisk1"
new_fs $rawdisk1 > /dev/null 2>&1 new_fs $rawdisk1 > /dev/null 2>&1 ||
(($? != 0)) && log_untested "Unable to create ufs filesystem on $rawdisk1" log_untested "Unable to create ufs filesystem on $rawdisk1"
log_must mkdir -p $UFSMP 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 while (($dirnum <= 2)); do
log_must mkdir $bigdir${dirnum} log_must mkdir $bigdir${dirnum}
while (( $filenum <= 2 )); do 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 -b $BLOCK_SIZE -c $BLOCK_COUNT
if [[ $? -ne 0 ]]; then then
if [[ $dirnum -lt 3 ]]; then if [[ $dirnum -lt 3 ]]; then
log_fail "file_write only wrote" \ log_fail "file_write only wrote" \
"<(( $dirnum * 3 + $filenum ))>" \ "<(( $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 zpool create $TESTPOOL1 "$FS_DISK2" spare "$disk1"
log_mustnot poolexists $TESTPOOL1 log_mustnot poolexists $TESTPOOL1
wait $PIDUFSDUMP wait $PIDUFSDUMP || log_fail "ufsdump failed with error code $?"
typeset -i retval=$?
(($retval != 0)) && log_fail "ufsdump failed with error code $ret_val"
log_must mount $disk1 $UFSMP log_must mount $disk1 $UFSMP

View File

@ -52,10 +52,10 @@ function cleanup
# to work correctly. So its reproduced below. Still need to fully # to work correctly. So its reproduced below. Still need to fully
# understand why default_cleanup does not work correctly from here. # understand why default_cleanup does not work correctly from here.
# #
log_must zfs umount $TESTPOOL/$TESTFS log_must zfs umount $TESTPOOL/$TESTFS
rm -rf $TESTDIR || \ rm -rf $TESTDIR ||
log_unresolved Could not remove $TESTDIR log_unresolved Could not remove $TESTDIR
log_must zfs destroy $TESTPOOL/$TESTFS log_must zfs destroy $TESTPOOL/$TESTFS
destroy_pool $TESTPOOL destroy_pool $TESTPOOL
@ -71,21 +71,11 @@ function mini_format
if is_linux; then if is_linux; then
parted $disk -s -- mklabel gpt parted $disk -s -- mklabel gpt
typeset -i retval=$?
elif is_freebsd; then elif is_freebsd; then
gpart create -s gpt $disk gpart create -s gpt $disk
typeset -i retval=$?
else else
typeset format_file=$TEST_BASE_DIR/format_in.$$.1 format -e -s -d $disk -f <(printf '%s\n' partition modify)
echo "partition" > $format_file
echo "modify" >> $format_file
format -e -s -d $disk -f $format_file
typeset -i retval=$?
rm -rf $format_file
fi fi
return $retval
} }
log_assert "format will disallow modification of a mounted zfs disk partition"\ 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. # units for 'df'. It must be greater than one.
# ----------------------------------------------------------------------- # -----------------------------------------------------------------------
typeset str typeset str
typeset -i ret
for volsize in $VOLSIZES; do for volsize in $VOLSIZES; do
log_note "Create a pool which will contain a volume device" log_note "Create a pool which will contain a volume device"
log_must create_pool $TESTPOOL2 "$DISKS" log_must create_pool $TESTPOOL2 "$DISKS"
log_note "Create a volume device of desired sizes: $volsize" log_note "Create a volume device of desired sizes: $volsize"
str=$(zfs create -sV $volsize $TESTPOOL2/$TESTVOL 2>&1) if ! str=$(zfs create -sV $volsize $TESTPOOL2/$TESTVOL 2>&1); then
ret=$?
if (( ret != 0 )); then
if [[ is_32bit && \ if [[ is_32bit && \
$str == *${VOL_LIMIT_KEYWORD1}* || \ $str == *${VOL_LIMIT_KEYWORD1}* || \
$str == *${VOL_LIMIT_KEYWORD2}* || \ $str == *${VOL_LIMIT_KEYWORD2}* || \

View File

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

View File

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

View File

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

View File

@ -34,12 +34,12 @@
# #
# DESCRIPTION: # 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: # STRATEGY:
# 1. Calculate chksum of testfile # 1. Calculate chksum of testfile
# 2. Tar up test file and place on a ZFS filesystem # 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 # 4. Calculate chksum of extracted file
# 5. Compare old and new chksums. # 5. Compare old and new chksums.
# #
@ -48,19 +48,14 @@ verify_runnable "both"
function cleanup function cleanup
{ {
rm -rf $TESTDIR/tar$$.tar rm -rf $TESTDIR/tar$$.tar $NONZFS_TESTDIR/$BNAME
rm -rf $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 log_onexit cleanup
prepare $DNAME "tar cf $TESTDIR/tar$$.tar $BNAME" log_must prepare $DNAME "tar cf $TESTDIR/tar$$.tar $BNAME"
(( $? != 0 )) && log_fail "Unable to create src archive" log_must migrate $NONZFS_TESTDIR $SUMA $SUMB "tar xf $TESTDIR/tar$$.tar"
migrate $NONZFS_TESTDIR $SUMA $SUMB "tar xf $TESTDIR/tar$$.tar" log_pass "Successfully migrated test file from ZFS fs to $NEWFS_DEFAULT_FS fs".
(( $? != 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".

View File

@ -34,11 +34,11 @@
# #
# DESCRIPTION: # 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: # STRATEGY:
# 1. Calculate chksum of testfile # 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 # 3. Extract tar contents to a ZFS file system
# 4. Calculate chksum of extracted file # 4. Calculate chksum of extracted file
# 5. Compare old and new chksums. # 5. Compare old and new chksums.
@ -48,19 +48,14 @@ verify_runnable "both"
function cleanup function cleanup
{ {
rm -rf $NONZFS_TESTDIR/tar$$.tar rm -rf $NONZFS_TESTDIR/tar$$.tar $TESTDIR/$BNAME
rm -rf $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 log_onexit cleanup
prepare $DNAME "tar cf $NONZFS_TESTDIR/tar$$.tar $BNAME" log_must prepare $DNAME "tar cf $NONZFS_TESTDIR/tar$$.tar $BNAME"
(( $? != 0 )) && log_fail "Unable to create src archive" log_must migrate $TESTDIR $SUMA $SUMB "tar xvf $NONZFS_TESTDIR/tar$$.tar"
migrate $TESTDIR $SUMA $SUMB "tar xvf $NONZFS_TESTDIR/tar$$.tar" log_pass "Successfully migrated test file from $NEWFS_DEFAULT_FS fs to ZFS fs".
(( $? != 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".

View File

@ -48,8 +48,7 @@ verify_runnable "both"
function cleanup function cleanup
{ {
rm -rf $TESTDIR/cpio$$.cpio rm -rf $TESTDIR/cpio$$.cpio $TESTDIR/$BNAME
rm -rf $TESTDIR/$BNAME
} }
log_assert "Migrating test file from ZFS fs to ZFS fs using cpio" 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 log_onexit cleanup
cwd=$PWD cwd=$PWD
cd $DNAME log_must cd $DNAME
(( $? != 0 )) && log_untested "Could not change directory to $DNAME" log_must eval "find $BNAME | cpio -oc > $TESTDIR/cpio$$.cpio"
log_must cd $cwd
ls $BNAME | cpio -oc > $TESTDIR/cpio$$.cpio log_must migrate_cpio $TESTDIR "$TESTDIR/cpio$$.cpio" $SUMA $SUMB
(( $? != 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_pass "Successfully migrated test file from ZFS fs to ZFS fs". log_pass "Successfully migrated test file from ZFS fs to ZFS fs".

View File

@ -34,12 +34,12 @@
# #
# DESCRIPTION: # 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: # STRATEGY:
# 1. Calculate chksum of testfile # 1. Calculate chksum of testfile
# 2. Cpio up test file and place on a ZFS filesystem # 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 # 4. Calculate chksum of extracted file
# 5. Compare old and new chksums. # 5. Compare old and new chksums.
# #
@ -48,26 +48,17 @@ verify_runnable "both"
function cleanup function cleanup
{ {
rm -rf $TESTDIR/cpio$$.cpio rm -rf $TESTDIR/cpio$$.cpio $NONZFS_TESTDIR/$BNAME
rm -rf $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 log_onexit cleanup
cwd=$PWD cwd=$PWD
cd $DNAME log_must cd $DNAME
(( $? != 0 )) && log_untested "Could not change directory to $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 log_pass "Successfully migrated test file from ZFS fs to $NEWFS_DEFAULT_FS fs".
(( $? != 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".

View File

@ -48,8 +48,7 @@ verify_runnable "both"
function cleanup function cleanup
{ {
rm -rf $NONZFS_TESTDIR/cpio$$.cpio rm -rf $NONZFS_TESTDIR/cpio$$.cpio $TESTDIR/$BNAME
rm -rf $TESTDIR/$BNAME
} }
log_assert "Migrating test file from UFS fs to ZFS fs using cpio" 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 log_onexit cleanup
cwd=$PWD cwd=$PWD
cd $DNAME log_must cd $DNAME
(( $? != 0 )) && log_untested "Could not change directory to $DNAME" log_must eval "find $BNAME | cpio -oc > $NONZFS_TESTDIR/cpio$$.cpio"
log_must cd $cwd
ls $BNAME | cpio -oc > $NONZFS_TESTDIR/cpio$$.cpio log_must migrate_cpio $TESTDIR "$NONZFS_TESTDIR/cpio$$.cpio" $SUMA $SUMB
(( $? != 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_pass "Successfully migrated test file from UFS fs to ZFS fs". log_pass "Successfully migrated test file from UFS fs to ZFS fs".

View File

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

View File

@ -34,12 +34,12 @@
# #
# DESCRIPTION: # 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: # STRATEGY:
# 1. Calculate chksum of testfile # 1. Calculate chksum of testfile
# 2. Dd up test file and place on a ZFS filesystem # 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 # 4. Calculate chksum of extracted file
# 5. Compare old and new chksums. # 5. Compare old and new chksums.
# #
@ -48,19 +48,14 @@ verify_runnable "both"
function cleanup function cleanup
{ {
rm -rf $TESTDIR/dd$$.dd rm -rf $TESTDIR/dd$$.dd $NONZFS_TESTDIR/$BNAME
rm -rf $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 log_onexit cleanup
prepare $DNAME "dd if=$BNAME obs=128k of=$TESTDIR/dd$$.dd" log_must prepare $DNAME "dd if=$BNAME obs=128k of=$TESTDIR/dd$$.dd"
(( $? != 0 )) && log_fail "Unable to create src archive" 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" log_pass "Successfully migrated test file from ZFS fs to $NEWFS_DEFAULT_FS fs".
(( $? != 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".

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