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
@@ -35,8 +35,8 @@
verify_runnable "global"
$DF -F zfs -h | $GREP "$TESTFS " >/dev/null
[[ $? == 0 ]] && log_must $ZFS umount -f $TESTDIR
df -F zfs -h | grep "$TESTFS " >/dev/null
[[ $? == 0 ]] && log_must zfs umount -f $TESTDIR
destroy_pool $TESTPOOL
# recreate and destroy a zpool over the disks to restore the partitions to
@@ -51,16 +51,16 @@ verify_runnable "both"
function cleanup
{
$ECHO cleanup
echo cleanup
[[ -e $TESTDIR ]] && \
log_must $RM -rf $TESTDIR/* > /dev/null 2>&1
log_must rm -rf $TESTDIR/* > /dev/null 2>&1
}
log_assert "Create and read back files with using different checksum algorithms"
log_onexit cleanup
FSSIZE=$($ZPOOL list -Hp -o size $TESTPOOL)
FSSIZE=$(zpool list -Hp -o size $TESTPOOL)
WRITESZ=1048576
WRITECNT=$((($FSSIZE) / $WRITESZ ))
# Skip the first and last 4MB
@@ -79,16 +79,16 @@ firstvdev=${array[0]}
# errors.
for ((count = 0; count < ${#checksum_props[*]} ; count++)); do
i=${checksum_props[$count]}
$ZFS set checksum=$i $TESTPOOL
$FILE_WRITE -o overwrite -f $TESTDIR/test_$i -b $WRITESZ -c 5 -d R
zfs set checksum=$i $TESTPOOL
file_write -o overwrite -f $TESTDIR/test_$i -b $WRITESZ -c 5 -d R
done
$ZPOOL export $TESTPOOL
$ZPOOL import $TESTPOOL
$ZPOOL scrub $TESTPOOL
zpool export $TESTPOOL
zpool import $TESTPOOL
zpool scrub $TESTPOOL
while is_pool_scrubbing $TESTPOOL; do
$SLEEP 1
sleep 1
done
$ZPOOL status -P -v $TESTPOOL | grep $firstvdev | read -r name state rd wr cksum
zpool status -P -v $TESTPOOL | grep $firstvdev | read -r name state rd wr cksum
log_assert "Normal file write test saw $cksum checksum errors"
log_must [ $cksum -eq 0 ]
@@ -97,29 +97,29 @@ rm -fr $TESTDIR/*
log_assert "Test scrambling the disk and seeing checksum errors"
for ((count = 0; count < ${#checksum_props[*]} ; count++)); do
i=${checksum_props[$count]}
$ZFS set checksum=$i $TESTPOOL
$FILE_WRITE -o overwrite -f $TESTDIR/test_$i -b $WRITESZ -c 5 -d R
zfs set checksum=$i $TESTPOOL
file_write -o overwrite -f $TESTDIR/test_$i -b $WRITESZ -c 5 -d R
$ZPOOL export $TESTPOOL
zpool export $TESTPOOL
# Scramble the data on the first vdev in our pool.
# Skip the first and last 16MB of data, then scramble the rest after that
#
$FILE_WRITE -o overwrite -f $firstvdev -s $SKIP -c $WRITECNT -b $WRITESZ -d R
file_write -o overwrite -f $firstvdev -s $SKIP -c $WRITECNT -b $WRITESZ -d R
$ZPOOL import $TESTPOOL
zpool import $TESTPOOL
i=${checksum_props[$count]}
$ZPOOL scrub $TESTPOOL
zpool scrub $TESTPOOL
while is_pool_scrubbing $TESTPOOL; do
$SLEEP 1
sleep 1
done
$ZPOOL status -P -v $TESTPOOL | grep $firstvdev | read -r name state rd wr cksum
zpool status -P -v $TESTPOOL | grep $firstvdev | read -r name state rd wr cksum
log_assert "Checksum '$i' caught $cksum checksum errors"
log_must [ $cksum -ne 0 ]
rm -f $TESTDIR/test_$i
$ZPOOL clear $TESTPOOL
zpool clear $TESTPOOL
done
@@ -12,7 +12,7 @@
#
#
# Copyright (c) 2015 by Delphix. All rights reserved.
# Copyright (c) 2015, 2016 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
@@ -12,7 +12,7 @@
#
#
# Copyright (c) 2015 by Delphix. All rights reserved.
# Copyright (c) 2015, 2016 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
@@ -12,7 +12,7 @@
#
#
# Copyright (c) 2015 by Delphix. All rights reserved.
# Copyright (c) 2015, 2016 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib