tests: review every awk(1) invocation

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-11 23:54:08 +01:00 committed by Brian Behlendorf
parent 72f3516094
commit 75746e9a40
132 changed files with 402 additions and 762 deletions

View File

@ -156,12 +156,11 @@ main(int argc, const char * const argv[])
(void) close(fd); (void) close(fd);
char buffer[BUFFER_SIZE]; char buffer[BUFFER_SIZE] = "";
memset(buffer, 0, BUFFER_SIZE);
(void) attribute_to_str(dosflags, buffer); (void) attribute_to_str(dosflags, buffer);
(void) printf("%s\n", buffer); (void) puts(buffer);
return (EXIT_SUCCESS); return (EXIT_SUCCESS);
} }

View File

@ -223,13 +223,11 @@ function set_slice_prefix
if is_linux; then if is_linux; then
while (( i < $DISK_ARRAY_NUM )); do while (( i < $DISK_ARRAY_NUM )); do
disk="$(echo $DISKS | nawk '{print $(i + 1)}')" disk="$(echo $DISKS | awk '{print $(i + 1)}')"
if ( is_mpath_device $disk ) && [[ -z $(echo $disk | awk 'substr($1,18,1)\ if is_mpath_device $disk && ! echo $disk | awk 'substr($1,18,1) ~ /^[[:digit:]]+$/ {exit 1}' || is_real_device $disk; then
~ /^[[:digit:]]+$/') ]] || ( is_real_device $disk ); then
export SLICE_PREFIX="" export SLICE_PREFIX=""
return 0 return 0
elif ( is_mpath_device $disk || is_loop_device \ elif is_mpath_device $disk || is_loop_device $disk; then
$disk ); then
export SLICE_PREFIX="p" export SLICE_PREFIX="p"
return 0 return 0
else else
@ -518,11 +516,11 @@ function get_pool_devices #testpool #devdir
typeset devdir=$2 typeset devdir=$2
typeset out="" typeset out=""
if is_linux || is_freebsd; then case $(uname) in
out=$(zpool status -P $testpool |grep ${devdir} | awk '{print $1}') Linux|FreeBSD)
out=$(echo $out | sed -e "s|${devdir}/||g" | tr '\n' ' ') zpool status -P $testpool | awk -v d="$devdir" '$1 ~ d {sub(d "/", ""); printf("%s ", $1)}'
fi ;;
echo $out esac
} }
# #

View File

@ -149,14 +149,11 @@ function ismounted
case $fstype in case $fstype in
zfs) zfs)
if [[ "$1" == "/"* ]] ; then if [[ "$1" == "/"* ]] ; then
for out in $(zfs mount | awk '{print $2}'); do ! zfs mount | awk -v fs="$1" '$2 == fs {exit 1}'
[[ $1 == $out ]] && return 0
done
else else
for out in $(zfs mount | awk '{print $1}'); do ! zfs mount | awk -v ds="$1" '$1 == ds {exit 1}'
[[ $1 == $out ]] && return 0
done
fi fi
return $?
;; ;;
ufs|nfs) ufs|nfs)
if is_freebsd; then if is_freebsd; then
@ -178,7 +175,7 @@ function ismounted
fi fi
;; ;;
ext*) ext*)
out=$(df -t $fstype $1 2>/dev/null) df -t $fstype $1 > /dev/null 2>&1
return $? return $?
;; ;;
zvol) zvol)
@ -608,10 +605,8 @@ function default_cleanup_noexit
log_must zfs set reservation=none $fs log_must zfs set reservation=none $fs
log_must zfs set recordsize=128K $fs log_must zfs set recordsize=128K $fs
log_must zfs set mountpoint=/$fs $fs log_must zfs set mountpoint=/$fs $fs
typeset enc="" typeset enc=$(get_prop encryption $fs)
enc=$(get_prop encryption $fs) if [ -z "$enc" ] || [ "$enc" = "off" ]; then
if [[ $? -ne 0 ]] || [[ -z "$enc" ]] || \
[[ "$enc" == "off" ]]; then
log_must zfs set checksum=on $fs log_must zfs set checksum=on $fs
fi fi
log_must zfs set compression=off $fs log_must zfs set compression=off $fs
@ -684,8 +679,6 @@ function destroy_snapshot
typeset mtpt="" typeset mtpt=""
if ismounted $snap; then if ismounted $snap; then
mtpt=$(get_prop mountpoint $snap) mtpt=$(get_prop mountpoint $snap)
(($? != 0)) && \
log_fail "get_prop mountpoint $snap failed."
fi fi
destroy_dataset "$snap" destroy_dataset "$snap"
@ -710,8 +703,6 @@ function destroy_clone
typeset mtpt="" typeset mtpt=""
if ismounted $clone; then if ismounted $clone; then
mtpt=$(get_prop mountpoint $clone) mtpt=$(get_prop mountpoint $clone)
(($? != 0)) && \
log_fail "get_prop mountpoint $clone failed."
fi fi
destroy_dataset "$clone" destroy_dataset "$clone"
@ -743,7 +734,6 @@ function destroy_bookmark
function snapexists function snapexists
{ {
zfs list -H -t snapshot "$1" > /dev/null 2>&1 zfs list -H -t snapshot "$1" > /dev/null 2>&1
return $?
} }
# #
@ -754,7 +744,6 @@ function snapexists
function bkmarkexists function bkmarkexists
{ {
zfs list -H -t bookmark "$1" > /dev/null 2>&1 zfs list -H -t bookmark "$1" > /dev/null 2>&1
return $?
} }
# #
@ -765,8 +754,7 @@ function bkmarkexists
# #
function holdexists function holdexists
{ {
zfs holds "$2" | awk '{ print $2 }' | grep "$1" > /dev/null 2>&1 ! zfs holds "$2" | awk -v t="$1" '$2 ~ t { exit 1 }'
return $?
} }
# #
@ -934,9 +922,8 @@ function set_partition
# Determine the cylinder size for the device and using # Determine the cylinder size for the device and using
# that calculate the end offset in cylinders. # that calculate the end offset in cylinders.
typeset -i cly_size_kb=0 typeset -i cly_size_kb=0
cly_size_kb=$(parted -m $disk -s -- \ cly_size_kb=$(parted -m $disk -s -- unit cyl print |
unit cyl print | head -3 | tail -1 | \ awk -F '[:k.]' 'NR == 3 {print $4}')
awk -F '[:k.]' '{print $4}')
((end = (size_mb * 1024 / cly_size_kb) + start)) ((end = (size_mb * 1024 / cly_size_kb) + start))
parted $disk -s -- \ parted $disk -s -- \
@ -1077,15 +1064,14 @@ function get_endslice #<disk> <slice>
typeset -i ratio=0 typeset -i ratio=0
ratio=$(prtvtoc /dev/rdsk/${disk}s2 | \ ratio=$(prtvtoc /dev/rdsk/${disk}s2 | \
grep "sectors\/cylinder" | \ awk '/sectors\/cylinder/ {print $2}')
awk '{print $2}')
if ((ratio == 0)); then if ((ratio == 0)); then
return return
fi fi
typeset -i endcyl=$(prtvtoc -h /dev/rdsk/${disk}s2 | typeset -i endcyl=$(prtvtoc -h /dev/rdsk/${disk}s2 |
nawk -v token="$slice" '{if ($1==token) print $6}') awk -v token="$slice" '$1 == token {print $6}')
((endcyl = (endcyl + 1) / ratio)) ((endcyl = (endcyl + 1) / ratio))
;; ;;
@ -1163,56 +1149,22 @@ function fill_fs # destdir dirnum filenum bytes num_writes data
return 0 return 0
} }
# # Get the specified dataset property in parsable format or fail
# Simple function to get the specified property. If unable to
# get the property then exits.
#
# Note property is in 'parsable' format (-p)
#
function get_prop # property dataset function get_prop # property dataset
{ {
typeset prop_val
typeset prop=$1 typeset prop=$1
typeset dataset=$2 typeset dataset=$2
prop_val=$(zfs get -pH -o value $prop $dataset 2>/dev/null) zfs get -Hpo value "$prop" "$dataset" || log_fail "zfs get $prop $dataset"
if [[ $? -ne 0 ]]; then
log_note "Unable to get $prop property for dataset " \
"$dataset"
return 1
fi
echo "$prop_val"
return 0
} }
# # Get the specified pool property in parsable format or fail
# Simple function to get the specified property of pool. If unable to
# get the property then exits.
#
# Note property is in 'parsable' format (-p)
#
function get_pool_prop # property pool function get_pool_prop # property pool
{ {
typeset prop_val
typeset prop=$1 typeset prop=$1
typeset pool=$2 typeset pool=$2
if poolexists $pool ; then zpool get -Hpo value "$prop" "$pool" || log_fail "zpool get $prop $pool"
prop_val=$(zpool get -pH $prop $pool 2>/dev/null | tail -1 | \
awk '{print $3}')
if [[ $? -ne 0 ]]; then
log_note "Unable to get $prop property for pool " \
"$pool"
return 1
fi
else
log_note "Pool $pool not exists."
return 1
fi
echo "$prop_val"
return 0
} }
# Return 0 if a pool exists; $? otherwise # Return 0 if a pool exists; $? otherwise
@ -1988,19 +1940,16 @@ function verify_ashift # device ashift
typeset device="$1" typeset device="$1"
typeset ashift="$2" typeset ashift="$2"
zdb -e -lll $device | awk -v ashift=$ashift '/ashift: / { zdb -e -lll $device | awk -v ashift=$ashift '
/ashift: / {
if (ashift != $2) if (ashift != $2)
exit 1; exit 1;
else else
count++; count++;
} END { }
if (count != 4) END {
exit 1; exit (count != 4);
else
exit 0;
}' }'
return $?
} }
# #
@ -2375,35 +2324,24 @@ function find_disks
swap -l > $sfi swap -l > $sfi
dumpadm > $dmpi 2>/dev/null dumpadm > $dmpi 2>/dev/null
# write an awk script that can process the output of format disks=${@:-$(echo "" | format -e 2>/dev/null | awk '
# to produce a list of disks we know about. Note that we have BEGIN { FS="."; }
# to escape "$2" so that the shell doesn't interpret it while
# we're creating the awk script.
# -------------------
cat > /tmp/find_disks.awk <<EOF
#!/bin/nawk -f
BEGIN { FS="."; }
/^Specify disk/{ /^Specify disk/{
searchdisks=0; searchdisks=0;
} }
{ {
if (searchdisks && \$2 !~ "^$"){ if (searchdisks && $2 !~ "^$"){
split(\$2,arr," "); split($2,arr," ");
print arr[1]; print arr[1];
} }
} }
/^AVAILABLE DISK SELECTIONS:/{ /^AVAILABLE DISK SELECTIONS:/{
searchdisks=1; searchdisks=1;
} }
EOF ')}
#---------------------
chmod 755 /tmp/find_disks.awk
disks=${@:-$(echo "" | format -e 2>/dev/null | /tmp/find_disks.awk)}
rm /tmp/find_disks.awk
unused="" unused=""
for disk in $disks; do for disk in $disks; do
@ -2801,23 +2739,21 @@ function safe_to_destroy_pool { # $1 the pool name
# this is a list of the top-level directories in each of the # this is a list of the top-level directories in each of the
# files that make up the path to the files the pool is based on # files that make up the path to the files the pool is based on
FILEPOOL=$(zpool status -v $pool | grep /$1/ | \ FILEPOOL=$(zpool status -v $pool | awk -v pool="/$1/" '$0 ~ pool {print $1}')
awk '{print $1}')
# this is a list of the zvols that make up the pool # this is a list of the zvols that make up the pool
ZVOLPOOL=$(zpool status -v $pool | grep "$ZVOL_DEVDIR/$1$" \ ZVOLPOOL=$(zpool status -v $pool | awk -v zvols="$ZVOL_DEVDIR/$1$" '$0 ~ zvols {print $1}')
| awk '{print $1}')
# also want to determine if it's a file-based pool using an # also want to determine if it's a file-based pool using an
# alternate mountpoint... # alternate mountpoint...
POOL_FILE_DIRS=$(zpool status -v $pool | \ POOL_FILE_DIRS=$(zpool status -v $pool | \
grep / | awk '{print $1}' | \ awk '/\// {print $1}' | \
awk -F/ '{print $2}' | grep -v "dev") awk -F/ '!/dev/ {print $2}')
for pooldir in $POOL_FILE_DIRS for pooldir in $POOL_FILE_DIRS
do do
OUTPUT=$(zfs list -H -r -o mountpoint $1 | \ OUTPUT=$(zfs list -H -r -o mountpoint $1 | \
grep "${pooldir}$" | awk '{print $1}') awk -v pd="${pooldir}$" '$0 ~ pd {print $1}')
ALTMOUNTPOOL="${ALTMOUNTPOOL}${OUTPUT}" ALTMOUNTPOOL="${ALTMOUNTPOOL}${OUTPUT}"
done done
@ -2935,21 +2871,11 @@ function get_config
if ! poolexists "$pool" ; then if ! poolexists "$pool" ; then
return 1 return 1
fi fi
alt_root=$(zpool list -H $pool | awk '{print $NF}') if [ "$(get_pool_prop cachefile "$pool")" = "none" ]; then
if [[ $alt_root == "-" ]]; then zdb -e $pool
value=$(zdb -C $pool | grep "$config:" | awk -F: \
'{print $2}')
else else
value=$(zdb -e $pool | grep "$config:" | awk -F: \ zdb -C $pool
'{print $2}') fi | awk -F: -v cfg="$config:" '$0 ~ cfg {sub(/^'\''/, $2); sub(/'\''$/, $2); print $2}'
fi
if [[ -n $value ]] ; then
value=${value#'}
value=${value%'}
fi
echo $value
return 0
} }
# #
@ -2967,8 +2893,7 @@ function _random_get
typeset -i ind typeset -i ind
((ind = RANDOM % cnt + 1)) ((ind = RANDOM % cnt + 1))
typeset ret=$(echo "$str" | cut -f $ind -d ' ') echo "$str" | cut -f $ind -d ' '
echo $ret
} }
# #
@ -3031,20 +2956,7 @@ function datasetcksum
typeset cksum typeset cksum
sync sync
sync_all_pools sync_all_pools
cksum=$(zdb -vvv $1 | grep "^Dataset $1 \[" | grep "cksum" \ zdb -vvv $1 | awk -F= -v ds="^Dataset $1 "'\\[' '$0 ~ ds && /cksum/ {print $7}'
| awk -F= '{print $7}')
echo $cksum
}
#
# Get cksum of file
# #1 file path
#
function checksum
{
typeset cksum
cksum=$(cksum $1 | awk '{print $1}')
echo $cksum
} }
# #
@ -3067,27 +2979,6 @@ function get_device_state #pool disk field("", "spares","logs")
echo $state echo $state
} }
#
# print the given directory filesystem type
#
# $1 directory name
#
function get_fstype
{
typeset dir=$1
if [[ -z $dir ]]; then
log_fail "Usage: get_fstype <directory>"
fi
#
# $ df -n /
# / : ufs
#
df -n $dir | awk '{print $3}'
}
# #
# Given a disk, label it to VTOC regardless what label was on the disk # Given a disk, label it to VTOC regardless what label was on the disk
# $1 disk # $1 disk
@ -3141,16 +3032,6 @@ function labelvtoc
return 0 return 0
} }
#
# check if the system was installed as zfsroot or not
# return: 0 if zfsroot, non-zero if not
#
function is_zfsroot
{
df -n / | grep zfs > /dev/null 2>&1
return $?
}
# #
# get the root filesystem name if it's zfsroot system. # get the root filesystem name if it's zfsroot system.
# #
@ -3162,7 +3043,7 @@ function get_rootfs
if is_freebsd; then if is_freebsd; then
rootfs=$(mount -p | awk '$2 == "/" && $3 == "zfs" {print $1}') rootfs=$(mount -p | awk '$2 == "/" && $3 == "zfs" {print $1}')
elif ! is_linux; then elif ! is_linux; then
rootfs=$(awk '{if ($2 == "/" && $3 == "zfs") print $1}' \ rootfs=$(awk '$2 == "/" && $3 == "zfs" {print $1}' \
/etc/mnttab) /etc/mnttab)
fi fi
if [[ -z "$rootfs" ]]; then if [[ -z "$rootfs" ]]; then
@ -3460,9 +3341,7 @@ function wait_freeing #pool
function wait_replacing #pool function wait_replacing #pool
{ {
typeset pool=${1:-$TESTPOOL} typeset pool=${1:-$TESTPOOL}
while true; do while zpool status $pool | grep -qE 'replacing-[0-9]+'; do
[[ "" == "$(zpool status $pool |
awk '/replacing-[0-9]+/ {print $1}')" ]] && break
log_must sleep 1 log_must sleep 1
done done
} }
@ -3910,7 +3789,9 @@ function md5digest
md5 -q $file md5 -q $file
;; ;;
*) *)
md5sum -b $file | awk '{ print $1 }' typeset sum _
read -r sum _ < <(md5sum -b $file)
echo $sum
;; ;;
esac esac
} }
@ -3928,7 +3809,9 @@ function sha256digest
sha256 -q $file sha256 -q $file
;; ;;
*) *)
sha256sum -b $file | awk '{ print $1 }' typeset sum _
read -r sum _ < <(sha256sum -b $file)
echo $sum
;; ;;
esac esac
} }
@ -4116,9 +3999,7 @@ function kstat # stat flags?
sysctl $flags kstat.zfs.misc.$stat sysctl $flags kstat.zfs.misc.$stat
;; ;;
Linux) Linux)
typeset zfs_kstat="/proc/spl/kstat/zfs/$stat" cat "/proc/spl/kstat/zfs/$stat" 2>/dev/null
[[ -f "$zfs_kstat" ]] || return 1
cat $zfs_kstat
;; ;;
*) *)
false false
@ -4135,7 +4016,7 @@ function get_arcstat # stat
kstat arcstats.$stat kstat arcstats.$stat
;; ;;
Linux) Linux)
kstat arcstats | awk "/$stat/ { print \$3 }" kstat arcstats | awk "/$stat/"' { print $3 }'
;; ;;
*) *)
false false

