diff --git a/tests/runfiles/common.run b/tests/runfiles/common.run index af720ad9b2da..ccf03af89dcb 100644 --- a/tests/runfiles/common.run +++ b/tests/runfiles/common.run @@ -49,7 +49,7 @@ post = [tests/functional/cache] tests = ['cache_001_pos', 'cache_002_pos', 'cache_003_pos', 'cache_004_neg', 'cache_005_neg', 'cache_006_pos', 'cache_007_neg', 'cache_008_neg', - 'cache_009_pos', 'cache_010_neg', 'cache_011_pos', 'cache_012_pos'] + 'cache_009_pos', 'cache_010_pos', 'cache_011_pos', 'cache_012_pos'] tags = ['functional', 'cache'] [tests/functional/cachefile] diff --git a/tests/test-runner/bin/zts-report.py b/tests/test-runner/bin/zts-report.py index 92fc5f6d6e11..7fc84fcecf95 100755 --- a/tests/test-runner/bin/zts-report.py +++ b/tests/test-runner/bin/zts-report.py @@ -191,7 +191,6 @@ maybe = { 'alloc_class/alloc_class_012_pos': ['FAIL', '9142'], 'alloc_class/alloc_class_013_pos': ['FAIL', '9142'], - 'cache/cache_010_neg': ['FAIL', known_reason], 'chattr/setup': ['SKIP', exec_reason], 'cli_root/zdb/zdb_006_pos': ['FAIL', known_reason], 'cli_root/zfs_get/zfs_get_004_pos': ['FAIL', known_reason], diff --git a/tests/zfs-tests/tests/functional/cache/Makefile.am b/tests/zfs-tests/tests/functional/cache/Makefile.am index 406a9281709a..f28130ee9e4d 100644 --- a/tests/zfs-tests/tests/functional/cache/Makefile.am +++ b/tests/zfs-tests/tests/functional/cache/Makefile.am @@ -11,7 +11,7 @@ dist_pkgdata_SCRIPTS = \ cache_007_neg.ksh \ cache_008_neg.ksh \ cache_009_pos.ksh \ - cache_010_neg.ksh \ + cache_010_pos.ksh \ cache_011_pos.ksh \ cache_012_pos.ksh diff --git a/tests/zfs-tests/tests/functional/cache/cache_010_neg.ksh b/tests/zfs-tests/tests/functional/cache/cache_010_pos.ksh similarity index 64% rename from tests/zfs-tests/tests/functional/cache/cache_010_neg.ksh rename to tests/zfs-tests/tests/functional/cache/cache_010_pos.ksh index 1d0683b8587e..1d9fc5a8922b 100755 --- a/tests/zfs-tests/tests/functional/cache/cache_010_neg.ksh +++ b/tests/zfs-tests/tests/functional/cache/cache_010_pos.ksh @@ -34,12 +34,12 @@ # # DESCRIPTION: -# Verify cache device must be a block device. +# Verify that cache devices can be block devices, files or character devices # # STRATEGY: # 1. Create a pool # 2. Add different object as cache -# 3. Verify character devices and files fail +# 3. Verify character devices and files pass # verify_runnable "global" @@ -50,51 +50,55 @@ function cleanup_testenv if [[ -n $lofidev ]]; then if is_linux; then losetup -d $lofidev + elif is_freebsd; then + mdconfig -du ${lofidev#md} else lofiadm -d $lofidev fi fi } -log_assert "Cache device can only be block devices." +log_assert "Verify cache devices can be disk, file, lofi device or any " \ + "device that presents a block interface" + +verify_disk_count "$DISKS" 2 log_onexit cleanup_testenv TESTVOL=testvol1$$ dsk1=${DISKS%% *} log_must zpool create $TESTPOOL ${DISKS#$dsk1} -# Add nomal ${DEV_RDSKDIR} device +# Add normal ${DEV_RDSKDIR} device log_must zpool add $TESTPOOL cache \ - ${DEV_RDSKDIR}/${dsk1}${SLICE_PREFIX}${SLICE0} + ${DEV_RDSKDIR}/${dsk1} +log_must zpool remove $TESTPOOL ${DEV_RDSKDIR}/${dsk1} + + +# Add provided disk +log_must zpool add $TESTPOOL cache $dsk1 log_must verify_cache_device $TESTPOOL $dsk1 'ONLINE' +log_must zpool remove $TESTPOOL $dsk1 # Add normal file -log_mustnot zpool add $TESTPOOL cache $VDEV2 +log_must zpool add $TESTPOOL cache $VDEV +ldev=$(random_get $VDEV) +log_must verify_cache_device $TESTPOOL $ldev 'ONLINE' -# Add /dev/rlofi device (allowed under Linux) +# Add loop back device if is_linux; then lofidev=$(losetup -f) - lofidev=${lofidev##*/} log_must losetup $lofidev ${VDEV2%% *} - log_must zpool add $TESTPOOL cache $lofidev - log_must zpool remove $TESTPOOL $lofidev - log_must losetup -d $lofidev - lofidev="" + lofidev=${lofidev##*/} +elif is_freebsd; then + lofidev=$(mdconfig -a ${VDEV2%% *}) else lofidev=${VDEV2%% *} log_must lofiadm -a $lofidev lofidev=$(lofiadm $lofidev) - log_mustnot zpool add $TESTPOOL cache "/dev/rlofi/${lofidev#/dev/lofi/}" - log_must lofiadm -d $lofidev - lofidev="" fi -# Add /dev/zvol/rdsk device (allowed under Linux) -if ! is_linux; then - log_must zpool create $TESTPOOL2 $VDEV2 - log_must zfs create -V $SIZE $TESTPOOL2/$TESTVOL - log_mustnot zpool add $TESTPOOL cache \ - ${ZVOL_RDEVDIR}/$TESTPOOL2/$TESTVOL -fi +log_must zpool add $TESTPOOL cache $lofidev +log_must verify_cache_device $TESTPOOL $lofidev 'ONLINE' -log_pass "Cache device can only be block devices." +log_pass "Verify cache devices can be disk, file, lofi device or any " \ + "device that presents a block interface" diff --git a/tests/zfs-tests/tests/functional/cache/setup.ksh b/tests/zfs-tests/tests/functional/cache/setup.ksh index d5da5d9bb061..0493637fcca8 100755 --- a/tests/zfs-tests/tests/functional/cache/setup.ksh +++ b/tests/zfs-tests/tests/functional/cache/setup.ksh @@ -34,10 +34,6 @@ verify_runnable "global" -if ! is_physical_device $LDEV; then - log_unsupported "Only physical disk could be cache device" -fi - log_must rm -rf $VDIR $VDIR2 log_must mkdir -p $VDIR $VDIR2 log_must mkfile $SIZE $VDEV $VDEV2