OpenZFS 7290 - ZFS test suite needs to control what utilities it can run

Authored by: John Wren Kennedy <john.kennedy@delphix.com>
Reviewed by: Dan Kimmel <dan.kimmel@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Dan McDonald <danmcd@omniti.com>
Approved by: Gordon Ross <gordon.w.ross@gmail.com>
Ported-by: Brian Behlendorf <behlendorf1@llnl.gov>
Ported-by: George Melikov <mail@gmelikov.ru>

Porting Notes:
- Utilities which aren't available under Linux have been removed.
- Because of sudo's default secure path behavior PATH must be
  explicitly reset at the top of libtest.shlib.  This avoids the
  need for all users to customize secure path on their system.
- Updated ZoL infrastructure to manage constrained path
- Updated all test cases
- Check permissions for usergroup tests
- When testing in-tree create links under bin/
- Update fault cleanup such that missing files during
  cleanup aren't fatal.
- Configure su environment with constrained path

OpenZFS-issue: https://www.illumos.org/issues/7290
OpenZFS-commit: https://github.com/openzfs/openzfs/commit/1d32ba6
Closes #5903
This commit is contained in:
John Wren Kennedy
2017-04-05 20:18:22 -04:00
committed by Brian Behlendorf
parent 7a4500a101
commit c1d9abf905
797 changed files with 8038 additions and 7458 deletions
@@ -28,7 +28,7 @@
#
#
# Copyright (c) 2012, 2015 by Delphix. All rights reserved.
# Copyright (c) 2012, 2016 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
@@ -47,15 +47,15 @@ verify_runnable "global"
function cleanup {
if poolexists $TESTPOOL ; then
log_must $ZPOOL destroy $TESTPOOL
log_must zpool destroy $TESTPOOL
fi
if [[ -f $VDEV ]]; then
log_must $RM -f $VDEV
log_must rm -f $VDEV
fi
}
$ZPOOL set 2>&1 | $GREP bootfs > /dev/null
zpool set 2>&1 | grep bootfs > /dev/null
if [ $? -ne 0 ]
then
log_unsupported "bootfs pool property not supported on this release."
@@ -66,17 +66,17 @@ log_onexit cleanup
typeset VDEV=$TESTDIR/bootfs_001_pos_a.$$.dat
log_must $MKFILE $MINVDEVSIZE $VDEV
log_must mkfile $MINVDEVSIZE $VDEV
create_pool "$TESTPOOL" "$VDEV"
log_must $ZFS create $TESTPOOL/$TESTFS
log_must zfs create $TESTPOOL/$TESTFS
log_must $ZFS snapshot $TESTPOOL/$TESTFS@snap
log_must $ZFS clone $TESTPOOL/$TESTFS@snap $TESTPOOL/clone
log_must zfs snapshot $TESTPOOL/$TESTFS@snap
log_must zfs clone $TESTPOOL/$TESTFS@snap $TESTPOOL/clone
log_must $ZPOOL set bootfs=$TESTPOOL/$TESTFS $TESTPOOL
log_must $ZPOOL set bootfs=$TESTPOOL/$TESTFS@snap $TESTPOOL
log_must $ZPOOL set bootfs=$TESTPOOL/clone $TESTPOOL
log_must zpool set bootfs=$TESTPOOL/$TESTFS $TESTPOOL
log_must zpool set bootfs=$TESTPOOL/$TESTFS@snap $TESTPOOL
log_must zpool set bootfs=$TESTPOOL/clone $TESTPOOL
log_must $ZFS promote $TESTPOOL/clone
log_must $ZPOOL set bootfs=$TESTPOOL/clone $TESTPOOL
log_must zfs promote $TESTPOOL/clone
log_must zpool set bootfs=$TESTPOOL/clone $TESTPOOL
log_pass "Valid datasets are accepted as bootfs property values"
@@ -28,7 +28,7 @@
#
#
# Copyright (c) 2012, 2015 by Delphix. All rights reserved.
# Copyright (c) 2012, 2016 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
@@ -49,19 +49,19 @@ verify_runnable "global"
function cleanup {
if datasetexists $TESTPOOL/vol
then
log_must $ZFS destroy $TESTPOOL/vol
log_must zfs destroy $TESTPOOL/vol
fi
if poolexists $TESTPOOL
then
log_must $ZPOOL destroy $TESTPOOL
log_must zpool destroy $TESTPOOL
fi
if [[ -f $VDEV ]]; then
log_must $RM -f $VDEV
log_must rm -f $VDEV
fi
}
$ZPOOL set 2>&1 | $GREP bootfs > /dev/null
zpool set 2>&1 | grep bootfs > /dev/null
if [ $? -ne 0 ]
then
log_unsupported "bootfs pool property not supported on this release."
@@ -72,11 +72,11 @@ log_onexit cleanup
typeset VDEV=$TESTDIR/bootfs_002_neg_a.$$.dat
log_must $MKFILE 400m $VDEV
log_must mkfile 400m $VDEV
create_pool "$TESTPOOL" "$VDEV"
log_must $ZFS create -V 10m $TESTPOOL/vol
log_must zfs create -V 10m $TESTPOOL/vol
block_device_wait
log_mustnot $ZPOOL set bootfs=$TESTPOOL/vol $TESTPOOL
log_mustnot zpool set bootfs=$TESTPOOL/vol $TESTPOOL
log_pass "Invalid datasets are rejected as boot property values"
@@ -26,7 +26,7 @@
#
#
# Copyright (c) 2012, 2015 by Delphix. All rights reserved.
# Copyright (c) 2012, 2016 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
@@ -48,13 +48,13 @@ set -A pools "pool.$$" "pool123" "mypool"
function cleanup {
if poolexists $POOL ; then
log_must $ZPOOL destroy $POOL
log_must zpool destroy $POOL
fi
$RM /bootfs_003.$$.dat
rm /bootfs_003.$$.dat
}
$ZPOOL set 2>&1 | $GREP bootfs > /dev/null
zpool set 2>&1 | grep bootfs > /dev/null
if [ $? -ne 0 ]
then
log_unsupported "bootfs pool property not supported on this release."
@@ -63,23 +63,23 @@ fi
log_onexit cleanup
log_assert "Valid pool names are accepted by zpool set bootfs"
$MKFILE $MINVDEVSIZE $TESTDIR/bootfs_003.$$.dat
mkfile $MINVDEVSIZE $TESTDIR/bootfs_003.$$.dat
typeset -i i=0;
while [ $i -lt "${#pools[@]}" ]
do
POOL=${pools[$i]}
log_must $ZPOOL create $POOL $TESTDIR/bootfs_003.$$.dat
log_must $ZFS create $POOL/$TESTFS
log_must zpool create $POOL $TESTDIR/bootfs_003.$$.dat
log_must zfs create $POOL/$TESTFS
log_must $ZPOOL set bootfs=$POOL/$TESTFS $POOL
RES=$($ZPOOL get bootfs $POOL | $TAIL -1 | $AWK '{print $3}' )
log_must zpool set bootfs=$POOL/$TESTFS $POOL
RES=$(zpool get bootfs $POOL | tail -1 | awk '{print $3}' )
if [ $RES != "$POOL/$TESTFS" ]
then
log_fail "Expected $RES == $POOL/$TESTFS"
fi
log_must $ZPOOL destroy $POOL
log_must zpool destroy $POOL
i=$(( $i + 1 ))
done
@@ -26,7 +26,7 @@
#
#
# Copyright (c) 2012, 2015 by Delphix. All rights reserved.
# Copyright (c) 2012, 2016 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
@@ -49,13 +49,13 @@ set -A pools "pool//$$" "pool%d123" "mirror" "c0t0d0s0" "pool*23*" "*po!l" \
function cleanup {
if poolexists $POOL; then
log_must $ZPOOL destroy $POOL
log_must zpool destroy $POOL
fi
$RM /bootfs_004.$$.dat
rm /bootfs_004.$$.dat
}
$ZPOOL set 2>&1 | $GREP bootfs > /dev/null
zpool set 2>&1 | grep bootfs > /dev/null
if [ $? -ne 0 ]
then
log_unsupported "bootfs pool property not supported on this release."
@@ -78,16 +78,16 @@ pools[${#pools[@]}]="$bigname"
$MKFILE $MINVDEVSIZE $TESTDIR/bootfs_004.$$.dat
mkfile $MINVDEVSIZE $TESTDIR/bootfs_004.$$.dat
typeset -i i=0;
while [ $i -lt "${#pools[@]}" ]
do
POOL=${pools[$i]}/$TESTFS
log_mustnot $ZPOOL create $POOL $TESTDIR/bootfs_004.$$.dat
log_mustnot $ZFS create $POOL/$TESTFS
log_mustnot $ZPOOL set bootfs=$POOL/$TESTFS $POOL
log_mustnot zpool create $POOL $TESTDIR/bootfs_004.$$.dat
log_mustnot zfs create $POOL/$TESTFS
log_mustnot zpool set bootfs=$POOL/$TESTFS $POOL
i=$(( $i + 1 ))
done
@@ -52,7 +52,7 @@ function cleanup {
#
typeset pool_name
for config in $CONFIGS; do
pool_name=$(eval $ECHO \$ZPOOL_VERSION_${config}_NAME)
pool_name=$(eval echo \$ZPOOL_VERSION_${config}_NAME)
destroy_pool $pool_name
done
@@ -65,14 +65,14 @@ log_assert "Boot properties cannot be set on pools with older versions"
CONFIGS="1 2 3"
log_onexit cleanup
log_must $ZPOOL create -f $TESTPOOL $DISKS
log_must zpool create -f $TESTPOOL $DISKS
for config in $CONFIGS
do
create_old_pool $config
POOL_NAME=$(eval $ECHO \$ZPOOL_VERSION_${config}_NAME)
log_must $ZFS create $POOL_NAME/$TESTFS
log_mustnot $ZPOOL set bootfs=$POOL_NAME/$TESTFS $POOL_NAME
POOL_NAME=$(eval echo \$ZPOOL_VERSION_${config}_NAME)
log_must zfs create $POOL_NAME/$TESTFS
log_mustnot zpool set bootfs=$POOL_NAME/$TESTFS $POOL_NAME
log_must destroy_upgraded_pool $config
done
@@ -26,7 +26,7 @@
#
#
# Copyright (c) 2012, 2015 by Delphix. All rights reserved.
# Copyright (c) 2012, 2016 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
@@ -44,7 +44,7 @@
verify_runnable "global"
$ZPOOL set 2>&1 | $GREP bootfs > /dev/null
zpool set 2>&1 | grep bootfs > /dev/null
if [ $? -ne 0 ]
then
log_unsupported "bootfs pool property not supported on this release."
@@ -57,38 +57,38 @@ VDEV4=$TESTDIR/bootfs_006_pos_d.$$.dat
function verify_bootfs { # $POOL
POOL=$1
log_must $ZFS create $POOL/$TESTFS
log_must zfs create $POOL/$TESTFS
log_must $ZPOOL set bootfs=$POOL/$TESTFS $POOL
VAL=$($ZPOOL get bootfs $POOL | $TAIL -1 | $AWK '{print $3}' )
log_must zpool set bootfs=$POOL/$TESTFS $POOL
VAL=$(zpool get bootfs $POOL | tail -1 | awk '{print $3}' )
if [ $VAL != "$POOL/$TESTFS" ]
then
log_must $ZPOOL status -v $POOL
log_must zpool status -v $POOL
log_fail \
"set/get failed on $POOL - expected $VAL == $POOL/$TESTFS"
fi
log_must $ZPOOL destroy $POOL
log_must zpool destroy $POOL
}
function verify_no_bootfs { # $POOL
POOL=$1
log_must $ZFS create $POOL/$TESTFS
log_mustnot $ZPOOL set bootfs=$POOL/$TESTFS $POOL
VAL=$($ZPOOL get bootfs $POOL | $TAIL -1 | $AWK '{print $3}' )
log_must zfs create $POOL/$TESTFS
log_mustnot zpool set bootfs=$POOL/$TESTFS $POOL
VAL=$(zpool get bootfs $POOL | tail -1 | awk '{print $3}' )
if [ $VAL == "$POOL/$TESTFS" ]
then
log_must $ZPOOL status -v $POOL
log_must zpool status -v $POOL
log_fail "set/get unexpectedly failed $VAL != $POOL/$TESTFS"
fi
log_must $ZPOOL destroy $POOL
log_must zpool destroy $POOL
}
function cleanup {
if poolexists $TESTPOOL
then
log_must $ZPOOL destroy $TESTPOOL
log_must zpool destroy $TESTPOOL
fi
log_must $RM $VDEV1 $VDEV2 $VDEV3 $VDEV4
log_must rm $VDEV1 $VDEV2 $VDEV3 $VDEV4
}
log_assert "Pools of correct vdev types accept boot property"
@@ -96,51 +96,51 @@ log_assert "Pools of correct vdev types accept boot property"
log_onexit cleanup
log_must $MKFILE $MINVDEVSIZE $VDEV1 $VDEV2 $VDEV3 $VDEV4
log_must mkfile $MINVDEVSIZE $VDEV1 $VDEV2 $VDEV3 $VDEV4
## the following configurations are supported bootable pools
# normal
log_must $ZPOOL create $TESTPOOL $VDEV1
log_must zpool create $TESTPOOL $VDEV1
verify_bootfs $TESTPOOL
# normal + hotspare
log_must $ZPOOL create $TESTPOOL $VDEV1 spare $VDEV2
log_must zpool create $TESTPOOL $VDEV1 spare $VDEV2
verify_bootfs $TESTPOOL
# mirror
log_must $ZPOOL create $TESTPOOL mirror $VDEV1 $VDEV2
log_must zpool create $TESTPOOL mirror $VDEV1 $VDEV2
verify_bootfs $TESTPOOL
# mirror + hotspare
log_must $ZPOOL create $TESTPOOL mirror $VDEV1 $VDEV2 spare $VDEV3
log_must zpool create $TESTPOOL mirror $VDEV1 $VDEV2 spare $VDEV3
verify_bootfs $TESTPOOL
## the following configurations are not supported as bootable pools
# stripe
log_must $ZPOOL create $TESTPOOL $VDEV1 $VDEV2
log_must zpool create $TESTPOOL $VDEV1 $VDEV2
verify_no_bootfs $TESTPOOL
# stripe + hotspare
log_must $ZPOOL create $TESTPOOL $VDEV1 $VDEV2 spare $VDEV3
log_must zpool create $TESTPOOL $VDEV1 $VDEV2 spare $VDEV3
verify_no_bootfs $TESTPOOL
# raidz
log_must $ZPOOL create $TESTPOOL raidz $VDEV1 $VDEV2
log_must zpool create $TESTPOOL raidz $VDEV1 $VDEV2
verify_no_bootfs $TESTPOOL
# raidz + hotspare
log_must $ZPOOL create $TESTPOOL raidz $VDEV1 $VDEV2 spare $VDEV3
log_must zpool create $TESTPOOL raidz $VDEV1 $VDEV2 spare $VDEV3
verify_no_bootfs $TESTPOOL
# raidz2
log_must $ZPOOL create $TESTPOOL raidz2 $VDEV1 $VDEV2 $VDEV3
log_must zpool create $TESTPOOL raidz2 $VDEV1 $VDEV2 $VDEV3
verify_no_bootfs $TESTPOOL
# raidz2 + hotspare
log_must $ZPOOL create $TESTPOOL raidz2 $VDEV1 $VDEV2 $VDEV3 spare $VDEV4
log_must zpool create $TESTPOOL raidz2 $VDEV1 $VDEV2 $VDEV3 spare $VDEV4
verify_no_bootfs $TESTPOOL
log_pass "Pools of correct vdev types accept boot property"
@@ -25,6 +25,10 @@
# Use is subject to license terms.
#
#
# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
#
@@ -56,12 +60,12 @@ typeset assert_mesg="setting bootfs on a pool which was configured with the \
log_assert $assert_mesg
create_pool "$TESTPOOL" "$DISK"
log_must $ZFS create $EFI_BOOTFS
log_must zfs create $EFI_BOOTFS
if is_linux; then
log_must $ZPOOL set bootfs=$EFI_BOOTFS $TESTPOOL
log_must zpool set bootfs=$EFI_BOOTFS $TESTPOOL
else
log_mustnot $ZPOOL set bootfs=$EFI_BOOTFS $TESTPOOL
log_mustnot zpool set bootfs=$EFI_BOOTFS $TESTPOOL
fi
log_pass $assert_mesg
@@ -27,6 +27,10 @@
# Copyright 2015 Nexenta Systems, Inc.
#
#
# Copyright (c) 2016 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
#
@@ -58,8 +62,8 @@ typeset assert_mesg="setting bootfs on a pool which was configured with the \
log_assert $assert_mesg
create_pool "$TESTPOOL" "$DISK"
log_must $ZFS create $EFI_BOOTFS
log_must zfs create $EFI_BOOTFS
log_must $ZPOOL set bootfs=$EFI_BOOTFS $TESTPOOL
log_must zpool set bootfs=$EFI_BOOTFS $TESTPOOL
log_pass $assert_mesg
@@ -26,7 +26,7 @@
#
#
# Copyright (c) 2012, 2015 by Delphix. All rights reserved.
# Copyright (c) 2012, 2016 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
@@ -51,7 +51,7 @@ function cleanup {
fi
if [[ -f $VDEV ]]; then
log_must $RM -f $VDEV
log_must rm -f $VDEV
fi
}
@@ -64,18 +64,18 @@ typeset COMP_FS=$TESTPOOL/COMP_FS
log_onexit cleanup
log_assert $assert_msg
log_must $MKFILE $MINVDEVSIZE $VDEV
log_must $ZPOOL create $TESTPOOL $VDEV
log_must $ZFS create $COMP_FS
log_must mkfile $MINVDEVSIZE $VDEV
log_must zpool create $TESTPOOL $VDEV
log_must zfs create $COMP_FS
typeset -i i=0
set -A gtype "gzip" "gzip-1" "gzip-2" "gzip-3" "gzip-4" "gzip-5" \
"gzip-6" "gzip-7" "gzip-8" "gzip-9"
while (( i < ${#gtype[@]} )); do
log_must $ZFS set compression=${gtype[i]} $COMP_FS
log_mustnot $ZPOOL set bootfs=$COMP_FS $TESTPOOL
log_must $ZFS set compression=off $COMP_FS
log_must zfs set compression=${gtype[i]} $COMP_FS
log_mustnot zpool set bootfs=$COMP_FS $TESTPOOL
log_must zfs set compression=off $COMP_FS
(( i += 1 ))
done
@@ -29,6 +29,6 @@
verify_runnable "global"
[[ -e $TESTDIR ]] && $RM -rf $TESTDIR
[[ -e $TESTDIR ]] && rm -rf $TESTDIR
log_pass
@@ -29,6 +29,6 @@
verify_runnable "global"
log_must $MKDIR $TESTDIR
log_must mkdir $TESTDIR
log_pass