View File

@ -15,7 +15,7 @@ function test_zpool_script {
out="$($wholecmd)" out="$($wholecmd)"
# Default number of columns that get printed without -c # Default number of columns that get printed without -c
if echo "$cmd" | grep -q iostat ; then if [ "$cmd" != "${cmd/iostat/_/}" ]; then
# iostat # iostat
dcols=7 dcols=7
else else
@ -39,8 +39,8 @@ function test_zpool_script {
# zpool iostat -v output is 7 columns, so if the script ran correctly # zpool iostat -v output is 7 columns, so if the script ran correctly
# we should see more than that. # we should see more than that.
if ! newcols=$(echo "$out" | \ if ! newcols=$(echo "$out" | \
awk '/\/dev/{print NF-'$dcols'; if (NF <= '$dcols') {exit 1}}' | \ awk '/\/dev/ {print NF-'$dcols'; if (NF <= '$dcols') {exit 1}}' | \
head -n 1) ; \ head -n 1)
then then
log_fail "'$wholecmd' didn't create a new column value" log_fail "'$wholecmd' didn't create a new column value"
else else

View File

@ -185,9 +185,7 @@ function plus_sign_check_l #<obj>
return 1 return 1
fi fi
ls -ld $obj | awk '{print $1}' | grep "+$" > /dev/null ! ls -ld $obj | awk '$1 ~ /\+$/ {exit 1}'
return $?
} }
# #
@ -202,9 +200,7 @@ function plus_sign_check_v #<obj>
return 1 return 1
fi fi
ls -vd $obj | awk '(NR == 1) {print $1}' | grep "+$" > /dev/null ! ls -vd $obj | awk 'NR == 1 && $1 ~ /\+$ {exit 1}'
return $?
} }
# #
@ -216,7 +212,6 @@ function plus_sign_check_v #<obj>
function chgusr_exec #<login_name> <commands> [...] function chgusr_exec #<login_name> <commands> [...]
{ {
chg_usr_exec $@ chg_usr_exec $@
return $?
} }
# #
@ -237,7 +232,6 @@ function set_cur_usr #<login_name>
function usr_exec #<commands> [...] function usr_exec #<commands> [...]
{ {
chg_usr_exec "$ZFS_ACL_CUR_USER" $@ chg_usr_exec "$ZFS_ACL_CUR_USER" $@
return $?
} }
# #
@ -447,12 +441,10 @@ function get_group #node
fi fi
if [[ -d $node ]]; then if [[ -d $node ]]; then
value=$(ls -dl $node | awk '{print $4}') ls -dl $node
elif [[ -e $node ]]; then elif [[ -e $node ]]; then
value=$(ls -l $node | awk '{print $4}') ls -l $node
fi fi | awk '{print $4}'
echo $value
} }

View File

@ -55,12 +55,10 @@ function hasflag
typeset path=$2 typeset path=$2
if is_linux; then if is_linux; then
read_dos_attributes $path | awk \ read_dos_attributes $path
'{ gsub(",", "\n", $1); print $1 }' | grep -qxF $flag
else else
ls -lo $path | awk '{ gsub(",", "\n", $5); print $5 }' | \ ls -lo $path | awk '{ print $5 }'
grep -qxF $flag fi | grep -qwF $flag
fi
} }
log_assert "Verify DOS mode flags function correctly" log_assert "Verify DOS mode flags function correctly"

View File

@ -70,9 +70,8 @@ if [ "$?" -eq "0" ]; then
log_must chmod 700 $TESTDIR/dir.0 log_must chmod 700 $TESTDIR/dir.0
log_must setfacl -m g:$ZFS_ACL_STAFF_GROUP:rw $TESTDIR/dir.0 log_must setfacl -m g:$ZFS_ACL_STAFF_GROUP:rw $TESTDIR/dir.0
# Confirm permissions # Confirm permissions
ls -l $TESTDIR |grep "dir.0" |grep -q "drwxrw----+" if ! ls -l $TESTDIR | grep "dir.0" | grep -q "drwxrw----+"; then
if [ "$?" -ne "0" ]; then msk=$(ls -l $TESTDIR | awk '/dir.0/ {print $1}')
msk=$(ls -l $TESTDIR |grep "dir.0" | awk '{print $1}')
log_note "expected mask drwxrw----+ but found $msk" log_note "expected mask drwxrw----+ but found $msk"
log_fail "Expected permissions were not set." log_fail "Expected permissions were not set."
fi fi

View File

@ -53,9 +53,8 @@ log_must mkdir $TESTDIR/dir.0
log_must chmod 700 $TESTDIR/dir.0 log_must chmod 700 $TESTDIR/dir.0
log_must setfacl -m g:$ZFS_ACL_STAFF_GROUP:wx $TESTDIR/dir.0 log_must setfacl -m g:$ZFS_ACL_STAFF_GROUP:wx $TESTDIR/dir.0
# Confirm permissions # Confirm permissions
ls -l $TESTDIR |grep "dir.0" |grep -q "drwx-wx---+" if ! ls -l $TESTDIR | grep "dir.0" | grep -q "drwx-wx---+"; then
if [ "$?" -ne "0" ]; then msk=$(ls -l $TESTDIR | awk '/dir.0/ {print $1}')
msk=$(ls -l $TESTDIR |grep "dir.0" | awk '{print $1}')
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

View File

@ -42,7 +42,7 @@ do
log_must zpool create $TESTPOOL $type $ZPOOL_DISKS log_must zpool create $TESTPOOL $type $ZPOOL_DISKS
fi fi
ac_value="$(zpool get -H -o property,value all | \ ac_value="$(zpool get -H -o property,value all | \
egrep allocation_classes | awk '{print $2}')" awk '/allocation_classes/ {print $2}')"
if [ "$ac_value" = "enabled" ]; then if [ "$ac_value" = "enabled" ]; then
log_note "feature@allocation_classes is enabled" log_note "feature@allocation_classes is enabled"
else else
@ -57,7 +57,7 @@ do
$CLASS_DISK0 $CLASS_DISK1 $CLASS_DISK0 $CLASS_DISK1
fi fi
ac_value="$(zpool get -H -o property,value all | \ ac_value="$(zpool get -H -o property,value all | \
egrep allocation_classes | awk '{print $2}')" awk '/allocation_classes/ {print $2}')"
if [ "$ac_value" = "active" ]; then if [ "$ac_value" = "active" ]; then
log_note "feature@allocation_classes is active" log_note "feature@allocation_classes is active"
else else

View File

@ -39,7 +39,7 @@ for value in 0 512 1024 2048 4096 8192 16384 32768 65536 131072
do do
log_must zfs set special_small_blocks=$value $TESTPOOL log_must zfs set special_small_blocks=$value $TESTPOOL
ACTUAL=$(zfs get -p special_small_blocks $TESTPOOL | \ ACTUAL=$(zfs get -p special_small_blocks $TESTPOOL | \
grep special_small_blocks | awk '{print $3}') awk '/special_small_blocks/ {print $3}')
if [ "$ACTUAL" != "$value" ] if [ "$ACTUAL" != "$value" ]
then then
log_fail "v. $ACTUAL set for $TESTPOOL, expected v. $value!" log_fail "v. $ACTUAL set for $TESTPOOL, expected v. $value!"

View File

@ -56,8 +56,7 @@ function testdbufstat # stat_name dbufstat_filter
[[ -n "$2" ]] && filter="-F $2" [[ -n "$2" ]] && filter="-F $2"
if is_linux; then if is_linux; then
from_dbufstat=$(grep -w "$name" "$DBUFSTATS_FILE" | read -r _ _ from_dbufstat _ < <(grep -w "$name" "$DBUFSTATS_FILE")
awk '{ print $3 }')
else else
from_dbufstat=$(awk "/dbufstats\.$name:/ { print \$2 }" \ from_dbufstat=$(awk "/dbufstats\.$name:/ { print \$2 }" \
"$DBUFSTATS_FILE") "$DBUFSTATS_FILE")

View File

@ -74,7 +74,7 @@ do
log_must zfs create $POOL/$TESTFS log_must zfs create $POOL/$TESTFS
log_must zpool set bootfs=$POOL/$TESTFS $POOL log_must zpool set bootfs=$POOL/$TESTFS $POOL
RES=$(zpool get bootfs $POOL | tail -1 | awk '{print $3}' ) RES=$(zpool get bootfs $POOL | awk 'END {print $3}' )
if [ $RES != "$POOL/$TESTFS" ] if [ $RES != "$POOL/$TESTFS" ]
then then
log_fail "Expected $RES == $POOL/$TESTFS" log_fail "Expected $RES == $POOL/$TESTFS"

View File

