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
@@ -12,7 +12,7 @@
#
#
# Copyright (c) 2012 by Delphix. All rights reserved.
# Copyright (c) 2012, 2016 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
@@ -34,42 +34,42 @@ log_onexit cleanup
function cleanup
{
datasetexists $origin && log_must $ZFS destroy -R $origin
log_must $ZFS create -o mountpoint=$TESTDIR $origin
datasetexists $origin && log_must zfs destroy -R $origin
log_must zfs create -o mountpoint=$TESTDIR $origin
}
log_assert "nopwrite updates file metadata correctly"
log_must $ZFS set compress=on $origin
log_must $ZFS set checksum=sha256 $origin
$DD if=/dev/urandom of=$TESTDIR/file bs=1024k count=$MEGS conv=notrunc \
log_must zfs set compress=on $origin
log_must zfs set checksum=sha256 $origin
dd if=/dev/urandom of=$TESTDIR/file bs=1024k count=$MEGS conv=notrunc \
>/dev/null 2>&1 || log_fail "dd into $TESTDIR/file failed."
$ZFS snapshot $origin@a || log_fail "zfs snap failed"
log_must $ZFS clone $origin@a $origin/clone
zfs snapshot $origin@a || log_fail "zfs snap failed"
log_must zfs clone $origin@a $origin/clone
if is_linux; then
o_atime=$(stat -c %X $TESTDIR/clone/file)
o_ctime=$(stat -c %Z $TESTDIR/clone/file)
o_mtime=$(stat -c %Y $TESTDIR/clone/file)
else
o_atime=$($LS -E% all $TESTDIR/clone/file | $AWK '/atime/ {print $4}')
o_ctime=$($LS -E% all $TESTDIR/clone/file | $AWK '/ctime/ {print $4}')
o_mtime=$($LS -E% all $TESTDIR/clone/file | $AWK '/mtime/ {print $4}')
o_atime=$(ls -E% all $TESTDIR/clone/file | awk '/atime/ {print $4}')
o_ctime=$(ls -E% all $TESTDIR/clone/file | awk '/ctime/ {print $4}')
o_mtime=$(ls -E% all $TESTDIR/clone/file | awk '/mtime/ {print $4}')
fi
$SLEEP 1
$DD if=/$TESTDIR/file of=/$TESTDIR/clone/file bs=1024k count=$MEGS \
sleep 1
dd if=/$TESTDIR/file of=/$TESTDIR/clone/file bs=1024k count=$MEGS \
conv=notrunc >/dev/null 2>&1 || log_fail "dd failed."
$SLEEP 1
sleep 1
if is_linux; then
atime=$(stat -c %X $TESTDIR/clone/file)
ctime=$(stat -c %Z $TESTDIR/clone/file)
mtime=$(stat -c %Y $TESTDIR/clone/file)
else
atime=$($LS -E% all $TESTDIR/clone/file | $AWK '/atime/ {print $4}')
ctime=$($LS -E% all $TESTDIR/clone/file | $AWK '/ctime/ {print $4}')
mtime=$($LS -E% all $TESTDIR/clone/file | $AWK '/mtime/ {print $4}')
atime=$(ls -E% all $TESTDIR/clone/file | awk '/atime/ {print $4}')
ctime=$(ls -E% all $TESTDIR/clone/file | awk '/ctime/ {print $4}')
mtime=$(ls -E% all $TESTDIR/clone/file | awk '/mtime/ {print $4}')
fi
[[ $o_atime = $atime ]] || log_fail "atime changed: $o_atime $atime"