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
@@ -26,7 +26,7 @@
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
@@ -47,9 +47,9 @@ verify_runnable "both"
function cleanup
{
log_must $ZFS destroy -rf $TESTPOOL/$TESTFS
log_must $ZFS create $TESTPOOL/$TESTFS
log_must $ZFS set mountpoint=$TESTDIR $TESTPOOL/$TESTFS
log_must zfs destroy -rf $TESTPOOL/$TESTFS
log_must zfs create $TESTPOOL/$TESTFS
log_must zfs set mountpoint=$TESTDIR $TESTPOOL/$TESTFS
}
log_assert "refquota limits the amount of space a dataset can consume, " \
@@ -58,20 +58,20 @@ log_onexit cleanup
fs=$TESTPOOL/$TESTFS
sub=$fs/sub
log_must $ZFS create $sub
log_must zfs create $sub
log_must $ZFS set refquota=10M $fs
log_must zfs set refquota=10M $fs
mntpnt=$(get_prop mountpoint $fs)
log_mustnot $MKFILE 11M $mntpnt/file
log_must $MKFILE 9M $mntpnt/file
log_must $ZFS snapshot $fs@snap
log_mustnot $MKFILE 2M $mntpnt/file2
log_mustnot mkfile 11M $mntpnt/file
log_must mkfile 9M $mntpnt/file
log_must zfs snapshot $fs@snap
log_mustnot mkfile 2M $mntpnt/file2
mntpnt=$(get_prop mountpoint $sub)
log_must $MKFILE 10M $mntpnt/file
log_must $ZFS snapshot $sub@snap
log_must $MKFILE 10 $mntpnt/file2
log_must mkfile 10M $mntpnt/file
log_must zfs snapshot $sub@snap
log_must mkfile 10 $mntpnt/file2
log_pass "refquota limits the amount of space a dataset can consume, " \
"but does not include space used by descendents."
@@ -26,7 +26,7 @@
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
@@ -47,9 +47,9 @@ verify_runnable "both"
function cleanup
{
log_must $ZFS destroy -rf $TESTPOOL/$TESTFS
log_must $ZFS create $TESTPOOL/$TESTFS
log_must $ZFS set mountpoint=$TESTDIR $TESTPOOL/$TESTFS
log_must zfs destroy -rf $TESTPOOL/$TESTFS
log_must zfs create $TESTPOOL/$TESTFS
log_must zfs set mountpoint=$TESTDIR $TESTPOOL/$TESTFS
}
log_assert "Quotas are enforced using the minimum of the two properties"
@@ -57,11 +57,11 @@ log_onexit cleanup
TESTFILE='testfile'
fs=$TESTPOOL/$TESTFS
log_must $ZFS set quota=15M $fs
log_must $ZFS set refquota=25M $fs
log_must zfs set quota=15M $fs
log_must zfs set refquota=25M $fs
mntpnt=$(get_prop mountpoint $fs)
log_mustnot $MKFILE 20M $mntpnt/$TESTFILE
log_mustnot mkfile 20M $mntpnt/$TESTFILE
typeset -i used quota
used=$(get_prop used $fs)
quota=$(get_prop quota $fs)
@@ -74,11 +74,11 @@ fi
#
# Switch the value of them and try again
#
log_must $RM $mntpnt/$TESTFILE
log_must $ZFS set quota=25M $fs
log_must $ZFS set refquota=15M $fs
log_must rm $mntpnt/$TESTFILE
log_must zfs set quota=25M $fs
log_must zfs set refquota=15M $fs
log_mustnot $MKFILE 20M $mntpnt/$TESTFILE
log_mustnot mkfile 20M $mntpnt/$TESTFILE
used=$(get_prop used $fs)
refquota=$(get_prop refquota $fs)
((used = used / (1024 * 1024)))
@@ -26,7 +26,7 @@
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
@@ -45,9 +45,9 @@ verify_runnable "both"
function cleanup
{
log_must $ZFS destroy -rf $TESTPOOL/$TESTFS
log_must $ZFS create $TESTPOOL/$TESTFS
log_must $ZFS set mountpoint=$TESTDIR $TESTPOOL/$TESTFS
log_must zfs destroy -rf $TESTPOOL/$TESTFS
log_must zfs create $TESTPOOL/$TESTFS
log_must zfs set mountpoint=$TESTDIR $TESTPOOL/$TESTFS
}
log_assert "Sub-filesystem quotas are not enforced by property 'refquota'"
@@ -55,12 +55,12 @@ log_onexit cleanup
TESTFILE='testfile'
fs=$TESTPOOL/$TESTFS
log_must $ZFS set quota=25M $fs
log_must $ZFS set refquota=10M $fs
log_must $ZFS create $fs/subfs
log_must zfs set quota=25M $fs
log_must zfs set refquota=10M $fs
log_must zfs create $fs/subfs
mntpnt=$(get_prop mountpoint $fs/subfs)
log_must $MKFILE 20M $mntpnt/$TESTFILE
log_must mkfile 20M $mntpnt/$TESTFILE
typeset -i used quota refquota
used=$(get_prop used $fs)
@@ -71,7 +71,7 @@ if [[ $used -lt $refquota ]]; then
log_fail "ERROR: $used < $refquota subfs quotas are limited by refquota"
fi
log_mustnot $MKFILE 20M $mntpnt/$TESTFILE.2
log_mustnot mkfile 20M $mntpnt/$TESTFILE.2
used=$(get_prop used $fs)
quota=$(get_prop quota $fs)
((used = used / (1024 * 1024)))
@@ -26,7 +26,7 @@
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
@@ -45,9 +45,9 @@ verify_runnable "both"
function cleanup
{
log_must $ZFS destroy -rf $TESTPOOL/$TESTFS
log_must $ZFS create $TESTPOOL/$TESTFS
log_must $ZFS set mountpoint=$TESTDIR $TESTPOOL/$TESTFS
log_must zfs destroy -rf $TESTPOOL/$TESTFS
log_must zfs create $TESTPOOL/$TESTFS
log_must zfs set mountpoint=$TESTDIR $TESTPOOL/$TESTFS
}
log_assert "refquotas are not limited by snapshots."
@@ -55,15 +55,15 @@ log_onexit cleanup
TESTFILE='testfile'
fs=$TESTPOOL/$TESTFS
log_must $ZFS set quota=25M $fs
log_must $ZFS set refquota=15M $fs
log_must zfs set quota=25M $fs
log_must zfs set refquota=15M $fs
mntpnt=$(get_prop mountpoint $fs)
typeset -i i=0
while ((i < 3)); do
log_must $MKFILE 7M $mntpnt/$TESTFILE.$i
log_must $ZFS snapshot $fs@snap.$i
log_must $RM $mntpnt/$TESTFILE.$i
log_must mkfile 7M $mntpnt/$TESTFILE.$i
log_must zfs snapshot $fs@snap.$i
log_must rm $mntpnt/$TESTFILE.$i
((i += 1))
done
@@ -71,6 +71,6 @@ done
#
# Verify out of the limitation of 'quota'
#
log_mustnot $MKFILE 7M $mntpnt/$TESTFILE
log_mustnot mkfile 7M $mntpnt/$TESTFILE
log_pass "refquotas are not limited by snapshots."
@@ -26,7 +26,7 @@
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
@@ -45,9 +45,9 @@ verify_runnable "both"
function cleanup
{
log_must $ZFS destroy -rf $TESTPOOL/$TESTFS
log_must $ZFS create $TESTPOOL/$TESTFS
log_must $ZFS set mountpoint=$TESTDIR $TESTPOOL/$TESTFS
log_must zfs destroy -rf $TESTPOOL/$TESTFS
log_must zfs create $TESTPOOL/$TESTFS
log_must zfs set mountpoint=$TESTDIR $TESTPOOL/$TESTFS
}
log_assert "refquotas are not limited by sub-filesystem snapshots."
@@ -55,16 +55,16 @@ log_onexit cleanup
TESTFILE='testfile'
fs=$TESTPOOL/$TESTFS
log_must $ZFS set quota=25M $fs
log_must $ZFS set refquota=15M $fs
log_must $ZFS create $fs/subfs
log_must zfs set quota=25M $fs
log_must zfs set refquota=15M $fs
log_must zfs create $fs/subfs
mntpnt=$(get_prop mountpoint $fs/subfs)
typeset -i i=0
while ((i < 3)); do
log_must $MKFILE 7M $mntpnt/$TESTFILE.$i
log_must $ZFS snapshot $fs/subfs@snap.$i
log_must $RM $mntpnt/$TESTFILE.$i
log_must mkfile 7M $mntpnt/$TESTFILE.$i
log_must zfs snapshot $fs/subfs@snap.$i
log_must rm $mntpnt/$TESTFILE.$i
((i += 1))
done
@@ -72,6 +72,6 @@ done
#
# Verify out of the limitation of 'quota'
#
log_mustnot $MKFILE 7M $mntpnt/$TESTFILE
log_mustnot mkfile 7M $mntpnt/$TESTFILE
log_pass "refquotas are not limited by sub-filesystem snapshots"
@@ -26,7 +26,7 @@
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
@@ -45,8 +45,8 @@ verify_runnable "both"
function cleanup
{
log_must $ZFS set refquota=none $TESTPOOL/$TESTFS
log_must $ZFS set refreserv=none $TESTPOOL/$TESTFS
log_must zfs set refquota=none $TESTPOOL/$TESTFS
log_must zfs set refreserv=none $TESTPOOL/$TESTFS
}
log_assert "'zfs set refquota' can handle incorrect arguments correctly."
@@ -61,8 +61,8 @@ set -A badopt \
typeset -i i=0
while ((i < ${#badopt[@]})); do
log_mustnot $ZFS set refquota=${badopt[$i]} $TESTPOOL/$TESTFS
log_mustnot $ZFS set refreserv=${badopt[$i]} $TESTPOOL/$TESTFS
log_mustnot zfs set refquota=${badopt[$i]} $TESTPOOL/$TESTFS
log_mustnot zfs set refreserv=${badopt[$i]} $TESTPOOL/$TESTFS
((i += 1))
done