@ -60,7 +60,7 @@ function verify_bootfs { # $POOL
log_must zfs create $POOL/$TESTFS log_must zfs create $POOL/$TESTFS
log_must zpool set bootfs=$POOL/$TESTFS $POOL log_must zpool set bootfs=$POOL/$TESTFS $POOL
VAL=$(zpool get bootfs $POOL | tail -1 | awk '{print $3}' ) VAL=$(zpool get bootfs $POOL | awk 'END {print $3}' )
if [ $VAL != "$POOL/$TESTFS" ] if [ $VAL != "$POOL/$TESTFS" ]
then then
log_must zpool status -v $POOL log_must zpool status -v $POOL
@ -74,7 +74,7 @@ function verify_no_bootfs { # $POOL
POOL=$1 POOL=$1
log_must zfs create $POOL/$TESTFS log_must zfs create $POOL/$TESTFS
log_mustnot zpool set bootfs=$POOL/$TESTFS $POOL log_mustnot zpool set bootfs=$POOL/$TESTFS $POOL
VAL=$(zpool get bootfs $POOL | tail -1 | awk '{print $3}' ) VAL=$(zpool get bootfs $POOL | awk 'END {print $3}' )
if [ $VAL == "$POOL/$TESTFS" ] if [ $VAL == "$POOL/$TESTFS" ]
then then
log_must zpool status -v $POOL log_must zpool status -v $POOL

View File

@ -34,15 +34,11 @@ function test_instr_limit
{ {
typeset lim=$1 typeset lim=$1
error=$(zfs program -t $lim $TESTPOOL $ZCP_ROOT/lua_core/tst.timeout.zcp 2>&1) log_mustnot eval 'error=$(zfs program -t '$lim' $TESTPOOL $ZCP_ROOT/lua_core/tst.timeout.zcp 2>&1)'
[[ $? -ne 0 ]] || log_fail "Channel program with limit $lim exited 0: $error"
instrs_run=$(echo $error | awk -F "chunk" '{print $2}' | awk '{print $1}') read -r instrs_run _ < <(echo $error | awk -F "chunk" '{print $2}')
if [[ $instrs_run -lt $(( $lim - 100 )) ]]; then log_must [ $instrs_run -ge $(( $lim - 100 )) ]
log_fail "Runtime (${instrs_run} instr) < limit (${lim} - 100 instr)" log_must [ $instrs_run -le $(( $lim + 100 )) ]
elif [[ $instrs_run -gt $(( $lim + 100 )) ]]; then
log_fail "Runtime (${instrs_run} instr) > limit (${lim} + 100 instr)"
fi
log_note "With limit $lim the program ended after $instrs_run instructions" log_note "With limit $lim the program ended after $instrs_run instructions"
} }

View File

@ -85,7 +85,7 @@ log_must zpool import $TESTPOOL
log_must zpool scrub $TESTPOOL log_must zpool scrub $TESTPOOL
log_must wait_scrubbed $TESTPOOL log_must wait_scrubbed $TESTPOOL
cksum=$(zpool status -P -v $TESTPOOL | grep "$firstvdev" | awk '{print $5}') cksum=$(zpool status -P -v $TESTPOOL | awk -v v="$firstvdev" '$0 ~ v {print $5}')
log_assert "Normal file write test saw $cksum checksum errors" log_assert "Normal file write test saw $cksum checksum errors"
log_must [ $cksum -eq 0 ] log_must [ $cksum -eq 0 ]
@ -105,8 +105,7 @@ while [[ $j -lt ${#CHECKSUM_TYPES[*]} ]]; do
log_must zpool scrub $TESTPOOL log_must zpool scrub $TESTPOOL
log_must wait_scrubbed $TESTPOOL log_must wait_scrubbed $TESTPOOL
cksum=$(zpool status -P -v $TESTPOOL | grep "$firstvdev" | \ cksum=$(zpool status -P -v $TESTPOOL | awk -v v="$firstvdev" '$0 ~ v {print $5}')
awk '{print $5}')
log_assert "Checksum '$type' caught $cksum checksum errors" log_assert "Checksum '$type' caught $cksum checksum errors"
log_must [ $cksum -ne 0 ] log_must [ $cksum -ne 0 ]

View File

@ -30,14 +30,6 @@
. $STF_SUITE/include/libtest.shlib . $STF_SUITE/include/libtest.shlib
#
# Get the checksum and size of the file.
#
function get_cksum # <file path>
{
return $(cksum $1 | awk '{print $1 $2}')
}
# #
# Compare the checksum of target files with the original file # Compare the checksum of target files with the original file
# #
@ -45,7 +37,7 @@ function get_cksum # <file path>
function compare_cksum #<orig_data> <target_data1>...<target_datan> function compare_cksum #<orig_data> <target_data1>...<target_datan>
{ {
typeset orig_data=$1 typeset orig_data=$1
typeset orig_sum=$(get_cksum $orig_data) typeset orig_sum=$(cksum < $orig_data)
typeset target_sum="" typeset target_sum=""
typeset bad_data_list="" typeset bad_data_list=""
typeset -i bad_count=0 typeset -i bad_count=0
@ -58,7 +50,7 @@ function compare_cksum #<orig_data> <target_data1>...<target_datan>
continue continue
fi fi
target_sum=$(get_cksum $data) target_sum=$(cksum < $data)
if [[ $target_sum != $orig_sum ]]; then if [[ $target_sum != $orig_sum ]]; then
bad_data_list="$bad_data_list $data" bad_data_list="$bad_data_list $data"
(( bad_count +=1 )) (( bad_count +=1 ))

View File

@ -70,12 +70,14 @@ log_must dd if=$DEV_RDSKDIR/${DISK[0]} of=$DEV_RDSKDIR/${DISK[1]} bs=1K count=25
ubs=$(zdb -lu ${DISK[1]} | grep -e LABEL -e Uberblock -e 'labels = ') ubs=$(zdb -lu ${DISK[1]} | grep -e LABEL -e Uberblock -e 'labels = ')
log_note "vdev 1: ubs $ubs" log_note "vdev 1: ubs $ubs"
set -o pipefail
ub_dump_counts=$(zdb -lu ${DISK[1]} | \ ub_dump_counts=$(zdb -lu ${DISK[1]} | \
awk ' /LABEL/ {label=$NF; blocks[label]=0}; awk ' /LABEL/ {label=$NF; blocks[label]=0};
/Uberblock/ {blocks[label]++}; /Uberblock/ {blocks[label]++};
END {print blocks[0],blocks[1],blocks[2],blocks[3]}') END {print blocks[0],blocks[1],blocks[2],blocks[3]}') ||
(( $? != 0)) && log_fail "failed to get ub_dump_counts from DISK[1]" log_fail "failed to get ub_dump_counts from DISK[1]"
log_note "vdev 1: ub_dump_counts $ub_dump_counts" log_note "vdev 1: ub_dump_counts $ub_dump_counts"
set +o pipefail
set -A dump_count $ub_dump_counts set -A dump_count $ub_dump_counts
for label in 0 1 2 3; do for label in 0 1 2 3; do

View File

@ -73,7 +73,7 @@ obj=${array[0]}
log_note "file $init_data has object number $obj" log_note "file $init_data has object number $obj"
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"
@ -81,15 +81,13 @@ log_note "block 0 of $init_data has a DVA of $dva"
size_str=$(sed -Ene 's/^.+ size=([^ ]+) .*$/\1/p' <<< "$output") size_str=$(sed -Ene 's/^.+ size=([^ ]+) .*$/\1/p' <<< "$output")
log_note "block size $size_str" log_note "block size $size_str"
vdev=$(echo "$dva" |awk '{split($0,array,":")} END{print array[1]}') vdev=$(echo "$dva" | cut -d: -f1)
offset=$(echo "$dva" |awk '{split($0,array,":")} END{print array[2]}') offset=$(echo "$dva" | cut -d: -f2)
output=$(zdb -R $TESTPOOL $vdev:$offset:$size_str:d 2> /dev/null) output=$(zdb -R $TESTPOOL $vdev:$offset:$size_str:d 2> /dev/null)
echo $output |grep $pattern > /dev/null echo $output | grep -q $pattern || log_fail "zdb -R :d failed to decompress the data properly"
(( $? != 0 )) && log_fail "zdb -R :d failed to decompress the data properly"
output=$(zdb -R $TESTPOOL $vdev:$offset:$size_str:dr 2> /dev/null) output=$(zdb -R $TESTPOOL $vdev:$offset:$size_str:dr 2> /dev/null)
echo $output |grep $four_k > /dev/null echo $output | grep -q $four_k || log_fail "zdb -R :dr failed to decompress the data properly"
(( $? != 0 )) && log_fail "zdb -R :dr failed to decompress the data properly"
output=$(zdb -R $TESTPOOL $vdev:$offset:$size_str:dr 2> /dev/null) output=$(zdb -R $TESTPOOL $vdev:$offset:$size_str:dr 2> /dev/null)
result=${#output} result=${#output}
@ -97,8 +95,8 @@ result=${#output}
"zdb -R failed to decompress the data to the length (${#output} != $size_str)" "zdb -R failed to decompress the data to the length (${#output} != $size_str)"
# decompress using lsize # decompress using lsize
lsize=$(echo $size_str |awk '{split($0,array,"/")} END{print array[1]}') lsize=$(echo $size_str | cut -d/ -f1)
psize=$(echo $size_str |awk '{split($0,array,"/")} END{print array[2]}') psize=$(echo $size_str | cut -d/ -f2)
output=$(zdb -R $TESTPOOL $vdev:$offset:$lsize:dr 2> /dev/null) output=$(zdb -R $TESTPOOL $vdev:$offset:$lsize:dr 2> /dev/null)
result=${#output} result=${#output}
(( $result != $blksize)) && log_fail \ (( $result != $blksize)) && log_fail \

View File

@ -76,11 +76,11 @@ 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 |awk '{split($0,array,"/")} END{print array[1]}') lsize=$(echo $size_str | cut -d/ -f 1)
lsize_orig=$lsize lsize_orig=$lsize
lsize=${lsize%?} lsize=${lsize%?}
lsize_bytes=$((16#$lsize)) lsize_bytes=$((16#$lsize))
psize=$(echo $size_str |awk '{split($0,array,"/")} END{print array[2]}') psize=$(echo $size_str | cut -d/ -f 2)
psize_orig=$psize psize_orig=$psize
psize=${psize%?} psize=${psize%?}
psize_bytes=$((16#$psize)) psize_bytes=$((16#$psize))
@ -88,21 +88,21 @@ 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") zstd_str=$(sed -Ene 's/^.+ ZSTD:size=([^:]+):version=([^:]+):level=([^:]+):.*$/\1:\2:\3/p' <<< "$output")
zstd_size=$(echo "$zstd_str" |awk '{split($0,array,":")} END{print array[1]}') 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" |awk '{split($0,array,":")} END{print array[2]}') 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" |awk '{split($0,array,":")} END{print array[3]}') 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" |awk '{split($0,array,":")} END{print array[1]}') vdev=$(echo "$dva" | cut -d: -f 1)
offset=$(echo "$dva" |awk '{split($0,array,":")} END{print array[2]}') 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") outsize=$(wc -c <<< "$output")

View File

@ -106,8 +106,8 @@ if [ "$output" != "$blk_out1" ]; then
log_fail "zdb -R :b80d (block 1 display/decompress) failed" log_fail "zdb -R :b80d (block 1 display/decompress) failed"
fi fi
vdev=$(echo "$dva" |awk '{split($0,array,":")} END{print array[1]}') vdev=$(echo "$dva" | cut -d: -f1)
offset=$(echo "$dva" |awk '{split($0,array,":")} END{print array[2]}') offset=$(echo "$dva" | cut -d: -f2)
output=$(export ZDB_NO_ZLE=\"true\";\ output=$(export ZDB_NO_ZLE=\"true\";\
zdb -R $TESTPOOL $vdev:$offset:$l1_read_size:id 2> /dev/null) zdb -R $TESTPOOL $vdev:$offset:$l1_read_size:id 2> /dev/null)
block_cnt=$(echo "$output" | grep 'L0' | wc -l) block_cnt=$(echo "$output" | grep 'L0' | wc -l)

View File

@ -65,7 +65,7 @@ done
# Specifying a non-existent object identifier returns an error # Specifying a non-existent object identifier returns an error
obj_id_highest=$(zdb -P -dd $TESTPOOL/$TESTFS 2>/dev/null | obj_id_highest=$(zdb -P -dd $TESTPOOL/$TESTFS 2>/dev/null |
egrep "^ +-?([0-9]+ +){7}" | sort -n | tail -n 1 | awk '{print $1}') egrep "^ +-?([0-9]+ +){7}" | sort -n | awk 'END {print $1}')
obj_id_invalid=$(( $obj_id_highest + 1 )) obj_id_invalid=$(( $obj_id_highest + 1 ))
log_mustnot zdb -dd $TESTPOOL/$TESTFS $obj_id_invalid log_mustnot zdb -dd $TESTPOOL/$TESTFS $obj_id_invalid

View File

@ -42,8 +42,8 @@ function get_object_list_range
begin=$2 begin=$2
end=$3 end=$3
get_object_list $dataset | get_object_list $dataset |
while read line; do while read -r line; do
obj=$(echo $line | awk '{print $1}') read -r obj _ <<<"$line"
if [[ $obj -ge $begin && $obj -le $end ]] ; then if [[ $obj -ge $begin && $obj -le $end ]] ; then
echo "$line" echo "$line"
elif [[ $obj -gt $end ]] ; then elif [[ $obj -gt $end ]] ; then
@ -142,7 +142,7 @@ log_must test "\n$actual\n" == "\n$expected\n"
# Specifying individual object IDs works # Specifying individual object IDs works
objects="$start1 $end1 $start2 $end2" objects="$start1 $end1 $start2 $end2"
expected="$objects" expected="$objects"
actual=$(get_object_list $TESTPOOL/$TESTFS $objects | awk '{print $1}' | tr '\n' ' ') actual=$(get_object_list $TESTPOOL/$TESTFS $objects | awk '{printf("%s ", $1)}' | tr '\n' ' ')
log_must test "${actual% }" == "$expected" log_must test "${actual% }" == "$expected"
# Get all objects in the meta-objset to test m (spacemap) and z (zap) flags # Get all objects in the meta-objset to test m (spacemap) and z (zap) flags

View File

@ -68,8 +68,7 @@ log_note "file $init_data has object number $obj"
sync_pool $TESTPOOL sync_pool $TESTPOOL
output=$(zdb -d $TESTPOOL/$TESTFS) output=$(zdb -d $TESTPOOL/$TESTFS)
objset_id=$(echo $output | awk '{split($0,array,",")} END{print array[2]}' | objset_id=$(echo $output | cut -d, -f2 | cut -d' ' -f2)
awk '{split($0,array," ")} END{print array[2]}')
objset_hex=$(printf "0x%X" $objset_id) objset_hex=$(printf "0x%X" $objset_id)
log_note "objset $TESTPOOL/$TESTFS has objset ID $objset_id ($objset_hex)" log_note "objset $TESTPOOL/$TESTFS has objset ID $objset_id ($objset_hex)"
@ -77,54 +76,33 @@ for id in "$objset_id" "$objset_hex"
do do
log_note "zdb -dddddd $TESTPOOL/$id $obj" log_note "zdb -dddddd $TESTPOOL/$id $obj"
output=$(zdb -dddddd $TESTPOOL/$id $obj) output=$(zdb -dddddd $TESTPOOL/$id $obj)
reason="($TESTPOOL/$TESTFS not in zdb output)" echo $output | grep -q "$TESTPOOL/$TESTFS" ||
echo $output |grep "$TESTPOOL/$TESTFS" > /dev/null log_fail "zdb -dddddd $TESTPOOL/$id $obj failed ($TESTPOOL/$TESTFS not in zdb output)"
(( $? != 0 )) && log_fail \ echo $output | grep -q "file1" ||
"zdb -dddddd $TESTPOOL/$id $obj failed $reason" log_fail "zdb -dddddd $TESTPOOL/$id $obj failed (file1 not in zdb output)"
reason="(file1 not in zdb output)"
echo $output |grep "file1" > /dev/null
(( $? != 0 )) && log_fail \
"zdb -dddddd $TESTPOOL/$id $obj failed $reason"
obj=$(printf "0x%X" $obj)
obj=$(printf "0x%X" $obj)
log_note "zdb -NNNNNN $TESTPOOL/$id $obj" log_note "zdb -NNNNNN $TESTPOOL/$id $obj"
output=$(zdb -NNNNNN $TESTPOOL/$id $obj) output=$(zdb -NNNNNN $TESTPOOL/$id $obj)
reason="($TESTPOOL/$TESTFS not in zdb output)" echo $output | grep -q "$TESTPOOL/$TESTFS" ||
echo $output |grep "$TESTPOOL/$TESTFS" > /dev/null log_fail "zdb -NNNNNN $TESTPOOL/$id $obj failed ($TESTPOOL/$TESTFS not in zdb output)"
(( $? != 0 )) && log_fail \ echo $output | grep -q "file1" ||
"zdb -NNNNNN $TESTPOOL/$id $obj failed $reason" log_fail "zdb -NNNNNN $TESTPOOL/$id $obj failed (file1 not in zdb output)"
reason="(file1 not in zdb output)"
echo $output |grep "file1" > /dev/null
(( $? != 0 )) && log_fail \
"zdb -NNNNNN $TESTPOOL/$id $obj failed $reason"
done done
if is_linux; then if is_linux; then
output=$(ls -1 /proc/spl/kstat/zfs/$TESTPOOL |grep objset- |tail -1) output=$(ls -1 /proc/spl/kstat/zfs/$TESTPOOL |grep objset- |tail -1)
objset_hex=${output#*-} objset_hex=${output#*-}
name_from_proc=$(cat /proc/spl/kstat/zfs/$TESTPOOL/$output | name_from_proc=$(cat /proc/spl/kstat/zfs/$TESTPOOL/$output |
grep dataset_name | awk '{split($0,array," ")} END{print array[3]}') grep dataset_name | cut -d' ' -f3)
log_note "checking zdb output for $name_from_proc" log_note "checking zdb output for $name_from_proc"
reason="(name $name_from_proc from proc not in zdb output)" log_must eval "zdb -dddddd $TESTPOOL/$objset_hex | grep -q \"$name_from_proc\""
log_note "zdb -dddddd $TESTPOOL/$objset_hex"
output=$(zdb -dddddd $TESTPOOL/$objset_hex)
echo $output |grep "$name_from_proc" > /dev/null
(( $? != 0 )) && log_fail \
"zdb -dddddd $TESTPOOL/$objset_hex failed $reason"
fi fi
log_must zfs create $hex_ds log_must zfs create $hex_ds
log_must zfs create $num_ds log_must zfs create $num_ds
output=$(zdb -d $hex_ds) log_must eval "zdb -d $hex_ds | grep -q \"$hex_ds\""
reason="($TESTPOOL/0x400 not in zdb output)" log_must eval "zdb -d $num_ds | grep -q \"$num_ds\""
echo $output |grep "$hex_ds" > /dev/null
(( $? != 0 )) && log_fail \
"zdb -d $hex_ds failed $reason"
output=$(zdb -d $num_ds)
reason="($num_ds not in zdb output)"
echo $output |grep "$num_ds" > /dev/null
(( $? != 0 )) && log_fail \
"zdb -d $num_ds failed $reason"
# force numeric interpretation, expect fail # force numeric interpretation, expect fail
log_mustnot zdb -N $hex_ds log_mustnot zdb -N $hex_ds

View File

@ -40,8 +40,7 @@
# 2. Verify it succeed while upgrade, but fails while the version downgraded. # 2. Verify it succeed while upgrade, but fails while the version downgraded.
# #
ZFS_VERSION=$(zfs upgrade | head -1 | awk '{print $NF}' \ ZFS_VERSION=$(zfs upgrade | grep -wom1 '[[:digit:]]*')
| sed -e 's/\.//g')
verify_runnable "both" verify_runnable "both"

View File

@ -221,7 +221,7 @@ for (( i = 1; i <= (ZFS_MAXPROPLEN / 200 + 1); i++ )); do
log_must zfs clone ${fs}@snap ${fs}/${TESTCLONE}${xs}.${i} log_must zfs clone ${fs}@snap ${fs}/${TESTCLONE}${xs}.${i}
done done
clone_list=$(zfs list -o clones $fs@snap) clone_list=$(zfs list -o clones $fs@snap)
char_count=$(echo "$clone_list" | tail -1 | wc | awk '{print $3}') char_count=$(echo "$clone_list" | tail -1 | wc -c)
[[ $char_count -eq $ZFS_MAXPROPLEN ]] || \ [[ $char_count -eq $ZFS_MAXPROPLEN ]] || \
log_fail "Clone list not truncated correctly. Unexpected character count" \ log_fail "Clone list not truncated correctly. Unexpected character count" \
"$char_count" "$char_count"

View File

@ -94,11 +94,9 @@ done
log_note "Verify df(1) can correctly display the space charged." log_note "Verify df(1) can correctly display the space charged."
for val in 1 2 3; do for val in 1 2 3; do
if is_freebsd; then if is_freebsd; then
used=`df -m /$TESTPOOL/fs_$val | grep $TESTPOOL/fs_$val \ used=`df -m /$TESTPOOL/fs_$val | awk -v pa=$TESTPOOL/fs_$val -v fs=fs_$val '$0 ~ pa && $4 ~ fs {print $3}'`
| awk -v fs=fs_$val '$4 ~ fs {print $3}'`
else else
used=`df -F zfs -k /$TESTPOOL/fs_$val/$FILE | grep $TESTPOOL/fs_$val \ used=`df -F zfs -k /$TESTPOOL/fs_$val/$FILE | awk -v pa=$TESTPOOL/fs_$val '$0 ~ pa {print $3}'`
| awk '{print $3}'`
(( used = used * 1024 )) # kb -> bytes (( used = used * 1024 )) # kb -> bytes
fi fi
check_used $used $val check_used $used $val

View File

@ -62,8 +62,7 @@ function cleanup
# check to see if there is any new fs created during the test # check to see if there is any new fs created during the test
# if so destroy it. # if so destroy it.
# #
for dset in $(zfs list -H | \ for dset in $(zfs list -H | awk '$1 ~ /\/ {print $1}'); do
awk '{print $1}' | grep / ); do
found=false found=false
i=0 i=0
while (( $i < ${#existed_fs[*]} )); do while (( $i < ${#existed_fs[*]} )); do
@ -99,7 +98,7 @@ log_assert "Verify 'zfs create <filesystem>' fails with bad <filesystem> argumen
datasetexists $TESTPOOL/$TESTFS || \ datasetexists $TESTPOOL/$TESTFS || \
log_must zfs create $TESTPOOL/$TESTFS log_must zfs create $TESTPOOL/$TESTFS
set -A existed_fs $(zfs list -H | awk '{print $1}' | grep / ) set -A existed_fs $(zfs list -H | awk '$1 ~ /\// {print $1}')
log_mustnot zfs create $TESTPOOL log_mustnot zfs create $TESTPOOL
log_mustnot zfs create $TESTPOOL/$TESTFS log_mustnot zfs create $TESTPOOL/$TESTFS

View File

@ -62,8 +62,7 @@ function cleanup
# check to see if there is any new fs created during the test # check to see if there is any new fs created during the test
# if so destroy it. # if so destroy it.
# #
for dset in $(zfs list -H | \ for dset in $(zfs list -H | awk '$1 ~ /\// {print $1}'); do
awk '{print $1}' | grep / ); do
found=false found=false
i=0 i=0
while (( $i < ${#existed_fs[*]} )); do while (( $i < ${#existed_fs[*]} )); do
@ -108,7 +107,7 @@ set -A options "" "-s"
datasetexists $TESTPOOL/$TESTVOL || \ datasetexists $TESTPOOL/$TESTVOL || \
log_must zfs create -V $VOLSIZE $TESTPOOL/$TESTVOL log_must zfs create -V $VOLSIZE $TESTPOOL/$TESTVOL
set -A existed_fs $(zfs list -H | awk '{print $1}' | grep / ) set -A existed_fs $(zfs list -H | awk '$1 ~ /\// {print $1}')
log_mustnot zfs create -V $VOLSIZE $TESTPOOL/$TESTVOL log_mustnot zfs create -V $VOLSIZE $TESTPOOL/$TESTVOL
log_mustnot zfs create -s -V $VOLSIZE $TESTPOOL/$TESTVOL log_mustnot zfs create -s -V $VOLSIZE $TESTPOOL/$TESTVOL

View File

@ -41,8 +41,7 @@
# 2. Verify only the leaf filesystem to be version=1, others use the current version # 2. Verify only the leaf filesystem to be version=1, others use the current version
# #
ZFS_VERSION=$(zfs upgrade | head -1 | awk '{print $NF}' \ ZFS_VERSION=$(zfs upgrade | grep -wom1 '[[:digit:]]*')
| sed -e 's/\.//g')
verify_runnable "both" verify_runnable "both"

View File

@ -40,15 +40,12 @@ function propertycheck
{ {
typeset dtst=$1 typeset dtst=$1
typeset propstr=$2 typeset propstr=$2
typeset prop expect_value
typeset prop=$(echo $propstr | awk -F= '{print $1}') IFS='=' read -r prop expect_value <<<"$propstr"
typeset expect_value=$(echo $propstr | awk -F= '{print $2}')
typeset value=$(zfs get -H -p -o value $prop $dtst) typeset value=$(get_prop $prop $dtst)
if [[ "$expect_value" == "$value" ]]; then [ "$expect_value" = "$value" ]
return 0
else
return 1
fi
} }

View File

@ -98,8 +98,7 @@ log_must zfs set mountpoint=$mntp1 $fs1
log_must zfs set mountpoint=$mntp2 $clone log_must zfs set mountpoint=$mntp2 $clone
for arg in "$fs1 $mntp1" "$clone $mntp2"; do for arg in "$fs1 $mntp1" "$clone $mntp2"; do
fs=`echo $arg | awk '{print $1}'` read -r fs mntp <<<"$arg"
mntp=`echo $arg | awk '{print $2}'`
log_note "Verify that 'zfs destroy' fails to" \ log_note "Verify that 'zfs destroy' fails to" \
"destroy filesystem when it is busy." "destroy filesystem when it is busy."

View File

@ -47,7 +47,7 @@ function verify_object_change # <path> <change>
change="$2" change="$2"
log_must eval "zfs diff -F $TESTSNAP1 $TESTSNAP2 > $FILEDIFF" log_must eval "zfs diff -F $TESTSNAP1 $TESTSNAP2 > $FILEDIFF"
diffchg="$(awk -v path="$path" '$NF == path { print $1 }' < $FILEDIFF)" diffchg="$(awk -v path="$path" '$NF == path { print $1 }' $FILEDIFF)"
if [[ "$diffchg" != "$change" ]]; then if [[ "$diffchg" != "$change" ]]; then
log_fail "Unexpected change for $path ('$diffchg' != '$change')" log_fail "Unexpected change for $path ('$diffchg' != '$change')"
else else

View File

@ -73,10 +73,8 @@ log_must zfs snapshot "$TESTSNAP2"
# 3. Verify 'zfs diff -t' correctly display timestamps # 3. Verify 'zfs diff -t' correctly display timestamps
typeset -i count=0 typeset -i count=0
log_must eval "zfs diff -t $TESTSNAP1 $TESTSNAP2 > $FILEDIFF" log_must eval "zfs diff -t $TESTSNAP1 $TESTSNAP2 > $FILEDIFF"
awk '{print substr($1,1,index($1,".")-1)" "$NF}' < "$FILEDIFF" | while read line awk '{print substr($1,1,index($1,".")-1) " " $NF}' "$FILEDIFF" | while read -r ctime file
do do
read ctime file <<< "$line"
# If path from 'zfs diff' is not a file (could be xattr object) skip it # If path from 'zfs diff' is not a file (could be xattr object) skip it
if [[ ! -f "$file" ]]; then if [[ ! -f "$file" ]]; then
continue; continue;

View File

@ -52,7 +52,7 @@ function verify_object_class # <path> <symbol>
symbol="$2" symbol="$2"
log_must eval "zfs diff -F $TESTSNAP1 $TESTSNAP2 > $FILEDIFF" log_must eval "zfs diff -F $TESTSNAP1 $TESTSNAP2 > $FILEDIFF"
diffsym="$(awk -v path="$path" '$NF == path { print $2 }' < $FILEDIFF)" diffsym="$(awk -v path="$path" '$NF == path { print $2 }' $FILEDIFF)"
if [[ "$diffsym" != "$symbol" ]]; then if [[ "$diffsym" != "$symbol" ]]; then
log_fail "Unexpected type for $path ('$diffsym' != '$symbol')" log_fail "Unexpected type for $path ('$diffsym' != '$symbol')"
else else

View File

@ -102,16 +102,15 @@ function check_return_value
found=0 found=0
while read line; do while read line; do
typeset item typeset item value _
typeset value
item=$(echo $line | awk '{print $2}' 2>&1) read -r _ item _ <<<"$line"
if [[ $item == $p ]]; then if [[ $item == $p ]]; then
((found += 1)) ((found += 1))
cols=$(echo $line | awk '{print NF}') cols=$(echo $line | awk '{print NF}')
fi fi
value=$(echo $line | awk '{print $3}' 2>&1) read -r _ _ value _ <<<"$line"
if [[ $value == $uint64_max ]]; then if [[ $value == $uint64_max ]]; then
log_fail "'zfs get $opt $props $dst' return " \ log_fail "'zfs get $opt $props $dst' return " \
"UINT64_MAX constant." "UINT64_MAX constant."

View File

@ -55,9 +55,8 @@ log_onexit cleanup
log_must zfs set atime=on $TESTPOOL/$TESTFS log_must zfs set atime=on $TESTPOOL/$TESTFS
log_must zfs mount -o remount,noatime $TESTPOOL/$TESTFS log_must zfs mount -o remount,noatime $TESTPOOL/$TESTFS
value1=$(zfs get -H atime $TESTPOOL/$TESTFS | awk '{print $3}') read -r _ _ value1 _ < <(zfs get -H atime $TESTPOOL/$TESTFS)
value2=$(zfs get -H all $TESTPOOL/$TESTFS | awk '{print $2 " " $3}' | \ read -r _ value2 < <(zfs get -H all $TESTPOOL/$TESTFS | cut -f2,3 | grep ^atime)
grep ^atime | awk '{print $2}')
if [[ $value1 != $value2 ]]; then if [[ $value1 != $value2 ]]; then
log_fail "value1($value1) != value2($value2)" log_fail "value1($value1) != value2($value2)"
fi fi

View File

@ -163,15 +163,12 @@ while (( i < ${#opts[*]} )); do
log_must eval "zfs get ${opts[i]} all >$propfile" log_must eval "zfs get ${opts[i]} all >$propfile"
for ds in $allds; do for ds in $allds; do
grep $ds $propfile >/dev/null 2>&1 grep -q $ds $propfile || \
(( $? != 0 )) && \
log_fail "There is no property for" \ log_fail "There is no property for" \
"dataset $ds in 'get all' output." "dataset $ds in 'get all' output."
propnum=`cat $propfile | awk '{print $1}' | \ propnum=$(awk -v ds="${ds}$" '$1 ~ ds {print $1}' $propfile | wc -l)
grep "${ds}$" | wc -l` case $(zfs get -H -o value type $ds) in
ds_type=`zfs get -H -o value type $ds`
case $ds_type in
filesystem ) filesystem )
(( propnum < fspropnum )) && \ (( propnum < fspropnum )) && \
(( failflag += 1 )) (( failflag += 1 ))

View File

@ -70,7 +70,8 @@ log_must key_available $TESTPOOL/$TESTFS1
log_mustnot eval "echo $PASSPHRASE | zfs load-key $TESTPOOL/$TESTFS1" log_mustnot eval "echo $PASSPHRASE | zfs load-key $TESTPOOL/$TESTFS1"
typeset DISK2="$(echo $DISKS | awk '{ print $2 }')" typeset DISK2 _
read -r _ DISK2 _ <<<"$DISKS"
log_must eval "echo $PASSPHRASE | zpool create -O encryption=on" \ log_must eval "echo $PASSPHRASE | zpool create -O encryption=on" \
"-O keyformat=passphrase -O keylocation=prompt $TESTPOOL1 $DISK2" "-O keyformat=passphrase -O keylocation=prompt $TESTPOOL1 $DISK2"

View File

@ -56,7 +56,8 @@ log_must zfs create -o encryption=on -o keyformat=passphrase \
log_must zfs create -V 64M -o encryption=on -o keyformat=passphrase \ log_must zfs create -V 64M -o encryption=on -o keyformat=passphrase \
-o keylocation=file:///$TESTPOOL/pkey $TESTPOOL/zvol -o keylocation=file:///$TESTPOOL/pkey $TESTPOOL/zvol
typeset DISK2="$(echo $DISKS | awk '{ print $2}')" typeset DISK2 _
read -r _ DISK2 _ <<<"$DISKS"
log_must zpool create -O encryption=on -O keyformat=passphrase \ log_must zpool create -O encryption=on -O keyformat=passphrase \
-O keylocation=file:///$TESTPOOL/pkey $TESTPOOL1 $DISK2 -O keylocation=file:///$TESTPOOL/pkey $TESTPOOL1 $DISK2

View File

@ -35,10 +35,7 @@ function force_unmount #dev
{ {
typeset dev=$1 typeset dev=$1
ismounted $dev ismounted $dev && log_must zfs $unmountforce $dev
if (( $? == 0 )); then
log_must zfs $unmountforce $dev
fi
return 0 return 0
} }

View File

@ -112,7 +112,7 @@ function get_reverse_option
typeset val typeset val
typeset -i ind=0 typeset -i ind=0
val=$(get_prop $prop $fs) || log_fail "get_prop $prop $fs" val=$(get_prop $prop $fs)
if [[ $val == "on" ]]; then if [[ $val == "on" ]]; then
(( ind = i * 2 )) (( ind = i * 2 ))
else else
@ -127,7 +127,6 @@ cleanup
for property in ${properties[@]}; do for property in ${properties[@]}; do
orig_val=$(get_prop $property $fs) orig_val=$(get_prop $property $fs)
(($? != 0)) && log_fail "get_prop $property $fs"
# Set filesystem property temporarily # Set filesystem property temporarily
reverse_opt=$(get_reverse_option $fs $property) reverse_opt=$(get_reverse_option $fs $property)
@ -135,7 +134,6 @@ for property in ${properties[@]}; do
log_must zfs mount -o $reverse_opt $fs log_must zfs mount -o $reverse_opt $fs
cur_val=$(get_prop $property $fs) cur_val=$(get_prop $property $fs)
(($? != 0)) && log_fail "get_prop $property $fs"
# In LZ, a user with all zone privileges can never with "devices" # In LZ, a user with all zone privileges can never with "devices"
if ! is_global_zone && [[ $property == devices ]] ; then if ! is_global_zone && [[ $property == devices ]] ; then
@ -153,7 +151,6 @@ for property in ${properties[@]}; do
log_must zfs mount $fs log_must zfs mount $fs
cur_val=$(get_prop $property $fs) cur_val=$(get_prop $property $fs)
(($? != 0)) && log_fail "get_prop $property $fs"
if [[ $orig_val != $cur_val ]]; then if [[ $orig_val != $cur_val ]]; then
log_fail "zfs mount -o $reverse_opt " \ log_fail "zfs mount -o $reverse_opt " \
"change the property that is stored on disks" "change the property that is stored on disks"

View File

@ -217,12 +217,11 @@ for ds in $datasets; do
sync_pool sync_pool
done done
recursive_output=$(zfs get -p -r written@current $TESTPOOL | \ recursive_output=$(zfs get -p -r written@current $TESTPOOL | \
grep -v $TESTFS1@ | grep -v $TESTFS2@ | grep -v $TESTFS3@ | \ grep -ve $TESTFS1@ -e $TESTFS2@ -e $TESTFS3@ -e "VALUE" | grep -v "-")
grep -v "VALUE" | grep -v "-")
expected="$((20 * mb_block))" expected="$((20 * mb_block))"
for ds in $datasets; do for ds in $datasets; do
writtenat=$(echo "$recursive_output" | grep -v $ds/) writtenat=$(echo "$recursive_output" | grep -v $ds/)
writtenat=$(echo "$writtenat" | grep $ds | awk '{print $3}') writtenat=$(echo "$writtenat" | awk -v ds="$ds" '$0 ~ ds {print $3}')
within_percent $writtenat $expected 99.5 || \ within_percent $writtenat $expected 99.5 || \
log_fail "Unexpected written@ value on $ds" log_fail "Unexpected written@ value on $ds"
done done

View File

@ -62,7 +62,7 @@ log_onexit cleanup
ibackup=$TEST_BASE_DIR/ibackup.$$ ibackup=$TEST_BASE_DIR/ibackup.$$
fs=$TESTPOOL/$TESTFS; snap1=$fs@snap1; snap2=$fs@snap2 fs=$TESTPOOL/$TESTFS; snap1=$fs@snap1; snap2=$fs@snap2
mntpnt=$(get_prop mountpoint $fs) || log_fail "get_prop mountpoint $fs" mntpnt=$(get_prop mountpoint $fs)
log_must mkfile 10m $mntpnt/file1 log_must mkfile 10m $mntpnt/file1
log_must zfs snapshot $snap1 log_must zfs snapshot $snap1
log_must mkfile 10m $mntpnt/file2 log_must mkfile 10m $mntpnt/file2

View File

@ -82,7 +82,7 @@ datasetexists $ancestor_fs || \
log_must zfs create $ancestor_fs log_must zfs create $ancestor_fs
log_must zfs create $fs log_must zfs create $fs
mntpnt=$(get_prop mountpoint $fs) || log_fail "get_prop mountpoint $fs" mntpnt=$(get_prop mountpoint $fs)
log_must mkfile 10m $mntpnt/file1 log_must mkfile 10m $mntpnt/file1
log_must zfs snapshot $snap1 log_must zfs snapshot $snap1
log_must mkfile 10m $mntpnt/file2 log_must mkfile 10m $mntpnt/file2

View File

@ -64,7 +64,7 @@ ibackup=$TEST_BASE_DIR/ibackup.$$
datasetexists $fs || log_must zfs create $fs datasetexists $fs || log_must zfs create $fs
mntpnt=$(get_prop mountpoint $fs) || log_fail "get_prop mountpoint $fs" mntpnt=$(get_prop mountpoint $fs)
log_must mkfile 10m $mntpnt/file1 log_must mkfile 10m $mntpnt/file1
log_must zfs snapshot $snap1 log_must zfs snapshot $snap1
log_must mkfile 10m $mntpnt/file2 log_must mkfile 10m $mntpnt/file2

View File

@ -86,9 +86,6 @@ for orig_fs in $datasets ; do
typeset mntpnt typeset mntpnt
mntpnt=$(get_prop mountpoint $orig_fs) mntpnt=$(get_prop mountpoint $orig_fs)
if [[ $? -ne 0 ]] ; then
log_fail "get_prop mountpoint $orig_fs failed"
fi
typeset mnt_file=$mntpnt/file1 typeset mnt_file=$mntpnt/file1

View File

@ -52,7 +52,7 @@ log_onexit cleanup
truncate -s 100M $tpoolfile truncate -s 100M $tpoolfile
log_must zpool create $temppool $tpoolfile log_must zpool create $temppool $tpoolfile
log_must zfs create $src_fs log_must zfs create $src_fs
src_mnt=$(get_prop mountpoint $src_fs) || log_fail "get_prop mountpoint $src_fs" src_mnt=$(get_prop mountpoint $src_fs)
echo blah > $src_mnt/blah echo blah > $src_mnt/blah
zfs snapshot $src_fs@base zfs snapshot $src_fs@base

View File

@ -58,27 +58,22 @@ log_note "Randomly selected ZSTD level: $random_level"
log_must zfs create -o compress=zstd-$random_level $TESTPOOL/$TESTFS1 log_must zfs create -o compress=zstd-$random_level $TESTPOOL/$TESTFS1
# Make a 5kb compressible file # Make a 5kb compressible file
log_must cat $src_data $src_data $src_data $src_data $src_data \ log_must eval cat $src_data $src_data $src_data $src_data $src_data \
> /$TESTPOOL/$TESTFS1/$TESTFILE0 "> /$TESTPOOL/$TESTFS1/$TESTFILE0"
typeset checksum=$(md5digest /$TESTPOOL/$TESTFS1/$TESTFILE0) typeset checksum=$(md5digest /$TESTPOOL/$TESTFS1/$TESTFILE0)
log_must zfs snapshot $snap log_must zfs snapshot $snap
# get object number of file # get object number of file
listing=$(ls -i /$TESTPOOL/$TESTFS1/$TESTFILE0) read -r obj _ < <(ls -i /$TESTPOOL/$TESTFS1/$TESTFILE0)
set -A array $listing
obj=${array[0]}
log_note "file /$TESTPOOL/$TESTFS1/$TESTFILE0 has object number $obj" log_note "file /$TESTPOOL/$TESTFS1/$TESTFILE0 has object number $obj"
output=$(zdb -Zddddddbbbbbb $TESTPOOL/$TESTFS1 $obj 2> /dev/null \ output=$(zdb -Zddddddbbbbbb $TESTPOOL/$TESTFS1 $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 /$TESTPOOL/$TESTFS1/$TESTFILE0 has a DVA of $dva" log_note "block 0 of /$TESTPOOL/$TESTFS1/$TESTFILE0 has a DVA of $dva"
zstd_str=$(sed -Ene 's/^.+ ZSTD:size=([^:]+):version=([^:]+):level=([^:]+):.*$/\1:\2:\3/p' <<< "$output") read -r zstd_size1 zstd_version1 zstd_level1 < <(sed -Ene 's/^.+ ZSTD:size=([^:]+):version=([^:]+):level=([^:]+):.*$/\1 \2 \3/p' <<< "$output")
zstd_size1=$(echo "$zstd_str" |awk '{split($0,array,":")} END{print array[1]}')
zstd_version1=$(echo "$zstd_str" |awk '{split($0,array,":")} END{print array[2]}')
zstd_level1=$(echo "$zstd_str" |awk '{split($0,array,":")} END{print array[3]}')
log_note "ZSTD src: size=$zstd_size1 version=$zstd_version1 level=$zstd_level1" log_note "ZSTD src: size=$zstd_size1 version=$zstd_version1 level=$zstd_level1"
log_note "Verify ZFS can receive the ZSTD compressed stream" log_note "Verify ZFS can receive the ZSTD compressed stream"
@ -89,23 +84,18 @@ typeset cksum1=$(md5digest /$TESTPOOL/$TESTFS2/$TESTFILE0)
log_fail "Checksums differ ($cksum1 != $checksum)" log_fail "Checksums differ ($cksum1 != $checksum)"
# get object number of file # get object number of file
listing=$(ls -i /$TESTPOOL/$TESTFS2/$TESTFILE0) read -r obj _ < <(ls -i /$TESTPOOL/$TESTFS2/$TESTFILE0)
set -A array $listing
obj=${array[0]}
log_note "file /$TESTPOOL/$TESTFS2/$TESTFILE0 has object number $obj" log_note "file /$TESTPOOL/$TESTFS2/$TESTFILE0 has object number $obj"
output=$(zdb -Zddddddbbbbbb $TESTPOOL/$TESTFS2 $obj 2> /dev/null \ output=$(zdb -Zddddddbbbbbb $TESTPOOL/$TESTFS2 $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 /$TESTPOOL/$TESTFS2/$TESTFILE0 has a DVA of $dva" log_note "block 0 of /$TESTPOOL/$TESTFS2/$TESTFILE0 has a DVA of $dva"
zstd_str=$(sed -Ene 's/^.+ ZSTD:size=([^:]+):version=([^:]+):level=([^:]+):.*$/\1:\2:\3/p' <<< "$output") read -r zstd_size2 zstd_version2 zstd_level2 < <(sed -Ene 's/^.+ ZSTD:size=([^:]+):version=([^:]+):level=([^:]+):.*$/\1 \2 \3/p' <<< "$output")
zstd_size2=$(echo "$zstd_str" |awk '{split($0,array,":")} END{print array[1]}') log_note "ZSTD dest: size=$zstd_size2 version=$zstd_version2 level=$zstd_level2"
(( $zstd_size2 != $zstd_size1 )) && log_fail \ (( $zstd_size2 != $zstd_size1 )) && log_fail \
"ZFS recv failed: compressed size differs ($zstd_size2 != $zstd_size1)" "ZFS recv failed: compressed size differs ($zstd_size2 != $zstd_size1)"
zstd_version2=$(echo "$zstd_str" |awk '{split($0,array,":")} END{print array[2]}')
zstd_level2=$(echo "$zstd_str" |awk '{split($0,array,":")} END{print array[3]}')
log_note "ZSTD dest: size=$zstd_size2 version=$zstd_version2 level=$zstd_level2"
(( $zstd_level2 != $zstd_level1 )) && log_fail \ (( $zstd_level2 != $zstd_level1 )) && log_fail \
"ZFS recv failed: compression level did not match header level ($zstd_level2 != $zstd_level1)" "ZFS recv failed: compression level did not match header level ($zstd_level2 != $zstd_level1)"

View File

@ -39,7 +39,7 @@ function rename_cleanup
zfs destroy -fR $TESTPOOL/renamed zfs destroy -fR $TESTPOOL/renamed
} }
back=$(pwd) back=$PWD
log_onexit rename_cleanup log_onexit rename_cleanup
log_must zfs create $TESTPOOL/rename_test log_must zfs create $TESTPOOL/rename_test
@ -72,14 +72,15 @@ log_must zfs list $TESTPOOL/renamed
log_must zfs list $TESTPOOL/renamed/child log_must zfs list $TESTPOOL/renamed/child
log_must zfs list $TESTPOOL/renamed/child/grandchild log_must zfs list $TESTPOOL/renamed/child/grandchild
missing=$(zfs mount | awk -v pat=$TESTPOOL/renamed '$1 ~ pat' | awk \ missing=$(zfs mount | awk \
-v genpat=$TESTPOOL/renamed \
-v mntp_p=$mntp_p \ -v mntp_p=$mntp_p \
-v mntp_c=$mntp_c \ -v mntp_c=$mntp_c \
-v mntp_g=$mntp_g ' -v mntp_g=$mntp_g '
BEGIN { p = c = g = 0 } BEGIN { p = c = g = 0 }
$2 == mntp_p { p = 1 } $1 ~ genpat && $2 == mntp_p { p = 1 }
$2 == mntp_c { c = 1 } $1 ~ genpat && $2 == mntp_c { c = 1 }
$2 == mntp_g { g = 1 } $1 ~ genpat && $2 == mntp_g { g = 1 }
END { END {
if (p != 1) if (p != 1)
print mntp_p print mntp_p

View File

@ -52,7 +52,7 @@ streamfile=$(mktemp $TESTDIR/file.XXXXXX)
vdev=$(mktemp $TEST_BASE_DIR/file.XXXXXX) vdev=$(mktemp $TEST_BASE_DIR/file.XXXXXX)
test_pool () function test_pool
{ {
POOL=$1 POOL=$1
log_must zfs create -o recordsize=512 $POOL/fs log_must zfs create -o recordsize=512 $POOL/fs
@ -67,10 +67,7 @@ test_pool ()
sync_all_pools sync_all_pools
# check if we started reusing objects # check if we started reusing objects
object=$(ls -i $mntpnt | sort -n | awk -v object=$object \ object=$(ls -i $mntpnt | sort -n | awk -v object=$object \
'{if ($1 <= object) {exit 1}} END {print $1}') '{if ($1 <= object) {exit 1}} END {print $1}') || break
if [[ $? -ne 0 ]]; then
break
fi
done done
dd if=/dev/urandom of=${mntpnt}/$FILE bs=512 count=1 seek=1 2>/dev/null dd if=/dev/urandom of=${mntpnt}/$FILE bs=512 count=1 seek=1 2>/dev/null

View File

@ -81,14 +81,8 @@ function cleanup
log_assert "Setting a valid property of canmount to file system, it must be successful." log_assert "Setting a valid property of canmount to file system, it must be successful."
log_onexit cleanup log_onexit cleanup
typeset old_fs_canmount="" old_ctr_canmount="" typeset old_fs_canmount=$(get_prop canmount $TESTPOOL/$TESTFS)
typeset old_ctr_canmount=$(get_prop canmount $TESTPOOL/$TESTCTR)
old_fs_canmount=$(get_prop canmount $TESTPOOL/$TESTFS)
[[ $? != 0 ]] && \
log_fail "Get the $TESTPOOL/$TESTFS canmount error."
old_ctr_canmount=$(get_prop canmount $TESTPOOL/$TESTCTR)
[[ $? != 0 ]] && \
log_fail "Get the $TESTPOOL/$TESTCTR canmount error."
log_must zfs snapshot $TESTPOOL/$TESTFS@$TESTSNAP log_must zfs snapshot $TESTPOOL/$TESTFS@$TESTSNAP
log_must zfs snapshot $TESTPOOL/$TESTVOL@$TESTSNAP log_must zfs snapshot $TESTPOOL/$TESTVOL@$TESTSNAP

View File

@ -69,11 +69,7 @@ log_assert "Setting a valid mountpoint to file system, it must be successful."
log_onexit cleanup log_onexit cleanup
old_fs_mpt=$(get_prop mountpoint $TESTPOOL/$TESTFS) old_fs_mpt=$(get_prop mountpoint $TESTPOOL/$TESTFS)
[[ $? != 0 ]] && \
log_fail "Get the $TESTPOOL/$TESTFS mountpoint error."
old_ctr_mpt=$(get_prop mountpoint $TESTPOOL/$TESTCTR) old_ctr_mpt=$(get_prop mountpoint $TESTPOOL/$TESTCTR)
[[ $? != 0 ]] && \
log_fail "Get the $TESTPOOL/$TESTCTR mountpoint error."
if [[ ! -d $TESTDIR2 ]]; then if [[ ! -d $TESTDIR2 ]]; then
log_must mkdir $TESTDIR2 log_must mkdir $TESTDIR2

View File

@ -66,11 +66,7 @@ log_assert "Setting a valid mountpoint for an unmounted file system, \
log_onexit cleanup log_onexit cleanup
old_fs_mpt=$(get_prop mountpoint $TESTPOOL/$TESTFS) old_fs_mpt=$(get_prop mountpoint $TESTPOOL/$TESTFS)
[[ $? != 0 ]] && \
log_fail "Unable to get the mountpoint property for $TESTPOOL/$TESTFS"
old_ctr_mpt=$(get_prop mountpoint $TESTPOOL/$TESTCTR) old_ctr_mpt=$(get_prop mountpoint $TESTPOOL/$TESTCTR)
[[ $? != 0 ]] && \
log_fail "Unable to get the mountpoint property for $TESTPOOL/$TESTCTR"
if [[ ! -d $TESTDIR2 ]]; then if [[ ! -d $TESTDIR2 ]]; then
log_must mkdir $TESTDIR2 log_must mkdir $TESTDIR2

View File

@ -109,10 +109,8 @@ while ((i < ${#args[@]})); do
msg=$(mount | grep "$tmpmnt ") msg=$(mount | grep "$tmpmnt ")
echo $msg | grep "${args[((i))]}" > /dev/null 2>&1 if ! echo $msg | grep -q "${args[((i))]}"; then
if (($? != 0)) ; then if echo $msg | grep -q "${args[((i-1))]}"; then
echo $msg | grep "${args[((i-1))]}" > /dev/null 2>&1
if (($? == 0)) ; then
log_fail "Expected option: ${args[((i))]} \n" \ log_fail "Expected option: ${args[((i))]} \n" \
"Real option: $msg" "Real option: $msg"
fi fi
@ -130,8 +128,7 @@ while ((i < ${#args[@]})); do
args[((i+1))]="/nodevices/" args[((i+1))]="/nodevices/"
fi fi
echo $msg | grep "${args[((i+1))]}" > /dev/null 2>&1 if ! echo $msg | grep -q "${args[((i+1))]}"; then
if (($? != 0)) ; then
log_fail "Expected option: ${args[((i+1))]} \n" \ log_fail "Expected option: ${args[((i+1))]} \n" \
"Real option: $msg" "Real option: $msg"
fi fi

View File

@ -84,7 +84,7 @@ while (( i < ${#invalid_args[*]} )); do
((i = i + 1)) ((i = i + 1))
done done
log_note "verify multiple snapshot transaction group" log_note "verify multiple snapshot transaction group"
txg_group=$(zdb -Pd $TESTPOOL | grep snap | awk '{print $7}') txg_group=$(zdb -Pd $TESTPOOL | awk '/snap/ {print $7}')
for i in 1 2 3; do for i in 1 2 3; do
txg_tag=$(echo "$txg_group" | nawk -v j=$i 'FNR == j {print}') txg_tag=$(echo "$txg_group" | nawk -v j=$i 'FNR == j {print}')
[[ $txg_tag != $(echo "$txg_group" | \ [[ $txg_tag != $(echo "$txg_group" | \

View File

@ -54,7 +54,8 @@ log_must zfs create $TESTPOOL/$TESTFS1/child
log_must zfs create -V 64M -o encryption=on -o keyformat=passphrase \ log_must zfs create -V 64M -o encryption=on -o keyformat=passphrase \
-o keylocation=file:///$TESTPOOL/pkey $TESTPOOL/zvol -o keylocation=file:///$TESTPOOL/pkey $TESTPOOL/zvol
typeset DISK2="$(echo $DISKS | awk '{ print $2}')" typeset DISK2 _
read -r _ DISK2 _ <<<"$DISKS"
log_must zpool create -O encryption=on -O keyformat=passphrase \ log_must zpool create -O encryption=on -O keyformat=passphrase \
-O keylocation=file:///$TESTPOOL/pkey $TESTPOOL1 $DISK2 -O keylocation=file:///$TESTPOOL/pkey $TESTPOOL1 $DISK2

View File

@ -56,7 +56,6 @@ log_onexit cleanup
# Call cleanup to make sure the file system are mounted. # Call cleanup to make sure the file system are mounted.
cleanup cleanup
mntpnt=$(get_prop mountpoint $TESTPOOL/$TESTFS) mntpnt=$(get_prop mountpoint $TESTPOOL/$TESTFS)
(($? != 0)) && log_fail "get_prop mountpoint $TESTPOOL/$TESTFS"
typeset -i i=0 typeset -i i=0
while (( i < 10000 )); do while (( i < 10000 )); do

View File

@ -72,7 +72,7 @@ typeset expect_str3="The following filesystems are out of date, and can be upgra
typeset -i COUNT OLDCOUNT typeset -i COUNT OLDCOUNT
zfs upgrade | nawk '$1 ~ "^[0-9]+$" {print $2}'> $oldoutput zfs upgrade | nawk '$1 ~ "^[0-9]+$" {print $2}'> $oldoutput
OLDCOUNT=$( wc -l $oldoutput | awk '{print $1}' ) OLDCOUNT=$(wc -l < $oldoutput)
old_datasets="" old_datasets=""
for version in $ZFS_ALL_VERSIONS ; do for version in $ZFS_ALL_VERSIONS ; do
@ -100,7 +100,7 @@ log_must eval 'zfs upgrade > $output 2>&1'
# of the current ZFS version. # of the current ZFS version.
log_must eval 'grep "${expect_str1} $ZFS_VERSION" $output > /dev/null 2>&1' log_must eval 'grep "${expect_str1} $ZFS_VERSION" $output > /dev/null 2>&1'
zfs upgrade | nawk '$1 ~ "^[0-9]+$" {print $2}'> $output zfs upgrade | nawk '$1 ~ "^[0-9]+$" {print $2}'> $output
COUNT=$( wc -l $output | awk '{print $1}' ) COUNT=$(wc -l < $output)
typeset -i i=0 typeset -i i=0
for fs in ${old_datasets}; do for fs in ${old_datasets}; do
@ -125,7 +125,7 @@ else
log_must eval 'grep "${expect_str3}" $output > /dev/null 2>&1' log_must eval 'grep "${expect_str3}" $output > /dev/null 2>&1'
fi fi
zfs upgrade | nawk '$1 ~ "^[0-9]+$" {print $2}'> $output zfs upgrade | nawk '$1 ~ "^[0-9]+$" {print $2}'> $output
COUNT=$( wc -l $output | awk '{print $1}' ) COUNT=$(wc -l < $output)
if (( COUNT != OLDCOUNT )); then if (( COUNT != OLDCOUNT )); then
cat $output cat $output

View File

@ -39,8 +39,7 @@ log_onexit cleanup
log_assert "Test colorized zpool status output" log_assert "Test colorized zpool status output"
DISK2="$(echo $DISKS | cut -d' ' -f2)" read -r _ DISK2 DISK3 _ <<<"$DISKS"
DISK3="$(echo $DISKS | cut -d' ' -f3)"
log_must dd if=/dev/urandom of=/$TESTDIR/testfile bs=10M count=1 log_must dd if=/dev/urandom of=/$TESTDIR/testfile bs=10M count=1
@ -62,16 +61,15 @@ log_note "$(faketty TERM=xterm-256color ZFS_COLOR=1 zpool status)"
# Replace the escape codes with "ESC" so they're easier to grep # Replace the escape codes with "ESC" so they're easier to grep
out="$(faketty TERM=xterm-256color ZFS_COLOR=1 zpool status | \ out="$(faketty TERM=xterm-256color ZFS_COLOR=1 zpool status | \
grep -E 'pool:|DEGRADED' | \ sed -E '/pool:|DEGRADED/!d;s/[[:space:]]+//g;'$(printf 's/\033/ESC/g'))"
sed -r 's/[[:space:]]+//g;'$(echo -e 's/\033/ESC/g'))"
log_note "$(echo $out)" log_note "$(echo $out)"
log_note "Look for 'pool:' in bold" log_note "Look for 'pool:' in bold"
log_must eval "echo \"$out\" | grep -q 'ESC\[1mpool:ESC\[0m' " log_must grep -q 'ESC\[1mpool:ESC\[0m' <<<"$out"
log_note "Look for 'DEGRADED' in yellow" log_note "Look for 'DEGRADED' in yellow"
log_must eval "echo \"$out\" | grep -q 'ESC\[0;33mDEGRADEDESC\[0m'" log_must grep -q 'ESC\[0;33mDEGRADEDESC\[0m' <<<"$out"
# #
# The escape code for 'FAULTED' is a little more tricky. The line starts like # The escape code for 'FAULTED' is a little more tricky. The line starts like
@ -83,9 +81,11 @@ log_must eval "echo \"$out\" | grep -q 'ESC\[0;33mDEGRADEDESC\[0m'"
# we can easily remove the vdev field to get what we want. # we can easily remove the vdev field to get what we want.
# #
out="$(faketty TERM=xterm-256color ZFS_COLOR=1 zpool status \ out="$(faketty TERM=xterm-256color ZFS_COLOR=1 zpool status \
| awk '/FAULTED/{print $1$3$4}' | sed -r $(echo -e 's/\033/ESC/g'))" | awk '/FAULTED/ {print $1$3$4}' | sed -E $(printf 's/\033/ESC/g'))"
log_note "$(echo $out)"
log_note "Look for 'FAULTED' in red" log_note "Look for 'FAULTED' in red"
log_must eval "echo \"$out\" | grep -q 'ESC\[0;31mFAULTEDESC\[0m'" log_must grep -q 'ESC\[0;31mFAULTEDESC\[0m' <<<"$out"
log_pass "zpool status displayed colors" log_pass "zpool status displayed colors"

View File

@ -90,10 +90,8 @@ do
log_must wait_vdev_state $TESTPOOL $REPLACE_DEV "ONLINE" 60 log_must wait_vdev_state $TESTPOOL $REPLACE_DEV "ONLINE" 60
zpool status | awk -v poolname="$TESTPOOL" -v type="$type" 'BEGIN {s=""} zpool status | awk -v poolname="$TESTPOOL" -v type="$type" 'BEGIN {s=""}
$1 ~ poolname {c=4}; (c && c--) { s=s$1":" } $1 ~ poolname {c=4}; (c && c--) { s=s$1":" }
END { if (s != poolname":"type"-0:spare-0:replacing-0:") exit 1; }' END { if (s != poolname":"type"-0:spare-0:replacing-0:") exit 1; }' ||
if [[ $? -ne 0 ]]; then
log_fail "Pool does not contain nested replacing/spare vdevs" log_fail "Pool does not contain nested replacing/spare vdevs"
fi
# 3. Verify 'zpool add' is able to add new devices # 3. Verify 'zpool add' is able to add new devices
log_must zpool add $TESTPOOL spare $SPARE_DEV2 log_must zpool add $TESTPOOL spare $SPARE_DEV2

View File

@ -50,9 +50,8 @@ function find_vfstab_dev
# #
function find_mnttab_dev function find_mnttab_dev
{ {
typeset mnttabdev typeset mnttabdev _
typeset mnttabdevs="" typeset mnttabdevs=""
typeset line
if is_freebsd; then if is_freebsd; then
# FreeBSD doesn't have a mnttab file. # FreeBSD doesn't have a mnttab file.
@ -61,21 +60,16 @@ function find_mnttab_dev
return 0 return 0
elif is_linux; then elif is_linux; then
typeset mnttab="/etc/mtab" typeset mnttab="/etc/mtab"
typeset tmpfile="$TEST_BASE_DIR/mtab.tmp"
else else
typeset mnttab="/etc/mnttab" typeset mnttab="/etc/mnttab"
typeset tmpfile="$TEST_BASE_DIR/mnttab.tmp"
fi fi
cat $mnttab | grep "^${DEV_DSKDIR}" >$tmpfile while read -r mnttabdev _
while read -r line
do do
mnttabdev=`echo "$line" | awk '{print $1}'`
mnttabdev=${mnttabdev%%:} mnttabdev=${mnttabdev%%:}
mnttabdevs="$mnttabdev $mnttabdevs" mnttabdevs="$mnttabdev $mnttabdevs"
done <$tmpfile done < <(grep "^${DEV_DSKDIR}" $mnttab)
rm -f $tmpfile
echo $mnttabdevs echo $mnttabdevs
} }

View File

@ -90,8 +90,8 @@ done
log_must zpool add -f $TESTPOOL $config log_must zpool add -f $TESTPOOL $config
zpool status $TESTPOOL | awk 'NR == 1, /NAME/ { next } /^$/ {exit} zpool status $TESTPOOL | awk 'NR == 1, /NAME/ { next } /^$/ {exit}
{print $1}' > "$TMPFILE_PREFIX-vdevtree" {print $1}' > "$TMPFILE_PREFIX-vdevtree"
cat "$TMPFILE_PREFIX-dryrun" | awk 'NR == 1, /would/ {next} awk 'NR == 1, /would/ {next}
/^$/ {next} {print $1}' > "$TMPFILE_PREFIX-vdevtree-n" /^$/ {next} {print $1}' "$TMPFILE_PREFIX-dryrun" > "$TMPFILE_PREFIX-vdevtree-n"
log_must eval "diff $TMPFILE_PREFIX-vdevtree-n $TMPFILE_PREFIX-vdevtree" log_must diff $TMPFILE_PREFIX-vdevtree-n $TMPFILE_PREFIX-vdevtree
log_pass "'zpool add -n <pool> <vdev> ...' executes successfully." log_pass "'zpool add -n <pool> <vdev> ...' executes successfully."

View File

@ -50,9 +50,7 @@ function cleanup
poolexists $TESTPOOL1 && \ poolexists $TESTPOOL1 && \
log_must zpool destroy -f $TESTPOOL1 log_must zpool destroy -f $TESTPOOL1
for file in `ls $TEST_BASE_DIR/file.*`; do log_must rm -f $fbase.{0..2}
log_must rm -f $file
done
} }
@ -60,14 +58,8 @@ log_assert "Verify 'zpool clear' can clear errors of a storage pool."
log_onexit cleanup log_onexit cleanup
#make raw files to create various configuration pools #make raw files to create various configuration pools
typeset -i i=0
while (( i < 3 )); do
log_must truncate -s $FILESIZE $TEST_BASE_DIR/file.$i
(( i = i + 1 ))
done
fbase=$TEST_BASE_DIR/file fbase=$TEST_BASE_DIR/file
log_must truncate -s $FILESIZE $fbase.{0..2}
set -A poolconf "mirror $fbase.0 $fbase.1 $fbase.2" \ set -A poolconf "mirror $fbase.0 $fbase.1 $fbase.2" \
"raidz1 $fbase.0 $fbase.1 $fbase.2" \ "raidz1 $fbase.0 $fbase.1 $fbase.2" \
"raidz2 $fbase.0 $fbase.1 $fbase.2" "raidz2 $fbase.0 $fbase.1 $fbase.2"
@ -75,59 +67,24 @@ set -A poolconf "mirror $fbase.0 $fbase.1 $fbase.2" \
function check_err # <pool> [<vdev>] function check_err # <pool> [<vdev>]
{ {
typeset pool=$1 typeset pool=$1
shift typeset checkvdev=$2
if (( $# > 0 )); then
typeset checkvdev=$1
else
typeset checkvdev=""
fi
typeset -i errnum=0
typeset c_read=0
typeset c_write=0
typeset c_cksum=0
typeset tmpfile=$TEST_BASE_DIR/file.$$
typeset healthstr="pool '$pool' is healthy"
typeset output="`zpool status -x $pool`"
[[ "$output" == "$healthstr" ]] && return $errnum [ "$(zpool status -x $pool)" = "pool '$pool' is healthy" ] && return
zpool status -x $pool | grep -v "^$" | grep -v "pool:" \ typeset -i skipstart=1
| grep -v "state:" | grep -v "config:" \ typeset vdev _ c_read c_write c_cksum rest
| grep -v "errors:" > $tmpfile while read -r vdev _ c_read c_write c_cksum rest; do
typeset line if [ $skipstart -ne 0 ]; then
typeset -i fetchbegin=1 [ "$vdev" = "NAME" ] && skipstart=0
while read line; do
if (( $fetchbegin != 0 )); then
echo $line | grep "NAME" >/dev/null 2>&1
(( $? == 0 )) && (( fetchbegin = 0 ))
continue continue
fi fi
if [[ -n $checkvdev ]]; then if [ -n "$checkvdev" ]; then
echo $line | grep $checkvdev >/dev/null 2>&1 [ "$vdev" = "$checkvdev" ] || continue
(( $? != 0 )) && continue
c_read=`echo $line | awk '{print $3}'`
c_write=`echo $line | awk '{print $4}'`
c_cksum=`echo $line | awk '{print $5}'`
if [ $c_read != 0 ] || [ $c_write != 0 ] || \
[ $c_cksum != 0 ]
then
(( errnum = errnum + 1 ))
fi
break
fi fi
c_read=`echo $line | awk '{print $3}'` [ $c_read$c_write$c_cksum = 000 ] || return
c_write=`echo $line | awk '{print $4}'` done < <(zpool status -x $pool | grep -ve "^$" -e "pool:" -e "state:" -e "config:" -e "errors:")
c_cksum=`echo $line | awk '{print $5}'`
if [ $c_read != 0 ] || [ $c_write != 0 ] || \
[ $c_cksum != 0 ]
then
(( errnum = errnum + 1 ))
fi
done <$tmpfile
return $errnum
} }
function do_testing #<clear type> <vdevs> function do_testing #<clear type> <vdevs>
@ -137,6 +94,7 @@ function do_testing #<clear type> <vdevs>
typeset type=$1 typeset type=$1
shift shift
typeset vdev="$@" typeset vdev="$@"
(( i = $RANDOM % 3 ))
log_must zpool create -f $TESTPOOL1 $vdev log_must zpool create -f $TESTPOOL1 $vdev
log_must zfs create $FS log_must zfs create $FS
@ -146,14 +104,13 @@ function do_testing #<clear type> <vdevs>
# #
avail=$(get_prop available $FS) avail=$(get_prop available $FS)
fill_mb=$(((avail / 1024 / 1024) * 25 / 100)) fill_mb=$(((avail / 1024 / 1024) * 25 / 100))
log_must dd if=/dev/urandom of=$file.$i bs=$BLOCKSZ count=$fill_mb log_must dd if=/dev/urandom of=$file bs=$BLOCKSZ count=$fill_mb
# #
# Make errors to the testing pool by overwrite the vdev device with # Make errors to the testing pool by overwrite the vdev device with
# dd command. We do not want to have a full overwrite. That # dd command. We do not want to have a full overwrite. That
# may cause the system panic. So, we should skip the vdev label space. # may cause the system panic. So, we should skip the vdev label space.
# #
(( i = $RANDOM % 3 ))
typeset -i wcount=0 typeset -i wcount=0
typeset -i size typeset -i size
case $FILESIZE in case $FILESIZE in
@ -173,25 +130,19 @@ function do_testing #<clear type> <vdevs>
(( wcount = FILESIZE/1024 - 512 )) (( wcount = FILESIZE/1024 - 512 ))
;; ;;
esac esac
dd if=/dev/zero of=$fbase.$i seek=512 bs=1024 count=$wcount conv=notrunc \ dd if=/dev/zero of=$fbase.$i seek=512 bs=1024 count=$wcount conv=notrunc 2>/dev/null
> /dev/null 2>&1
sync_all_pools sync_all_pools
log_must sync #ensure the vdev files are written out log_must sync #ensure the vdev files are written out
log_must zpool scrub -w $TESTPOOL1 log_must zpool scrub -w $TESTPOOL1
check_err $TESTPOOL1 && \ log_mustnot check_err $TESTPOOL1
log_fail "No error generated." typeset dev=
if [[ $type == "device" ]]; then if [ "$type" = "device" ]; then
log_must zpool clear $TESTPOOL1 $fbase.$i dev=$fbase.$i
! check_err $TESTPOOL1 $fbase.$i && \
log_fail "'zpool clear' fails to clear error for $fbase.$i device."
fi fi
if [[ $type == "pool" ]]; then log_must zpool clear $TESTPOOL1 $dev
log_must zpool clear $TESTPOOL1 log_must check_err $TESTPOOL1 $dev
! check_err $TESTPOOL1 && \
log_fail "'zpool clear' fails to clear error for pool $TESTPOOL1."
fi
log_must zpool destroy $TESTPOOL1 log_must zpool destroy $TESTPOOL1
} }

View File

@ -83,14 +83,9 @@ function find_vfstab_dev
# #
function save_dump_dev function save_dump_dev
{ {
typeset dumpdev=""
if is_illumos; then if is_illumos; then
typeset fnd="Dump device" dumpadm | grep "Dump device" | cut -f2 -d : | awk '{print $1}'
dumpdev=`dumpadm | grep "$fnd" | cut -f2 -d : | \
awk '{print $1}'`
fi fi
echo $dumpdev
} }
# #

View File

@ -90,8 +90,8 @@ do
$file.1 $file.2 $file.3 $file.4 $file.1 $file.2 $file.3 $file.4
! poolexists $TESTPOOL && \ ! poolexists $TESTPOOL && \
log_fail "Creating pool with $opt fails." log_fail "Creating pool with $opt fails."
mpt=`zfs mount | egrep "^$TESTPOOL[^/]" | awk '{print $2}'` mpt=`zfs mount | awk -v pat="^$TESTPOOL[^/]" '$0 ~ pat {print $2}'`
(( ${#mpt} == 0 )) && \ [ -z "$mpt" ] && \
log_fail "$TESTPOOL created with $opt is not mounted." log_fail "$TESTPOOL created with $opt is not mounted."
mpt_val=$(get_prop "mountpoint" $TESTPOOL) mpt_val=$(get_prop "mountpoint" $TESTPOOL)
[[ "$mpt" != "$mpt_val" ]] && \ [[ "$mpt" != "$mpt_val" ]] && \

View File

@ -51,12 +51,11 @@ function cleanup
} }
if is_freebsd; then if is_freebsd; then
typeset swap_disks=$(swapinfo -l | grep "/dev" | awk '{print $1}') typeset swap_disks=$(swapinfo -l | awk '/\/dev/ {print $1}')
elif is_linux; then elif is_linux; then
typeset swap_disks=`swapon -s | grep "/dev" | awk '{print $1}'` typeset swap_disks=$(swapon -s | awk '/\/dev/ {print $1}')
else else
typeset swap_disks=`swap -l | grep "c[0-9].*d[0-9].*s[0-9]" | \ typeset swap_disks=$(swap -l | awk '/c[0-9].*d[0-9].*s[0-9]/ {print $1}')
awk '{print $1}'`
fi fi
log_assert "'zpool create' should fail with disk slice in swap." log_assert "'zpool create' should fail with disk slice in swap."

View File

@ -67,8 +67,8 @@ function cleanup
fi fi
} }
typeset swap_disks=$(swap -l | grep -v "swapfile" | awk '{print $1}') typeset swap_disks=$(swap -l | awk '!/swapfile/ {print $1}')
typeset dump_device=$(dumpadm | grep "Dump device" | awk '{print $3}') typeset dump_device=$(dumpadm | awk '/Dump device/ {print $3}')
log_assert "'zpool create' should success with no device in swap." log_assert "'zpool create' should success with no device in swap."
log_onexit cleanup log_onexit cleanup

View File

@ -55,11 +55,9 @@ for poolprop in "${poolprops[@]}"; do
# 2. Verify the pool is created with the specified temporary name # 2. Verify the pool is created with the specified temporary name
log_must poolexists $TEMPPOOL log_must poolexists $TEMPPOOL
log_mustnot poolexists $TESTPOOL log_mustnot poolexists $TESTPOOL
propname="$(awk -F= '{print $1}' <<< $fsprop)" IFS='=' read -r propname propval <<<"$fsprop"
propval="$(awk -F= '{print $2}' <<< $fsprop)"
log_must test "$(get_prop $propname $TEMPPOOL)" == "$propval" log_must test "$(get_prop $propname $TEMPPOOL)" == "$propval"
propname="$(awk -F= '{print $1}' <<< $poolprop)" IFS='=' read -r propname propval <<<"$poolprop"
propval="$(awk -F= '{print $2}' <<< $poolprop)"
log_must test "$(get_pool_prop $propname $TEMPPOOL)" == "$propval" log_must test "$(get_pool_prop $propname $TEMPPOOL)" == "$propval"
# Cleanup # Cleanup
destroy_pool $TEMPPOOL destroy_pool $TEMPPOOL

View File

@ -80,7 +80,7 @@ function damage_and_repair
log_must zpool wait -t scrub $POOL log_must zpool wait -t scrub $POOL
log_note "pass $1 observed $($EREPORTS | grep -c checksum) checksum ereports" log_note "pass $1 observed $($EREPORTS | grep -c checksum) checksum ereports"
repaired=$(zpool status $POOL | grep "scan: scrub repaired" | awk '{print $4}') repaired=$(zpool status $POOL | awk '/scan: scrub repaired/ {print $4}')
if [ "$repaired" == "0B" ]; then if [ "$repaired" == "0B" ]; then
log_fail "INVALID TEST -- expected scrub to repair some blocks" log_fail "INVALID TEST -- expected scrub to repair some blocks"
else else
@ -90,7 +90,7 @@ function damage_and_repair
function checksum_error_count function checksum_error_count
{ {
zpool status -p $POOL | grep $VDEV1 | awk '{print $5}' zpool status -p $POOL | awk -v dev=$VDEV1 '$0 ~ dev {print $5}'
} }
assertion="Damage to recently repaired blocks should be reported/counted" assertion="Damage to recently repaired blocks should be reported/counted"

View File

@ -30,9 +30,9 @@
. $STF_SUITE/include/libtest.shlib . $STF_SUITE/include/libtest.shlib
export DISK_ARRAY_NUM=$(echo ${DISKS} | nawk '{print NF}') export DISK_ARRAY_NUM=$(echo ${DISKS} | awk '{print NF}')
export DISK1=$(echo $DISKS | awk '{print $1}') read -r DISK1 _ DISK2 _ <<<"$DISKS"
export DISK2=$(echo $DISKS | awk '{print $3}') export DISK1 DISK2
if is_linux; then if is_linux; then
set_slice_prefix set_slice_prefix

View File

@ -88,7 +88,7 @@ done
# increment the counter to include the header line # increment the counter to include the header line
i=$(( $i + 1 )) i=$(( $i + 1 ))
COUNT=$(wc $values | awk '{print $1}') COUNT=$(wc -l < $values)
if [ $i -ne $COUNT ] if [ $i -ne $COUNT ]
then then
log_fail "Found zpool features not in the zpool_get test config $i/$COUNT." log_fail "Found zpool features not in the zpool_get test config $i/$COUNT."

View File

@ -50,14 +50,9 @@ typeset -i i=0
while [[ $i -lt "${#properties[@]}" ]]; do while [[ $i -lt "${#properties[@]}" ]]; do
log_note "Checking for parsable ${properties[$i]} property" log_note "Checking for parsable ${properties[$i]} property"
log_must eval "zpool get -p ${properties[$i]} $TESTPOOL >/tmp/value.$$" log_must eval "zpool get -p ${properties[$i]} $TESTPOOL >/tmp/value.$$"
grep "${properties[$i]}" /tmp/value.$$ >/dev/null 2>&1 log_must grep -q "${properties[$i]}" /tmp/value.$$
if [[ $? -ne 0 ]]; then
log_fail "${properties[$i]} not seen in output"
fi
typeset v=$(grep "${properties[$i]}" /tmp/value.$$ | awk '{print $3}') typeset v=$(awk -v p="${properties[$i]}" '$0 ~ p {print $3}' /tmp/value.$$)
log_note "${properties[$i]} has a value of $v"
# Determine if this value is a valid number, result in return code # Determine if this value is a valid number, result in return code
log_must test -n "$v" log_must test -n "$v"

View File

@ -143,13 +143,12 @@ function verify_data_md5sums
return 1 return 1
fi fi
cat $md5file | \ while read -r digest file; do
while read digest file; do
typeset digest1=$(md5digest $file) typeset digest1=$(md5digest $file)
if [[ "$digest1" != "$digest" ]]; then if [[ "$digest1" != "$digest" ]]; then
return 1 return 1
fi fi
done done < $md5file
return 0 return 0
} }
@ -227,8 +226,7 @@ function check_pool_config
typeset actual="" typeset actual=""
typeset began=false typeset began=false
printf "$status\n" | while read line; do while read -r vdev _; do
typeset vdev=$(echo "$line" | awk '{printf $1}')
if ( ! $began ) && [[ $vdev == NAME ]]; then if ( ! $began ) && [[ $vdev == NAME ]]; then
began=true began=true
continue continue
@ -240,7 +238,7 @@ function check_pool_config
vdev=$(_translate_vdev $vdev) vdev=$(_translate_vdev $vdev)
actual="$actual $vdev" actual="$actual $vdev"
fi fi
done done <<<"$status"
expected="$poolname $expected" expected="$poolname $expected"
@ -295,8 +293,7 @@ function check_pool_healthy
return 1 return 1
fi fi
status=$(echo "$status" | grep "$pool" | grep -v "pool:" | \ status=$(echo "$status" | awk -v p="$pool" '!/pool:/ && $0 ~ p {print $2}')
awk '{print $2}')
if [[ $status != "ONLINE" ]]; then if [[ $status != "ONLINE" ]]; then
log_note "Invalid zpool status for '$pool': '$status'" \ log_note "Invalid zpool status for '$pool': '$status'" \
@ -314,9 +311,7 @@ function pool_is_replacing
{ {
typeset pool=$1 typeset pool=$1
zpool status $pool | grep "replacing" | grep "ONLINE" > /dev/null zpool status $pool | grep "replacing" | grep -q "ONLINE"
return $?
} }
function set_vdev_validate_skip function set_vdev_validate_skip

View File

@ -76,11 +76,11 @@ function cleanup_all
# #
# Try import individually if 'import -a' failed. # Try import individually if 'import -a' failed.
# #
for pool in `zpool import | grep "pool:" | awk '{print $2}'`; do for pool in $(zpool import | awk '/pool:/ {print $2}'); do
zpool import -f $pool zpool import -f $pool
done done
for pool in `zpool import -d $DEVICE_DIR | grep "pool:" | awk '{print $2}'`; do for pool in $(zpool import -d $DEVICE_DIR | awk '/pool:/ {print $2}'); do
log_must zpool import -d $DEVICE_DIR -f $pool log_must zpool import -d $DEVICE_DIR -f $pool
done done

View File

@ -65,10 +65,7 @@ log_must zpool export $TESTPOOL
metaslabs=0 metaslabs=0
bs=512 bs=512
zdb -p $TESTDIR -Pme $TESTPOOL | awk '/metaslab[ ]+[0-9]+/ { print $4, $8 }' | zdb -p $TESTDIR -Pme $TESTPOOL | awk '/metaslab[ ]+[0-9]+/ { print $4, $8 }' |
while read -r offset_size; do while read -r offset size; do
typeset offset=$(echo $offset_size | cut -d ' ' -f1)
typeset size=$(echo $offset_size | cut -d ' ' -f2)
log_note "offset: '$offset'" log_note "offset: '$offset'"
log_note "size: '$size'" log_note "size: '$size'"

View File

@ -28,8 +28,8 @@
# Copyright (c) 2012, 2016 by Delphix. All rights reserved. # Copyright (c) 2012, 2016 by Delphix. All rights reserved.
# #
export DISK1=${DISKS%% *} read -r DISK1 DISK2 _ <<<"$DISKS"
export DISK2=$(echo $DISKS | awk '{print $2}') export DISK1 DISK2
export ZFS_SCAN_VDEV_LIMIT_SLOW=$((128*1024)) export ZFS_SCAN_VDEV_LIMIT_SLOW=$((128*1024))
export ZFS_SCAN_VDEV_LIMIT_DEFAULT=$((4*1024*1024)) export ZFS_SCAN_VDEV_LIMIT_DEFAULT=$((4*1024*1024))

View File

@ -71,12 +71,11 @@ fi
# Verify we can set a combination of valid property values on the new pool # Verify we can set a combination of valid property values on the new pool
for prop in "${good_props[@]}" for prop in "${good_props[@]}"
do do
propname="$(awk -F= '{print $1}' <<< $prop)" IFS='=' read -r propname propval <<<"$prop"
propval="$(awk -F= '{print $2}' <<< $prop)"
setup_mirror setup_mirror
log_must zpool split -o $prop $TESTPOOL $TESTPOOL2 log_must zpool split -o $prop $TESTPOOL $TESTPOOL2
log_must zpool import -N -d $TEST_BASE_DIR $TESTPOOL2 log_must zpool import -N -d $TEST_BASE_DIR $TESTPOOL2
log_must test "$(get_pool_prop $propname $TESTPOOL2)" == "$propval" log_must test "$(get_pool_prop $propname $TESTPOOL2)" = "$propval"
destroy_pool $TESTPOOL destroy_pool $TESTPOOL
destroy_pool $TESTPOOL2 destroy_pool $TESTPOOL2

View File

@ -122,7 +122,7 @@ typeset altroot="$TESTDIR/altroot-$TESTPOOL2"
for config in "${goodconfs[@]}" for config in "${goodconfs[@]}"
do do
create_config="${config%% *}" create_config="${config%% *}"
add_config="$(awk '{$1= "";print $0}' <<< $config)" add_config="$(awk '{$1=""; print $0}' <<< $config)"
log_must zpool create $TESTPOOL $(pool_config $create_config) log_must zpool create $TESTPOOL $(pool_config $create_config)
for vdev in $add_config; do for vdev in $add_config; do
log_must zpool add -f $TESTPOOL $(pool_config $vdev) log_must zpool add -f $TESTPOOL $(pool_config $vdev)
@ -137,7 +137,7 @@ done
for config in "${badconfs[@]}" for config in "${badconfs[@]}"
do do
create_config="${config%% *}" create_config="${config%% *}"
add_config="$(awk '{$1= "";print $0}' <<< $config)" add_config="$(awk '{$1=""; print $0}' <<< $config)"
log_must zpool create $TESTPOOL $(pool_config $create_config) log_must zpool create $TESTPOOL $(pool_config $create_config)
for vdev in $add_config; do for vdev in $add_config; do
log_must zpool add -f $TESTPOOL $(pool_config $vdev) log_must zpool add -f $TESTPOOL $(pool_config $vdev)

View File

@ -132,8 +132,7 @@ function check_poolversion
fi fi
# check version using zpool upgrade # check version using zpool upgrade
actual=$(zpool upgrade | grep $pool$ | \ actual=$(zpool upgrade | awk -v p="$pool$" '$0 ~ p {gsub(/ /, "", $1); print $1}')
awk '{print $1}' | sed -e 's/ //g')
if [[ $actual != $vers ]] ; then if [[ $actual != $vers ]] ; then
log_fail "$pool: zpool reported version $actual, expected $vers" log_fail "$pool: zpool reported version $actual, expected $vers"
fi fi

View File

@ -55,6 +55,6 @@ TEMPFILE="$TEST_BASE_DIR/zfs_001_neg.$$.txt"
zfs > $TEMPFILE 2>&1 zfs > $TEMPFILE 2>&1
log_must grep "usage: zfs command args" "$TEMPFILE" log_must grep "usage: zfs command args" "$TEMPFILE"
log_must eval "awk '{if (length(\$0) > 80) exit 1}' < $TEMPFILE" log_must awk '{if (length($0) > 80) exit 1}' $TEMPFILE
log_pass "zfs shows a usage message when run as a user" log_pass "zfs shows a usage message when run as a user"

View File

@ -59,6 +59,6 @@ log_assert "zpool shows a usage message when run as a user"
eval "zpool > $TEMPFILE 2>&1" eval "zpool > $TEMPFILE 2>&1"
log_must grep "usage: zpool command args" "$TEMPFILE" log_must grep "usage: zpool command args" "$TEMPFILE"
log_must eval "awk '{if (length(\$0) > 80) exit 1}' < $TEMPFILE" log_must awk '{if (length($0) > 80) exit 1}' $TEMPFILE
log_pass "zpool shows a usage message when run as a user" log_pass "zpool shows a usage message when run as a user"

View File

@ -54,7 +54,7 @@ while [[ $i -lt ${#args[*]} ]]
do do
PROP=${props[$i]} PROP=${props[$i]}
EXPECTED=${prop_vals[$i]} EXPECTED=${prop_vals[$i]}
ACTUAL=$( zpool get $PROP $TESTPOOL | grep $PROP | awk '{print $1}' ) ACTUAL=$( zpool get $PROP $TESTPOOL | awk -v p=$PROP '$0 ~ p {print $1}' )
if [ "$ACTUAL" != "$EXPECTED" ] if [ "$ACTUAL" != "$EXPECTED" ]
then then
log_fail "Property $PROP value was $ACTUAL, expected $EXPECTED" log_fail "Property $PROP value was $ACTUAL, expected $EXPECTED"

View File

@ -59,7 +59,7 @@ do
log_mustnot $POOL set $PROP=$NEW $TESTPOOL log_mustnot $POOL set $PROP=$NEW $TESTPOOL
# Now verify that the above command did nothing # Now verify that the above command did nothing
ACTUAL=$( zpool get $PROP $TESTPOOL | grep $PROP | awk '{print $1}' ) ACTUAL=$( zpool get $PROP $TESTPOOL | awk -v p=$PROP '$0 ~ p {print $1}' )
if [ "$ACTUAL" != "$EXPECTED" ] if [ "$ACTUAL" != "$EXPECTED" ]
then then
log_fail "Property $PROP was set to $ACTUAL, expected $EXPECTED" log_fail "Property $PROP was set to $ACTUAL, expected $EXPECTED"

View File

@ -120,7 +120,7 @@ function verify_reverse_sort { # command list name
function is_fs_type_zfs { function is_fs_type_zfs {
typeset dirname=$1 typeset dirname=$1
typeset fs="$(df $dirname | tail -1 | awk '{print $NF}')" typeset fs="$(df $dirname | awk 'END {print $NF}')"
if is_freebsd; then if is_freebsd; then
fs_type=$(mount | awk -v fs=$fs '{if ($3 == fs) print $4}' \ fs_type=$(mount | awk -v fs=$fs '{if ($3 == fs) print $4}' \

View File

@ -60,8 +60,8 @@ log_must file_write -o $OP -f $TESTDIR/$TESTFILE1 -b $BLOCKSZ \
sleep 60 sleep 60
FILE0_BLKS=`du -k $TESTDIR/$TESTFILE0 | awk '{ print $1}'` FILE0_BLKS=`du -k $TESTDIR/$TESTFILE0 | awk '{print $1}'`
FILE1_BLKS=`du -k $TESTDIR/$TESTFILE1 | awk '{ print $1}'` FILE1_BLKS=`du -k $TESTDIR/$TESTFILE1 | awk '{print $1}'`
if [[ $FILE0_BLKS -le $FILE1_BLKS ]]; then if [[ $FILE0_BLKS -le $FILE1_BLKS ]]; then
log_fail "$TESTFILE0 is smaller than $TESTFILE1" \ log_fail "$TESTFILE0 is smaller than $TESTFILE1" \

View File

@ -65,8 +65,8 @@ log_must file_write -o $OP -f $TESTDIR1/$TESTFILE1 -b $BLOCKSZ \
sleep 60 sleep 60
FILE0_BLKS=`du -k $TESTDIR1/$TESTFILE0 | awk '{ print $1}'` FILE0_BLKS=`du -k $TESTDIR1/$TESTFILE0 | awk '{print $1}'`
FILE1_BLKS=`du -k $TESTDIR1/$TESTFILE1 | awk '{ print $1}'` FILE1_BLKS=`du -k $TESTDIR1/$TESTFILE1 | awk '{print $1}'`
if [[ $FILE0_BLKS -le $FILE1_BLKS ]]; then if [[ $FILE0_BLKS -le $FILE1_BLKS ]]; then
log_fail "$TESTFILE0 is smaller than $TESTFILE1" \ log_fail "$TESTFILE0 is smaller than $TESTFILE1" \

View File

@ -391,12 +391,11 @@ function verify_send
user_run $user eval "zfs send $snap > $bak_user" user_run $user eval "zfs send $snap > $bak_user"
log_must eval "zfs send $snap > $bak_root" log_must eval "zfs send $snap > $bak_root"
if [[ $(checksum $bak_user) == $(checksum $bak_root) ]]; then if [ "$(cksum < $bak_user)" = "$(cksum < $bak_root)" ]; then
ret=0 ret=0
fi fi
rm -rf $bak_user > /dev/null rm -rf $bak_user $bak_root
rm -rf $bak_root > /dev/null
return $ret return $ret
} }
@ -462,12 +461,11 @@ function verify_fs_receive
log_must eval "zfs receive $dtst < $bak_root" log_must eval "zfs receive $dtst < $bak_root"
log_must eval "zfs send $dtstsnap > $bak_root" log_must eval "zfs send $dtstsnap > $bak_root"
log_must_busy zfs destroy -rf $dtst log_must_busy zfs destroy -rf $dtst
if [[ $(checksum $bak_user) != $(checksum $bak_root) ]]; then if [ "$(cksum < $bak_user)" != "$(cksum < $bak_root)" ]; then
return 1 return 1
fi fi
rm -rf $bak_user > /dev/null rm -rf $bak_user $bak_root
rm -rf $bak_root > /dev/null
done done

View File

@ -33,6 +33,4 @@ VDEV4=$TEST_BASE_DIR/vdev4
export TMP_EVENTS=$TEST_BASE_DIR/tmp_events.$$ export TMP_EVENTS=$TEST_BASE_DIR/tmp_events.$$
export TMP_EVENTS_FULL=$TEST_BASE_DIR/tmp_events_full.$$ export TMP_EVENTS_FULL=$TEST_BASE_DIR/tmp_events_full.$$
export TMP_EVENT_FULL=$TEST_BASE_DIR/tmp_event_full.$$
export TMP_EVENTS_ZED=$TEST_BASE_DIR/tmp_events_zed.$$ export TMP_EVENTS_ZED=$TEST_BASE_DIR/tmp_events_zed.$$
export TMP_EVENT_ZED=$TEST_BASE_DIR/tmp_event_zed.$$

View File

@ -42,15 +42,8 @@ verify_runnable "both"
function cleanup function cleanup
{ {
if poolexists $MPOOL; then poolexists $MPOOL && log_must destroy_pool $MPOOL
destroy_pool $MPOOL log_must rm -f $VDEV1 $VDEV2 $TMP_EVENTS_ZED
fi
for file in $VDEV1 $VDEV2; do
[[ -f $file ]] && rm -f $file
done
log_must rm -f $TMP_EVENTS_ZED
log_must zed_stop log_must zed_stop
} }
@ -69,10 +62,9 @@ log_must zed_start
log_must file_wait_event $ZED_DEBUG_LOG 'sysevent\.fs\.zfs\.config_sync' 150 log_must file_wait_event $ZED_DEBUG_LOG 'sysevent\.fs\.zfs\.config_sync' 150
log_must cp $ZED_DEBUG_LOG $TMP_EVENTS_ZED log_must cp $ZED_DEBUG_LOG $TMP_EVENTS_ZED
awk -v event="sysevent.fs.zfs.pool_create" \ log_mustnot awk -v event="sysevent.fs.zfs.pool_create" -v crit="\\nZEVENT_POOL=$MPOOL" \
'BEGIN{FS="\n"; RS=""} $0 ~ event { print $0 }' \ 'BEGIN{FS="\n"; RS=""} $0 ~ event && $0 ~ crit { exit 1 }' \
$TMP_EVENTS_ZED >$TMP_EVENT_ZED $TMP_EVENTS_ZED
log_must grep -q "^ZEVENT_POOL=$MPOOL" $TMP_EVENT_ZED
# 3. Stop the ZED # 3. Stop the ZED
zed_stop zed_stop

View File

@ -94,7 +94,7 @@ function run_and_verify
pool=${pool:-$TESTPOOL} pool=${pool:-$TESTPOOL}
fullcmd="$1" fullcmd="$1"
cmd=$(echo $fullcmd | awk '{print $1}') read -r cmd _ <<<"$fullcmd"
# If we aren't running zpool or zfs, something is wrong # If we aren't running zpool or zfs, something is wrong
[[ $cmd == "zpool" || $cmd == "zfs" ]] || \ [[ $cmd == "zpool" || $cmd == "zfs" ]] || \
@ -147,23 +147,20 @@ function run_and_verify
log_must grep -q "$event" $TMP_EVENTS log_must grep -q "$event" $TMP_EVENTS
# Verify the event is in the verbose output with pool name. # Verify the event is in the verbose output with pool name.
awk -v event="$event" \ log_mustnot awk -v event="$event" -v crit="pool = \"$pool\"" \
'BEGIN{FS="\n"; RS=""} $0 ~ event { print $0 }' \ 'BEGIN{FS="\n"; RS=""} $0 ~ event && $0 ~ crit { exit 1 }' \
$TMP_EVENTS_FULL >$TMP_EVENT_FULL $TMP_EVENTS_FULL
log_must grep -q "pool = \"$pool\"" $TMP_EVENT_FULL
# all-debug.sh filters history events (seen in ZED_DEBUG_LOG) # all-debug.sh filters history events (seen in ZED_DEBUG_LOG)
if [[ "$event" == "sysevent.fs.zfs.history_event" ]]; then if [ "$event" = "sysevent.fs.zfs.history_event" ]; then
continue continue
fi fi
# Verify the event was received by the ZED and logged. # Verify the event was received by the ZED and logged.
awk -v event="$event" \ log_mustnot awk -v event="$event" -v crit="\\nZEVENT_POOL=$pool" \
'BEGIN{FS="\n"; RS=""} $0 ~ event { print $0 }' \ 'BEGIN{FS="\n"; RS=""} $0 ~ event && $0 ~ crit { exit 1 }' \
$TMP_EVENTS_ZED >$TMP_EVENT_ZED $TMP_EVENTS_ZED
log_must grep -q "^ZEVENT_POOL=$pool" $TMP_EVENT_ZED
done done
rm -f $TMP_EVENTS $TMP_EVENTS_FULL $TMP_EVENT_FULL \ rm -f $TMP_EVENTS $TMP_EVENTS_FULL $TMP_EVENTS_ZED
$TMP_EVENTS_ZED $TMP_EVENT_ZED
} }

View File

@ -96,8 +96,7 @@ do
log_must zpool create -f $TESTPOOL $conf log_must zpool create -f $TESTPOOL $conf
block_device_wait ${DEV_DSKDIR}/${removedev} block_device_wait ${DEV_DSKDIR}/${removedev}
mntpnt=$(get_prop mountpoint /$TESTPOOL) || mntpnt=$(get_prop mountpoint /$TESTPOOL)
log_fail "get_prop mountpoint /$TESTPOOL"
# 2. Simulate physical removal of one device # 2. Simulate physical removal of one device
remove_disk $removedev remove_disk $removedev
@ -128,8 +127,7 @@ do
block_device_wait ${DEV_DSKDIR}/${removedev} block_device_wait ${DEV_DSKDIR}/${removedev}
log_must zpool add $TESTPOOL spare $sparedev log_must zpool add $TESTPOOL spare $sparedev
mntpnt=$(get_prop mountpoint /$TESTPOOL) || mntpnt=$(get_prop mountpoint /$TESTPOOL)
log_fail "get_prop mountpoint /$TESTPOOL"
# 2. Simulate physical removal of one device # 2. Simulate physical removal of one device
remove_disk $removedev remove_disk $removedev
@ -161,8 +159,7 @@ do
block_device_wait ${DEV_DSKDIR}/${removedev} block_device_wait ${DEV_DSKDIR}/${removedev}
log_must zpool add $TESTPOOL spare $sparedev log_must zpool add $TESTPOOL spare $sparedev
mntpnt=$(get_prop mountpoint /$TESTPOOL) || mntpnt=$(get_prop mountpoint /$TESTPOOL)
log_fail "get_prop mountpoint /$TESTPOOL"
# 2. Fault the spare device making it unavailable # 2. Fault the spare device making it unavailable
log_must zpool offline -f $TESTPOOL $sparedev log_must zpool offline -f $TESTPOOL $sparedev

View File

@ -72,8 +72,8 @@ echo "alias scsidebug /dev/disk/by-id/$SD_DEVICE_ID" >>$VDEVID_CONF
block_device_wait block_device_wait
SD_DEVICE=$(udevadm info -q all -n $DEV_DSKDIR/$SD | \ SD_DEVICE=$(udevadm info -q all -n $DEV_DSKDIR/$SD | \
awk -F'=' '/ID_VDEV=/{print $2; exit}') awk -F'=' '/ID_VDEV=/ {print $2; exit}')
[[ -z $SD_DEVICE ]] && log_fail "vdev rule was not registered properly" [ -z $SD_DEVICE ] && log_fail "vdev rule was not registered properly"
log_must zpool events -c log_must zpool events -c
log_must zpool create -f $TESTPOOL raidz1 $SD_DEVICE $DISK1 $DISK2 $DISK3 log_must zpool create -f $TESTPOOL raidz1 $SD_DEVICE $DISK1 $DISK2 $DISK3

View File

@ -67,7 +67,7 @@ log_must mkfile 1048576 /$TESTPOOL/testfile
sync_pool $TESTPOOL sync_pool $TESTPOOL
log_must zinject -c all log_must zinject -c all
SLOW_IOS=$(zpool status -sp | grep "$DISK" | awk '{print $6}') SLOW_IOS=$(zpool status -sp | awk -v d="$DISK" '$0 ~ d {print $6}')
DELAY_EVENTS=$(zpool events | grep delay | wc -l) DELAY_EVENTS=$(zpool events | grep delay | wc -l)
if [ $SLOW_IOS -gt 0 ] && [ $DELAY_EVENTS -gt 0 ] ; then if [ $SLOW_IOS -gt 0 ] && [ $DELAY_EVENTS -gt 0 ] ; then

View File

@ -73,7 +73,7 @@ log_must zfs umount $TEST_FS
for ((i=0; i < ${#dnsizes[*]}; i++)) ; do for ((i=0; i < ${#dnsizes[*]}; i++)) ; do
dnsize=$(zdb -dddd $TEST_FS ${inodes[$i]} | dnsize=$(zdb -dddd $TEST_FS ${inodes[$i]} |
awk '/ZFS plain file/ {print $6}' | tr K k) awk '/ZFS plain file/ {gsub(/K/, "k", $6); print $6}')
if [[ "$dnsize" != "${dnsizes[$i]}" ]]; then if [[ "$dnsize" != "${dnsizes[$i]}" ]]; then
log_fail "dnode size is $dnsize (expected ${dnsizes[$i]})" log_fail "dnode size is $dnsize (expected ${dnsizes[$i]})"
fi fi

View File

@ -59,7 +59,6 @@ log_assert "Verify zpool sub-commands which modify state are logged."
log_onexit cleanup log_onexit cleanup
mntpnt=$(get_prop mountpoint $TESTPOOL) mntpnt=$(get_prop mountpoint $TESTPOOL)
(( $? != 0)) && log_fail "get_prop($TESTPOOL mountpoint)"
VDEV1=$mntpnt/vdev1; VDEV2=$mntpnt/vdev2; VDEV1=$mntpnt/vdev1; VDEV2=$mntpnt/vdev2;
VDEV3=$mntpnt/vdev3; VDEV4=$mntpnt/vdev4; VDEV3=$mntpnt/vdev3; VDEV4=$mntpnt/vdev4;

View File

@ -55,7 +55,6 @@ log_assert "zpool history limitation test."
log_onexit cleanup log_onexit cleanup
mntpnt=$(get_prop mountpoint $TESTPOOL) mntpnt=$(get_prop mountpoint $TESTPOOL)
(( $? != 0 )) && log_fail "get_prop mountpoint $TESTPOOL"
VDEV0=$mntpnt/vdev0 VDEV0=$mntpnt/vdev0
log_must mkfile $MINVDEVSIZE $VDEV0 log_must mkfile $MINVDEVSIZE $VDEV0
@ -79,16 +78,16 @@ done
TMPFILE=$TEST_BASE_DIR/spool.$$ TMPFILE=$TEST_BASE_DIR/spool.$$
zpool history $spool >$TMPFILE zpool history $spool >$TMPFILE
typeset -i entry_count=$(wc -l $TMPFILE | awk '{print $1}') typeset -i entry_count=$(wc -l < $TMPFILE)
typeset final_md5=$(head -2 $TMPFILE | md5digest) typeset final_md5=$(head -2 $TMPFILE | md5digest)
grep 'zpool create' $TMPFILE >/dev/null 2>&1 || grep -q 'zpool create' $TMPFILE ||
log_fail "'zpool create' was not found in pool history" log_fail "'zpool create' was not found in pool history"
grep 'zfs create' $TMPFILE >/dev/null 2>&1 && grep -q 'zfs create' $TMPFILE &&
log_fail "'zfs create' was found in pool history" log_fail "'zfs create' was found in pool history"
grep 'zfs set compress' $TMPFILE >/dev/null 2>&1 || grep -q 'zfs set compress' $TMPFILE ||
log_fail "'zfs set compress' was found in pool history" log_fail "'zfs set compress' was found in pool history"
# Verify that the creation of the pool was preserved in the history. # Verify that the creation of the pool was preserved in the history.

View File

@ -46,7 +46,7 @@ verify_runnable "global"
log_assert "'zpool history' can cope with simultaneous commands." log_assert "'zpool history' can cope with simultaneous commands."
typeset -i orig_count=$(zpool history $spool | wc -l | awk '{print $1}') typeset -i orig_count=$(zpool history $spool | wc -l)
typeset -i i=0 typeset -i i=0
while ((i < 10)); do while ((i < 10)); do
@ -90,7 +90,7 @@ while ((i < 10)); do
((i += 1)) ((i += 1))
done done
typeset -i entry_count=$(zpool history $spool | wc -l | awk '{print $1}') typeset -i entry_count=$(zpool history $spool | wc -l)
if ((entry_count - orig_count != 200)); then if ((entry_count - orig_count != 200)); then
log_fail "The entries count error: entry_count=$entry_count " \ log_fail "The entries count error: entry_count=$entry_count " \

View File

@ -52,14 +52,12 @@ function run_and_verify
flags="$2" flags="$2"
if is_illumos; then if is_illumos; then
histcmd=$(echo $fullcmd | sed 's/\/usr\/sbin\///g') histcmd=$(echo $fullcmd | sed 's=/usr/sbin/==g')
else else
histcmd=$(echo $fullcmd | sed 's/^.*\/\(zpool .*\).*$/\1/') histcmd=$(echo $fullcmd | sed -E 's=^.*/(zpool|zfs)$=\1=')
histcmd=$(echo $histcmd | sed 's/^.*\/\(zfs .*\).*$/\1/')
fi fi
cmd=$(echo $histcmd | awk '{print $1}') read -r cmd subcmd _ <<<"$histcmd"
subcmd=$(echo $histcmd | awk '{print $2}')
# If we aren't running zpool or zfs, something is wrong # If we aren't running zpool or zfs, something is wrong
[[ $cmd == "zpool" || $cmd == "zfs" ]] || \ [[ $cmd == "zpool" || $cmd == "zfs" ]] || \
@ -77,11 +75,10 @@ function run_and_verify
log_must_busy user_run $user "$fullcmd" log_must_busy user_run $user "$fullcmd"
fi fi
zpool history $flags $pool > $TMP_HISTORY 2>/dev/null zpool history $flags $pool > $TMP_HISTORY 2>/dev/null
diff $OLD_HISTORY $TMP_HISTORY | grep "^> " | sed 's/^> //g' \ diff $OLD_HISTORY $TMP_HISTORY | sed -n 's/^> //gp' > $NEW_HISTORY
> $NEW_HISTORY
# Verify what's common to every case, regardless of zpool history flags. # Verify what's common to every case, regardless of zpool history flags.
grep "$histcmd" $NEW_HISTORY >/dev/null 2>&1 || \ grep -q "$histcmd" $NEW_HISTORY || \
log_fail "Didn't find \"$histcmd\" in pool history" log_fail "Didn't find \"$histcmd\" in pool history"
# If 'zpool history' was called without any flags, then we're done. # If 'zpool history' was called without any flags, then we're done.
@ -116,8 +113,7 @@ function verify_long
suffix=":freebsd" suffix=":freebsd"
fi fi
grep -q "$cmd \[user $uid ($user) on $hname$suffix\]" $NEW_HISTORY if grep -q "$cmd \[user $uid ($user) on $hname$suffix\]" $NEW_HISTORY; then
if [[ $? != 0 ]]; 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
@ -133,7 +129,8 @@ function verify_hold
[[ $flags =~ "i" ]] || return 1 [[ $flags =~ "i" ]] || return 1
typeset tag=$(echo $cmd | awk '{print $4}') typeset tag _
read -r _ _ _ tag _ <<<"$cmd"
typeset fullname=${cmd##* } typeset fullname=${cmd##* }
typeset dsname=${fullname%%@*} typeset dsname=${fullname%%@*}
typeset snapname=${fullname##*@} typeset snapname=${fullname##*@}
@ -141,9 +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
grep "$subcmd $ds ([0-9]*) tag=$tag" $NEW_HISTORY \ if grep -q "$subcmd $ds ([0-9]*) tag=$tag" $NEW_HISTORY; then
>/dev/null 2>&1
if [[ $? != 0 ]]; 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
@ -231,8 +226,7 @@ function verify_allow
# - Whether the operation applies locally or to descendent datasets (or # - Whether the operation applies locally or to descendent datasets (or
# both) # both)
# #
echo $cmd | awk '{i = NF - 1; print $i}' | grep '@' >/dev/null \ echo $cmd | awk '$(NF - 1) ~ /@/ {exit 1}' || is_set=1
2>&1 && is_set=1
dsname=${cmd##* } dsname=${cmd##* }
[[ $cmd =~ "-l " ]] && lflag=1 [[ $cmd =~ "-l " ]] && lflag=1
[[ $cmd =~ "-d " ]] && dflag=1 [[ $cmd =~ "-d " ]] && dflag=1
@ -275,7 +269,7 @@ function verify_allow
str="u" str="u"
[[ -n $is_set ]] && str="U" [[ -n $is_set ]] && str="U"
tmp=${cmd##*-u } tmp=${cmd##*-u }
opt=$(echo $tmp | awk '{print $2}') read -r _ opt _ <<<"$opt"
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"
@ -299,7 +293,7 @@ function verify_allow
str="g" str="g"
[[ -n $is_set ]] && str="G" [[ -n $is_set ]] && str="G"
tmp=${cmd##*-g } tmp=${cmd##*-g }
opt=$(echo $tmp | awk '{print $2}') read -r _ opt _ <<<"$opt"
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"

View File

@ -77,7 +77,7 @@ set -A vdevs "" "mirror" "raidz" "raidz1" "raidz2"
typeset -i i=0 typeset -i i=0
PREVDUMPDEV=`dumpadm | grep "Dump device" | awk '{print $3}'` PREVDUMPDEV=`dumpadm | awk '/Dump device/ {print $3}'`
unset NOINUSE_CHECK unset NOINUSE_CHECK
while (( i < ${#vdevs[*]} )); do while (( i < ${#vdevs[*]} )); do

View File

@ -82,7 +82,7 @@ set -A vdevs "" "mirror" "raidz" "raidz1" "raidz2"
typeset -i i=0 typeset -i i=0
PREVDUMPDEV=`dumpadm | grep "Dump device" | awk '{print $3}'` PREVDUMPDEV=`dumpadm | awk '/Dump device/ {print $3}'`
while (( i < ${#vdevs[*]} )); do while (( i < ${#vdevs[*]} )); do
typeset spare="spare $sdisks" typeset spare="spare $sdisks"

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