diff options
Diffstat (limited to 'tests/zfs-tests/tests/functional/cli_user')
68 files changed, 4244 insertions, 0 deletions
diff --git a/tests/zfs-tests/tests/functional/cli_user/Makefile.am b/tests/zfs-tests/tests/functional/cli_user/Makefile.am new file mode 100644 index 000000000000..f1ff32e8d22d --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/Makefile.am @@ -0,0 +1,5 @@ +SUBDIRS = \ + misc \ + zfs_list \ + zpool_iostat \ + zpool_list diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/Makefile.am b/tests/zfs-tests/tests/functional/cli_user/misc/Makefile.am new file mode 100644 index 000000000000..dad922c6dd46 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/Makefile.am @@ -0,0 +1,46 @@ +pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_user/misc +dist_pkgdata_SCRIPTS = \ + misc.cfg \ + setup.ksh \ + cleanup.ksh \ + zdb_001_neg.ksh \ + zfs_001_neg.ksh \ + zfs_allow_001_neg.ksh \ + zfs_clone_001_neg.ksh \ + zfs_create_001_neg.ksh \ + zfs_destroy_001_neg.ksh \ + zfs_get_001_neg.ksh \ + zfs_inherit_001_neg.ksh \ + zfs_mount_001_neg.ksh \ + zfs_promote_001_neg.ksh \ + zfs_receive_001_neg.ksh \ + zfs_rename_001_neg.ksh \ + zfs_rollback_001_neg.ksh \ + zfs_send_001_neg.ksh \ + zfs_set_001_neg.ksh \ + zfs_share_001_neg.ksh \ + zfs_snapshot_001_neg.ksh \ + zfs_unallow_001_neg.ksh \ + zfs_unmount_001_neg.ksh \ + zfs_unshare_001_neg.ksh \ + zfs_upgrade_001_neg.ksh \ + zpool_001_neg.ksh \ + zpool_add_001_neg.ksh \ + zpool_attach_001_neg.ksh \ + zpool_clear_001_neg.ksh \ + zpool_create_001_neg.ksh \ + zpool_destroy_001_neg.ksh \ + zpool_detach_001_neg.ksh \ + zpool_export_001_neg.ksh \ + zpool_get_001_neg.ksh \ + zpool_history_001_neg.ksh \ + zpool_import_001_neg.ksh \ + zpool_import_002_neg.ksh \ + zpool_offline_001_neg.ksh \ + zpool_online_001_neg.ksh \ + zpool_remove_001_neg.ksh \ + zpool_replace_001_neg.ksh \ + zpool_scrub_001_neg.ksh \ + zpool_set_001_neg.ksh \ + zpool_status_001_neg.ksh \ + zpool_upgrade_001_neg.ksh diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/cleanup.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/cleanup.ksh new file mode 100755 index 000000000000..77090baafbf3 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/cleanup.ksh @@ -0,0 +1,50 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2008 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013 by Delphix. All rights reserved. +# + +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg +. $STF_SUITE/include/libtest.shlib + +if poolexists $TESTPOOL.virt +then + log_must $ZPOOL destroy $TESTPOOL.virt +fi + +if poolexists v1-pool +then + log_must $ZPOOL destroy v1-pool +fi + +if [[ -f /tmp/zfstest_datastream.dat ]] +then + log_must $RM -f /tmp/zfstest_datastream.dat +fi + +default_cleanup diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/misc.cfg b/tests/zfs-tests/tests/functional/cli_user/misc/misc.cfg new file mode 100644 index 000000000000..55d38e824f9b --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/misc.cfg @@ -0,0 +1,71 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013 by Delphix. All rights reserved. +# + +# these are the set of setable ZFS properties +PROP_NAMES="\ + aclinherit aclmode atime \ + checksum compression devices \ + exec mountpoint quota readonly \ + recordsize reservation setuid sharenfs \ + snapdir" + +# these are a set of values we apply, for use when testing the +# zfs get/set subcommands - ordered as per the list above so we +# can iterate over both sets in an array +PROP_VALS="\ + secure discard on \ + fletcher2 on on \ + on legacy none on \ + 128k none on on \ + visible" + +# these are an alternate set of property values +PROP_ALTVALS="\ + noallow groupmask off \ + fletcher4 lzjb off \ + off /tmp/zfstest 100m off \ + 512 10m off off \ + hidden" + + + +# additional properties to worry about: canmount copies xattr zoned version + +POOL_PROPS="\ + failmode autoreplace" + +POOL_VALS="\ + continue on" + +POOL_ALTVALS="\ + panic off" + +export TESTSNAP=testsnap-misc +export TESTCLCT=testclct-misc diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/setup.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/setup.ksh new file mode 100755 index 000000000000..e651acb03102 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/setup.ksh @@ -0,0 +1,161 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2008 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013 by Delphix. All rights reserved. +# + +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg +. $STF_SUITE/include/libtest.shlib + +# This setup script is moderately complex, as it creates scenarios for all +# of the tests included in this directory. Usually we'd want each test case +# to setup/teardown it's own configuration, but this would be time consuming +# given the nature of these tests. However, as a side-effect, one test +# leaving the system in an unknown state could impact other test cases. + + +DISK=${DISKS%% *} +VOLSIZE=150m +TESTVOL=testvol + +# Create a default setup that includes a volume +default_setup_noexit "$DISK" "" "volume" + +# +# The rest of this setup script creates a ZFS filesystem configuration +# that is used to test the rest of the zfs subcommands in this directory. +# + +# create a snapshot and a clone to test clone promote +log_must $ZFS snapshot $TESTPOOL/$TESTFS@snap +log_must $ZFS clone $TESTPOOL/$TESTFS@snap $TESTPOOL/$TESTFS/clone +# create a file in the filesystem that isn't in the above snapshot +$TOUCH /$TESTDIR/file.txt + + +# create a non-default property and a child we can use to test inherit +log_must $ZFS create $TESTPOOL/$TESTFS/$TESTFS2 +log_must $ZFS set snapdir=hidden $TESTPOOL/$TESTFS + + +# create an unmounted filesystem to test unmount +log_must $ZFS create $TESTPOOL/$TESTFS/$TESTFS2.unmounted +log_must $ZFS unmount $TESTPOOL/$TESTFS/$TESTFS2.unmounted + + +# send our snapshot to a known file in /tmp +$ZFS send $TESTPOOL/$TESTFS@snap > /tmp/zfstest_datastream.dat +if [ ! -s /tmp/zfstest_datastream.dat ] +then + log_fail "ZFS send datafile was not created!" +fi +log_must $CHMOD 644 /tmp/zfstest_datastream.dat + + +# create a filesystem that has particular properties to test set/get +log_must $ZFS create -o version=1 $TESTPOOL/$TESTFS/prop +set -A props $PROP_NAMES +set -A prop_vals $PROP_VALS +typeset -i i=0 + +while [[ $i -lt ${#props[*]} ]] +do + prop_name=${props[$i]} + prop_val=${prop_vals[$i]} + log_must $ZFS set $prop_name=$prop_val $TESTPOOL/$TESTFS/prop + i=$(( $i + 1 )) +done + +# create a filesystem we don't mind renaming +log_must $ZFS create $TESTPOOL/$TESTFS/renameme + + +if is_global_zone +then + # create a filesystem we can share + log_must $ZFS create $TESTPOOL/$TESTFS/unshared + log_must $ZFS set sharenfs=off $TESTPOOL/$TESTFS/unshared + + # create a filesystem that we can unshare + log_must $ZFS create $TESTPOOL/$TESTFS/shared + log_must $ZFS set sharenfs=on $TESTPOOL/$TESTFS/shared +fi + + +log_must $ZFS create -o version=1 $TESTPOOL/$TESTFS/version1 +log_must $ZFS create -o version=1 $TESTPOOL/$TESTFS/allowed +log_must $ZFS allow everyone create $TESTPOOL/$TESTFS/allowed + +if is_global_zone +then + + # Now create several virtual disks to test zpool with + + $MKFILE 100m /$TESTDIR/disk1.dat + $MKFILE 100m /$TESTDIR/disk2.dat + $MKFILE 100m /$TESTDIR/disk3.dat + $MKFILE 100m /$TESTDIR/disk-additional.dat + $MKFILE 100m /$TESTDIR/disk-export.dat + $MKFILE 100m /$TESTDIR/disk-offline.dat + $MKFILE 100m /$TESTDIR/disk-spare1.dat + $MKFILE 100m /$TESTDIR/disk-spare2.dat + + # and create a pool we can perform attach remove replace, + # etc. operations with + log_must $ZPOOL create $TESTPOOL.virt mirror /$TESTDIR/disk1.dat \ + /$TESTDIR/disk2.dat /$TESTDIR/disk3.dat /$TESTDIR/disk-offline.dat \ + spare /$TESTDIR/disk-spare1.dat + + + # Offline one of the disks to test online + log_must $ZPOOL offline $TESTPOOL.virt /$TESTDIR/disk-offline.dat + + + # create an exported pool to test import + log_must $ZPOOL create $TESTPOOL.exported /$TESTDIR/disk-export.dat + log_must $ZPOOL export $TESTPOOL.exported + + set -A props $POOL_PROPS + set -A prop_vals $POOL_VALS + typeset -i i=0 + + while [[ $i -lt ${#props[*]} ]] + do + prop_name=${props[$i]} + prop_val=${prop_vals[$i]} + log_must $ZPOOL set $prop_name=$prop_val $TESTPOOL + i=$(( $i + 1 )) + done + + # copy a v1 pool from cli_root + $CP $STF_SUITE/tests/functional/cli_root/zpool_upgrade/blockfiles/zfs-pool-v1.dat.bz2 \ + /$TESTDIR + log_must $BUNZIP2 /$TESTDIR/zfs-pool-v1.dat.bz2 + log_must $ZPOOL import -d /$TESTDIR v1-pool +fi +log_pass diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zdb_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zdb_001_neg.ksh new file mode 100755 index 000000000000..876f1e0d2625 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zdb_001_neg.ksh @@ -0,0 +1,82 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013 by Delphix. All rights reserved. +# + +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg +. $STF_SUITE/include/libtest.shlib + +# +# DESCRIPTION: +# +# zdb can't run as a user on datasets, but can run without arguments +# +# STRATEGY: +# 1. Run zdb as a user, it should print information +# 2. Run zdb as a user on different datasets, it should fail +# + +function check_zdb +{ + $@ > /tmp/zdb.$$ + $GREP "Dataset mos" /tmp/zdb.$$ + if [ $? -eq 0 ] + then + log_fail "$@ exited 0 when run as a non root user!" + fi + $RM /tmp/zdb.$$ +} + + +function cleanup +{ + if [ -e /tmp/zdb_001_neg.$$.txt ] + then + $RM /tmp/zdb_001_neg.$$.txt + fi + +} + +verify_runnable "global" + +log_assert "zdb can't run as a user on datasets, but can run without arguments" +log_onexit cleanup + +log_must eval "$ZDB > /tmp/zdb_001_neg.$$.txt" +# verify the output looks okay +log_must $GREP pool_guid /tmp/zdb_001_neg.$$.txt +log_must $RM /tmp/zdb_001_neg.$$.txt + +# we shouldn't able to run it on any dataset +check_zdb $ZDB $TESTPOOL +check_zdb $ZDB $TESTPOOL/$TESTFS +check_zdb $ZDB $TESTPOOL/$TESTFS@snap +check_zdb $ZDB $TESTPOOL/$TESTFS.clone + +log_pass "zdb can't run as a user on datasets, but can run without arguments" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zfs_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_001_neg.ksh new file mode 100755 index 000000000000..5edf7350acfc --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_001_neg.ksh @@ -0,0 +1,59 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013 by Delphix. All rights reserved. +# + +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg +. $STF_SUITE/include/libtest.shlib + +# +# DESCRIPTION: +# +# zfs shows a usage message when run as a user +# +# STRATEGY: +# 1. Run zfs as a user +# 2. Verify it produces a usage message +# + +function cleanup +{ + if [ -e /tmp/zfs_001_neg.$$.txt ] + then + $RM /tmp/zfs_001_neg.$$.txt + fi +} + +log_onexit cleanup +log_assert "zfs shows a usage message when run as a user" + +eval "$ZFS > /tmp/zfs_001_neg.$$.txt 2>&1" +log_must $GREP "usage: zfs command args" /tmp/zfs_001_neg.$$.txt + +log_pass "zfs shows a usage message when run as a user" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zfs_allow_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_allow_001_neg.ksh new file mode 100755 index 000000000000..0fb22e019714 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_allow_001_neg.ksh @@ -0,0 +1,67 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2008 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013 by Delphix. All rights reserved. +# + +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg +. $STF_SUITE/include/libtest.shlib + +# +# DESCRIPTION: +# +# zfs allow returns an error when run as a user +# +# STRATEGY: +# +# 1. Verify that trying to show allows works as a user +# 2. Verify that trying to set allows fails as a user +# +# + +# check to see if we have zfs allow +$ZFS 2>&1 | $GREP "allow" > /dev/null +if (($? != 0)) then + log_unsupported "ZFS allow not supported on this machine." +fi + +log_assert "zfs allow returns an error when run as a user" + +log_must $ZFS allow $TESTPOOL/$TESTFS +log_mustnot $ZFS allow $($LOGNAME) create $TESTPOOL/$TESTFS + +# now verify that the above command actually did nothing by +# checking for any allow output. ( if no allows are granted, +# nothing should be output ) +OUTPUT=$($ZFS allow $TESTPOOL/$TESTFS | $GREP "Local+Descendent" ) +if [ -n "$OUTPUT" ] +then + log_fail "zfs allow permissions were granted on $TESTPOOL/$TESTFS" +fi + +log_pass "zfs allow returns an error when run as a user" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zfs_clone_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_clone_001_neg.ksh new file mode 100755 index 000000000000..406f91305125 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_clone_001_neg.ksh @@ -0,0 +1,54 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013 by Delphix. All rights reserved. +# + +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg +. $STF_SUITE/include/libtest.shlib + +# +# DESCRIPTION: +# +# zfs clone returns an error when run as a user +# +# STRATEGY: +# +# 1. Verify that we're unable to clone snapshots as a user +# +# + +log_assert "zfs clone returns an error when run as a user" +log_mustnot $ZFS clone $TESTPOOL/$TESTFS@snap $TESTPOOL/$TESTFS.myclone + +# check to see that the above command really did nothing +if datasetexists $TESTPOOL/$TESTFS.myclone +then + log_fail "Dataset $TESTPOOL/$TESTFS.myclone should not exist!" +fi +log_pass "zfs clone returns an error when run as a user" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zfs_create_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_create_001_neg.ksh new file mode 100755 index 000000000000..579771e84009 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_create_001_neg.ksh @@ -0,0 +1,61 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013 by Delphix. All rights reserved. +# + +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg +. $STF_SUITE/include/libtest.shlib + +# +# DESCRIPTION: +# Executing various badly formed 'zfs create' should fail. +# +# STRATEGY: +# 1. Create an array of badly formed sub-commands. +# 2. Execute each element of the array. +# 3. Verify an error code is returned. +# + +verify_runnable "both" + + +set -A args "" "create $TESTPOOL/$TESTFS" \ + "create $TESTPOOL/$TESTFS@$TESTSNAP" \ + "create $TESTPOOL/$TESTCLCT/$TESTFS" \ + "create $TESTFS/$TESTPOOL/$TESTCLCT" + +log_assert "Verify zfs create without parameters fails." + +typeset -i i=0 +while [[ $i -lt ${#args[*]} ]]; do + log_mustnot $ZFS ${args[i]} + ((i = i + 1)) +done + +log_pass "The sub-command 'create' fails as non-root." diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zfs_destroy_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_destroy_001_neg.ksh new file mode 100755 index 000000000000..d7a23acedf60 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_destroy_001_neg.ksh @@ -0,0 +1,67 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013 by Delphix. All rights reserved. +# + +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg +. $STF_SUITE/include/libtest.shlib + +# +# DESCRIPTION: +# Verify that 'zfs destroy' fails as non-root. +# +# STRATEGY: +# 1. Create an array of options. +# 2. Execute each element of the array. +# 3. Verify an error code is returned. +# + +verify_runnable "both" + + +set -A args "destroy" "destroy $TESTPOOL/$TESTFS" \ + "destroy -f" "destroy -f $TESTPOOL/$TESTFS" \ + "destroy -r" "destroy -r $TESTPOOL/$TESTFS" \ + "destroy -rf $TESTPOOL/$TESTFS" \ + "destroy -fr $TESTPOOL/$TESTFS" \ + "destroy $TESTPOOL/$TESTFS@$TESTSNAP" \ + "destroy -f $TESTPOOL/$TESTFS@$TESTSNAP" \ + "destroy -r $TESTPOOL/$TESTFS@$TESTSNAP" \ + "destroy -rf $TESTPOOL/$TESTFS@$TESTSNAP" \ + "destroy -fr $TESTPOOL/$TESTFS@$TESTSNAP" + +log_assert "zfs destroy [-f|-r] [fs|snap]" + +typeset -i i=0 +while [[ $i -lt ${#args[*]} ]]; do + log_mustnot $ZFS ${args[i]} + ((i = i + 1)) +done + +log_pass "The sub-command 'destroy' fails as non-root." diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zfs_get_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_get_001_neg.ksh new file mode 100755 index 000000000000..70b468117b47 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_get_001_neg.ksh @@ -0,0 +1,65 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013 by Delphix. All rights reserved. +# + +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg +. $STF_SUITE/include/libtest.shlib + +# +# DESCRIPTION: +# +# zfs get works when run as a user +# +# STRATEGY: +# 1. Run zfs get with an array of different arguments +# 2. Verify for each property, we get the value that's expected +# +# + +log_assert "zfs get works when run as a user" + +typeset -i i=0 + +set -A props $PROP_NAMES +set -A prop_vals $PROP_VALS + +while [[ $i -lt ${#args[*]} ]] +do + PROP=${props[$i]} + EXPECTED=${prop_vals[$i]} + ACTUAL=$( $ZFS get $PROP -o value -H snapdir $TESTPOOl/$TESTFS/prop ) + if [ "$ACTUAL" != "$EXPECTED" ] + then + log_fail "Property $PROP value was $ACTUAL, expected $EXPECTED" + fi + i=$(( $i + 1 )) +done + +log_pass "zfs get works when run as a user" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zfs_inherit_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_inherit_001_neg.ksh new file mode 100755 index 000000000000..d68cec6e5b45 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_inherit_001_neg.ksh @@ -0,0 +1,56 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013 by Delphix. All rights reserved. +# + +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg +. $STF_SUITE/include/libtest.shlib + +# +# DESCRIPTION: +# +# zfs inherit returns an error when run as a user +# +# STRATEGY: +# +# 1. Verify that we can't inherit a property when running as a user +# +# + +log_assert "zfs inherit returns an error when run as a user" +log_mustnot $ZFS inherit snapdir $TESTPOOL/$TESTFS/$TESTFS2 + +# check to see that the above command really did nothing +PROP=$($ZFS get snapdir $TESTPOOL/$TESTFS) +if [ "$PROP" = "visible" ] +then + log_fail "snapdir property inherited from the $TESTPOOL/$TESTFS!" +fi + +log_pass "zfs inherit returns an error when run as a user" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zfs_mount_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_mount_001_neg.ksh new file mode 100755 index 000000000000..ecf356228c13 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_mount_001_neg.ksh @@ -0,0 +1,57 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013 by Delphix. All rights reserved. +# + +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg +. $STF_SUITE/include/libtest.shlib + +# +# DESCRIPTION: +# +# zfs mount returns an error when run as a user +# +# STRATEGY: +# +# 1. Verify that we can't mount the unmounted filesystem created in setup +# +# + +log_assert "zfs mount returns an error when run as a user" + +log_mustnot $ZFS mount $TESTPOOL/$TESTFS/$TESTFS2.unmounted + +# now verify that the above command didn't do anything +MOUNTED=$($MOUNT | $GREP $TESTPOOL/$TESTFS/$TESTFS2.unmounted) +if [ -n "$MOUNTED" ] +then + log_fail "Filesystem $TESTPOOL/$TESTFS/$TESTFS2.unmounted was mounted!" +fi + +log_pass "zfs mount returns an error when run as a user" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zfs_promote_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_promote_001_neg.ksh new file mode 100755 index 000000000000..579ee9377635 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_promote_001_neg.ksh @@ -0,0 +1,56 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013 by Delphix. All rights reserved. +# + +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg +. $STF_SUITE/include/libtest.shlib + +# +# DESCRIPTION: +# +# zfs promote returns an error when run as a user +# +# STRATEGY: +# +# 1. Verify we don't have permissions to promote a clone +# +# + +log_assert "zfs promote returns an error when run as a user" + +log_mustnot $ZFS promote $TESTPOOL/$TESTFS/clone + +# Now verify that the above command didn't do anything +if datasetexists $TESTPOOL/$TESTFS/clone@snap +then + log_fail "Clone $TESTPOOl/$TESTFS/clone was actually promoted!" +fi + +log_pass "zfs promote returns an error when run as a user" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zfs_receive_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_receive_001_neg.ksh new file mode 100755 index 000000000000..7ea4a47971dd --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_receive_001_neg.ksh @@ -0,0 +1,58 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013 by Delphix. All rights reserved. +# + +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg +. $STF_SUITE/include/libtest.shlib + +# +# DESCRIPTION: +# +# zfs receive returns an error when run as a user +# +# STRATEGY: +# +# 1. Attempt to receive a datastream as a user +# 2. Verify that the dataset wasn't created +# + +log_assert "zfs receive returns an error when run as a user" + +log_mustnot eval "$ZFS receive -d $TESTPOOL/$TESTFS/$TESTFS2 \ + < /tmp/zfstest_datastream.dat" + +# verify that command actually did nothing + +if datasetexists $TESTPOOL/$TESTFS/$TESTFS2/$TESTFS +then + log_fail "$TESTPOOL/$TESTFS/$TESTFS2/$TESTFS was received!" +fi + +log_pass "zfs receive returns an error when run as a user" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zfs_rename_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_rename_001_neg.ksh new file mode 100755 index 000000000000..20b017fb0e65 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_rename_001_neg.ksh @@ -0,0 +1,56 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013 by Delphix. All rights reserved. +# + +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg +. $STF_SUITE/include/libtest.shlib + +# +# DESCRIPTION: +# +# zfs rename returns an error when run as a user +# +# STRATEGY: +# 1. Attempt to rename a dataset +# 2. Verify that the renamed dataset does not exist. +# +# + +log_assert "zfs rename returns an error when run as a user" + +log_mustnot $ZFS rename $TESTPOOL/$TESTFS/renameme $TESTPOOL/$TESTFS/renameme1 + +# now verify the above command didn't actually do anything +if datasetexists $TESTPOOL/$TESTFS/renameme1 +then + log_fail "The dataset $TESTPOOL/$TESTFS/renameme was renamed!" +fi + +log_pass "zfs rename returns an error when run as a user" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zfs_rollback_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_rollback_001_neg.ksh new file mode 100755 index 000000000000..ecc95c1313ff --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_rollback_001_neg.ksh @@ -0,0 +1,60 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013 by Delphix. All rights reserved. +# + +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg +. $STF_SUITE/include/libtest.shlib + +# +# DESCRIPTION: +# +# zfs rollback returns an error when run as a user +# +# STRATEGY: +# 1. Attempt to rollback a snapshot +# 2. Verify that a file which doesn't exist in the snapshot still exists +# (showing the snapshot rollback failed) +# +# + +log_assert "zfs rollback returns an error when run as a user" + +log_mustnot $ZFS rollback $TESTPOOL/$TESTFS@snap + +# now verify the above command didn't actually do anything + +# in the above filesystem there's a file that should not exist once +# the snapshot is rolled back - we check for it +if [ ! -e /$TESTDIR/file.txt ] +then + log_fail "Rollback of snapshot $TESTPOOL/$TESTFS@snap succeeded!" +fi + +log_pass "zfs rollback returns an error when run as a user" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zfs_send_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_send_001_neg.ksh new file mode 100755 index 000000000000..0b92ed355b13 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_send_001_neg.ksh @@ -0,0 +1,67 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013 by Delphix. All rights reserved. +# + +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg +. $STF_SUITE/include/libtest.shlib + +# +# DESCRIPTION: +# +# zfs send returns an error when run as a user +# +# STRATEGY: +# 1. Attempt to send a dataset to a file +# 2. Verify the file created has zero-size +# +# + +function cleanup +{ + if [ -e /tmp/zfstest_datastream.$$ ] + then + log_must $RM /tmp/zfstest_datastream.$$ + fi +} + +log_assert "zfs send returns an error when run as a user" +log_onexit cleanup + +log_mustnot eval "$ZFS send $TESTPOOL/$TESTFS@snap > /tmp/zfstest_datastream.$$" + +# Now check that the above command actually did nothing + +# We should have a non-zero-length file in /tmp +if [ -s /tmp/zfstest_datastream.$$ ] +then + log_fail "A zfs send file was created in /tmp/zfstest_datastream.$$ !" +fi + +log_pass "zfs send returns an error when run as a user" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zfs_set_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_set_001_neg.ksh new file mode 100755 index 000000000000..1f1a8bdc5f48 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_set_001_neg.ksh @@ -0,0 +1,70 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013 by Delphix. All rights reserved. +# + +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg +. $STF_SUITE/include/libtest.shlib + +# +# DESCRIPTION: +# +# zfs set returns an error when run as a user +# +# STRATEGY: +# 1. Attempt to set an array of properties on a dataset +# 2. Verify that those properties were not set and retain their original values. +# +# + +log_assert "zfs set returns an error when run as a user" + +typeset -i i=0 + +set -A props $PROP_NAMES +set -A prop_vals $PROP_VALS +set -A prop_new $PROP_ALTVALS + +while [[ $i -lt ${#args[*]} ]] +do + PROP=${props[$i]} + EXPECTED=${prop_vals[$i]} + NEW=${prop_new[$i]} + log_mustnot $ZFS set $PROP=$NEW $TESTPOOL/$TESTFS/prop + + # Now verify that the above command did nothing + ACTUAL=$($ZFS get $PROP -o value -H snapdir $TESTPOOl/$TESTFS/prop ) + if [ "$ACTUAL" != "$EXPECTED" ] + then + log_fail "Property $PROP was set to $ACTUAL, expected $EXPECTED" + fi + i=$(( $i + 1 )) +done + +log_pass "zfs set returns an error when run as a user" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zfs_share_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_share_001_neg.ksh new file mode 100755 index 000000000000..0f45f507f5a2 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_share_001_neg.ksh @@ -0,0 +1,63 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2008 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013 by Delphix. All rights reserved. +# + +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg +. $STF_SUITE/include/libtest.shlib + +# +# DESCRIPTION: +# +# zfs share returns an error when run as a user +# +# STRATEGY: +# 1. Attempt to share a dataset +# 2. Verify the dataset was not shared. +# +# + +verify_runnable "global" + +log_assert "zfs share returns an error when run as a user" + +if is_shared $TESTDIR/unshared +then + log_fail "$TESTPOOL/$TESTFS/unshared was incorrectly shared initially!" +fi + +log_mustnot $ZFS share $TESTPOOL/$TESTFS/unshared + +# Now verify that the above command didn't actually do anything +if is_shared $TESTDIR/unshared +then + log_fail "$TESTPOOL/$TESTFS/unshared was actually shared!" +fi + +log_pass "zfs share returns an error when run as a user" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zfs_snapshot_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_snapshot_001_neg.ksh new file mode 100755 index 000000000000..f473c5e83ce7 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_snapshot_001_neg.ksh @@ -0,0 +1,56 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013 by Delphix. All rights reserved. +# + +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg +. $STF_SUITE/include/libtest.shlib + +# +# DESCRIPTION: +# +# zfs snapshot returns an error when run as a user +# +# STRATEGY: +# 1. Attempt to snapshot a dataset +# 2. Verify the snapshot wasn't taken +# +# + +log_assert "zfs snapshot returns an error when run as a user" + +log_mustnot $ZFS snapshot $TESTPOOL/$TESTFS@usersnap1 + +# Now verify that the above command didn't actually do anything +if datasetexists $TESTPOOL/$TESTFS@usersnap1 +then + log_fail "Snapshot $TESTPOOL/$TESTFS@usersnap1 was taken !" +fi + +log_pass "zfs snapshot returns an error when run as a user" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zfs_unallow_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_unallow_001_neg.ksh new file mode 100755 index 000000000000..84dc9387085e --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_unallow_001_neg.ksh @@ -0,0 +1,64 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2008 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013 by Delphix. All rights reserved. +# + +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg +. $STF_SUITE/include/libtest.shlib + +# +# DESCRIPTION: +# +# zfs unallow returns an error when run as a user +# +# STRATEGY: +# 1. Attempt to unallow a set of permissions +# 2. Verify the unallow wasn't performed +# +# + +# check to see if we have zfs unallow +$ZFS 2>&1 | $GREP "unallow" > /dev/null +if (($? != 0)) then + log_unsupported "ZFS unallow not supported on this machine." +fi + +log_assert "zfs unallow returns an error when run as a user" + +log_mustnot $ZFS unallow everyone $TESTPOOL/$TESTFS/allowed + +# now check with zfs allow to see if the permissions are still there +OUTPUT=$($ZFS allow $TESTPOOL/$TESTFS/allowed | $GREP "Local+Descendent" ) +if [ -z "$OUTPUT" ] +then + log_fail "Error - create permissions were unallowed on \ + $TESTPOOL/$TESTFS/allowed" +fi + +log_pass "zfs unallow returns an error when run as a user" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zfs_unmount_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_unmount_001_neg.ksh new file mode 100755 index 000000000000..22a3d75e0797 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_unmount_001_neg.ksh @@ -0,0 +1,65 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013 by Delphix. All rights reserved. +# + +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg +. $STF_SUITE/include/libtest.shlib + +# +# DESCRIPTION: +# Verify that 'zfs umount' and its variants fail as non-root. +# +# STRATEGY: +# 1. Create an array of options. +# 2. Execute each element of the array. +# 3. Verify that the commands fail with an error code. +# + +verify_runnable "both" + +set -A args "umount" "umount -f" "unmount" "unmount -f" \ + "umount $TESTPOOL/$TESTFS" "umount -f $TESTPOOL/$TESTFS" \ + "unmount $TESTPOOL/$TESTFS" "unmount -f $TESTPOOL/$TESTFS" \ + "umount $TESTPOOL/$TESTFS@$TESTSNAP" \ + "umount -f $TESTPOOL/$TESTFS@$TESTSNAP" \ + "unmount $TESTPOOL/$TESTFS@$TESTSNAP" \ + "unmount -f $TESTPOOL/$TESTFS@$TESTSNAP" \ + "umount $TESTDIR" "umount -f $TESTDIR" \ + "unmount $TESTDIR" "unmount -f $TESTDIR" + +log_assert "zfs u[n]mount [-f] [mountpoint|fs|snap]" + +typeset -i i=0 +while [[ $i -lt ${#args[*]} ]]; do + log_mustnot $ZFS ${args[i]} + ((i = i + 1)) +done + +log_pass "The sub-command 'u[n]mount' fails as non-root." diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zfs_unshare_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_unshare_001_neg.ksh new file mode 100755 index 000000000000..069279cad84d --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_unshare_001_neg.ksh @@ -0,0 +1,64 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2008 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013 by Delphix. All rights reserved. +# + +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg +. $STF_SUITE/include/libtest.shlib + +# +# DESCRIPTION: +# +# zfs unshare returns an error when run as a user +# +# STRATEGY: +# 1. Attempt to unshare a shared dataset +# 2. Verify the dataset is still shared +# +# + +verify_runnable "global" + +log_assert "zfs unshare returns an error when run as a user" + +# verify that the filesystem was shared initially +if not_shared $TESTDIR/shared +then + log_fail "$TESTPOOL/$TESTFS/shared was not shared initially at all!" +fi + +log_mustnot $ZFS unshare $TESTPOOL/$TESTFS/shared + +# now verify that the above command didn't do anything +if not_shared $TESTDIR/shared +then + log_fail "$TESTPOOL/$TESTFS/shared was actually unshared!" +fi + +log_pass "zfs unshare returns an error when run as a user" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zfs_upgrade_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_upgrade_001_neg.ksh new file mode 100755 index 000000000000..0053871dc288 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_upgrade_001_neg.ksh @@ -0,0 +1,67 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013 by Delphix. All rights reserved. +# + +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg +. $STF_SUITE/include/libtest.shlib + +# +# DESCRIPTION: +# +# zfs upgrade returns an error when run as a user +# +# STRATEGY: +# 1. Attempt to upgrade a version1 dataset +# 2. Verify the dataset wasn't upgraded +# +# + +# check to see if we have upgrade capability +$ZFS upgrade > /dev/null 2>&1 +HAS_UPGRADE=$? +if [ $HAS_UPGRADE -ne 0 ] +then + log_unsupported "Zfs upgrade not supported" +fi + +log_assert "zfs upgrade returns an error when run as a user" + + +log_mustnot $ZFS upgrade $TESTPOOL/$TESTFS/version1 + +# now check to see the above command didn't do anything +VERSION=$($ZFS upgrade $TESTPOOL/$TESTFS/version1 2>&1 \ + | $GREP "already at this version") +if [ -n "$VERSION" ] +then + log_fail "A filesystem was upgraded!" +fi + +log_pass "zfs upgrade returns an error when run as a user" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zpool_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_001_neg.ksh new file mode 100755 index 000000000000..447fc9705b87 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_001_neg.ksh @@ -0,0 +1,60 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013 by Delphix. All rights reserved. +# + +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg +. $STF_SUITE/include/libtest.shlib + +# +# DESCRIPTION: +# +# zpool shows a usage message when run as a user +# +# STRATEGY: +# 1. Run the zpool command +# 2. Verify that a usage message is produced +# +# + +function cleanup +{ + if [ -e /tmp/zpool_001_neg.$$.txt ] + then + $RM /tmp/zpool_001_neg.$$.txt + fi +} + +log_onexit cleanup +log_assert "zpool shows a usage message when run as a user" + +eval "$ZPOOL > /tmp/zpool_001_neg.$$.txt 2>&1" +log_must $GREP "usage: zpool command args" /tmp/zpool_001_neg.$$.txt + +log_pass "zpool shows a usage message when run as a user" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zpool_add_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_add_001_neg.ksh new file mode 100755 index 000000000000..d02dd0b9e3bf --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_add_001_neg.ksh @@ -0,0 +1,69 @@ +#!/bin/ksh -p + +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2009 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013 by Delphix. All rights reserved. +# + +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg +. $STF_SUITE/include/libtest.shlib + +# +# DESCRIPTION: +# Verify that 'zpool add' fails as non-root. +# +# STRATEGY: +# 1. Create an array of options. +# 2. Execute each element of the array. +# 3. Verify that an error is returned. +# + +verify_runnable "global" + +ADD_DISK="${DISKS%% }" +ADD_DISK="${ADD_DISK##* }" + +[[ -z $ADD_DISK ]] && \ + log_fail "No spare disks available." + +set -A args "add" "add -f" "add -n" \ + "add $TESTPOOL" "add -f $TESTPOOL" "add -n $TESTPOOL" \ + "add -fn $TESTPOOL" "add -nf $TESTPOOL" \ + "add $TESTPOOL $ADD_DISK" "add -f $TESTPOOL $ADD_DISK" \ + "add -n $TESTPOOL $ADD_DISK" \ + "add -fn $TESTPOOL $ADD_DISK" \ + "add -nf $TESTPOOL $ADD_DISK" \ + +log_assert "zpool add [-fn] pool_name vdev" + +typeset -i i=0 +while [[ $i -lt ${#args[*]} ]]; do + log_mustnot $ZPOOL ${args[i]} + ((i = i + 1)) +done + +log_pass "The sub-command 'add' and its options fail as non-root." diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zpool_attach_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_attach_001_neg.ksh new file mode 100755 index 000000000000..59254ea459ae --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_attach_001_neg.ksh @@ -0,0 +1,67 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013 by Delphix. All rights reserved. +# + +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg +. $STF_SUITE/include/libtest.shlib + +# +# DESCRIPTION: +# +# zpool attach returns an error when run as a user +# +# STRATEGY: +# 1. Attempt to attach a disk to a pool +# 2.Verify that the attach failed +# +# + +function check_for_attach +{ + RESULT=$($ZPOOL status -v $TESTPOOL.virt | $GREP disk-additional.dat) + if [ -n "$RESULT" ] + then + log_fail "A disk was attached to the pool!" + fi +} + +verify_runnable "global" + +log_assert "zpool attach returns an error when run as a user" + +log_mustnot $ZPOOL attach $TESTPOOL.virt /$TESTDIR/disk1.dat \ + /$TESTDIR/disk-additional.dat +check_for_attach + +log_mustnot $ZPOOL attach -f $TESTPOOL.virt /$TESTDIR/disk1.dat \ + /$TESTDIR/disk-additional.dat +check_for_attach + +log_pass "zpool attach returns an error when run as a user" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zpool_clear_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_clear_001_neg.ksh new file mode 100755 index 000000000000..0a6bb8c0b370 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_clear_001_neg.ksh @@ -0,0 +1,52 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013 by Delphix. All rights reserved. +# + +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg +. $STF_SUITE/include/libtest.shlib + +# +# DESCRIPTION: +# +# zpool clear returns an error when run as a user +# +# STRATEGY: +# +# 1. Attempt to clear errors on a zpool +# 2. Verify that the command fails +# + +verify_runnable "global" + +log_assert "zpool clear returns an error when run as a user" + +log_mustnot $ZPOOL clear $TESTPOOL + +log_pass "zpool clear returns an error when run as a user" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zpool_create_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_create_001_neg.ksh new file mode 100755 index 000000000000..f77df30a0918 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_create_001_neg.ksh @@ -0,0 +1,69 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2009 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013 by Delphix. All rights reserved. +# + +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg +. $STF_SUITE/include/libtest.shlib + +# +# DESCRIPTION: +# Verify that 'zpool create' fails as a non-root user. +# +# STRATEGY: +# 1. Create an array of options. +# 2. Execute each element of the array. +# 3. Verify that an error is returned. +# + +verify_runnable "global" + +ADD_DISK="${DISKS%% }" +ADD_DISK="${ADD_DISK##* }" + +[[ -z $ADD_DISK ]] && \ + log_fail "No spare disks available." + +set -A args "create" "create -f" "create -n" \ + "create $TESTPOOL" "create -f $TESTPOOL" "create -n $TESTPOOL" \ + "create -fn $TESTPOOL" "create -nf $TESTPOOL" \ + "create $TESTPOOL $ADD_DISK" "create -f $TESTPOOL $ADD_DISK" \ + "create -n $TESTPOOL $ADD_DISK" \ + "create -fn $TESTPOOL $ADD_DISK" \ + "create -nf $TESTPOOL $ADD_DISK" + +log_assert "zpool create [-fn] pool_name vdev" + +typeset -i i=0 +while [[ $i -lt ${#args[*]} ]]; do + log_mustnot $ZPOOL ${args[i]} + ((i = i + 1)) +done + +log_pass "The sub-command 'create' and its options fail as non-root." diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zpool_destroy_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_destroy_001_neg.ksh new file mode 100755 index 000000000000..8d28f7093591 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_destroy_001_neg.ksh @@ -0,0 +1,59 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013 by Delphix. All rights reserved. +# + +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg +. $STF_SUITE/include/libtest.shlib + +# +# DESCRIPTION: +# Verify that 'zpool destroy' fails as non-root. +# +# STRATEGY: +# 1. Create an array of options. +# 2. Execute each element of the array. +# 3. Verify an error is returned. +# + +verify_runnable "global" + +set -A args "destroy" "destroy -f" \ + "destroy $TESTPOOL" "destroy -f $TESTPOOL" \ + "destroy $TESTPOOL $TESTPOOL" + +log_assert "zpool destroy [-f] [pool_name ...]" + +typeset -i i=0 +while [[ $i -lt ${#args[*]} ]]; do + log_mustnot $ZPOOL ${args[i]} + ((i = i + 1)) +done + +log_pass "The sub-command 'destroy' and its options fail as non-root." diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zpool_detach_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_detach_001_neg.ksh new file mode 100755 index 000000000000..849308dd666c --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_detach_001_neg.ksh @@ -0,0 +1,58 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013 by Delphix. All rights reserved. +# + +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg +. $STF_SUITE/include/libtest.shlib + +# +# DESCRIPTION: +# +# zpool detach returns an error when run as a user +# +# STRATEGY: +# +# 1. Attempt to detach a device from a pool +# 2. Verify the command fails +# + +verify_runnable "global" + +log_assert "zpool detach returns an error when run as a user" + +log_mustnot $ZPOOL detach $TESTPOOL.virt /$TESTDIR/disk1.dat + +RESULT=$($ZPOOL status -v $TESTPOOL.virt | $GREP disk1.dat) +if [ -z "$RESULT" ] +then + log_fail "A disk was detached from the pool!" +fi + +log_pass "zpool detach returns an error when run as a user" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zpool_export_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_export_001_neg.ksh new file mode 100755 index 000000000000..6d44be7227b5 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_export_001_neg.ksh @@ -0,0 +1,65 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013 by Delphix. All rights reserved. +# + +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg +. $STF_SUITE/include/libtest.shlib + +# +# DESCRIPTION: +# +# zpool export returns an error when run as a user +# +# STRATEGY: +# 1. Attempt to export a pool +# 2. Verify the command fails +# + +function check_for_export +{ + RESULT=$($ZPOOL list | $GREP $TESTPOOL.virt ) + if [ -z "$RESULT" ] + then + log_fail "A pool was exported!" + fi + +} + +verify_runnable "global" + +log_assert "zpool export returns an error when run as a user" + +log_mustnot $ZPOOL export $TESTPOOL.virt +check_for_export + +log_mustnot $ZPOOL export -f $TESTPOOL.virt +check_for_export + +log_pass "zpool export returns an error when run as a user" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zpool_get_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_get_001_neg.ksh new file mode 100755 index 000000000000..6965a58bd577 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_get_001_neg.ksh @@ -0,0 +1,67 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2008 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013 by Delphix. All rights reserved. +# + +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg +. $STF_SUITE/include/libtest.shlib + +# +# DESCRIPTION: +# +# zpool get works when run as a user +# +# STRATEGY: +# +# 1. For each property, get that property +# 2. Verify the property was the same as that set in setup +# + +verify_runnable "global" + +log_assert "zpool get works when run as a user" + +set -A props $POOL_PROPS +set -A prop_vals $POOL_VALS + +while [[ $i -lt ${#args[*]} ]] +do + PROP=${props[$i]} + EXPECTED=${prop_vals[$i]} + ACTUAL=$( $ZPOOL get $PROP $TESTPOOL | $GREP $PROP | $AWK '{print $1}' ) + if [ "$ACTUAL" != "$EXPECTED" ] + then + log_fail "Property $PROP value was $ACTUAL, expected $EXPECTED" + fi + i=$(( $i + 1 )) +done + +log_must $ZPOOL get all $TESTPOOL + +log_pass "zpool get works when run as a user" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zpool_history_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_history_001_neg.ksh new file mode 100755 index 000000000000..b29d083ac038 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_history_001_neg.ksh @@ -0,0 +1,55 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013 by Delphix. All rights reserved. +# + +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg +. $STF_SUITE/include/libtest.shlib + +# +# DESCRIPTION: +# +# zpool history works when run as a user +# +# STRATEGY: +# 1. Attempt to get history on a test pool +# 2. Verify the command fails +# + +verify_runnable "global" + +log_assert "zpool history returns an error when run as a user" + +log_mustnot $ZPOOL history +log_mustnot $ZPOOL history $TESTPOOL +log_mustnot $ZPOOL history -i $TESTPOOL +log_mustnot $ZPOOL history -l $TESTPOOL +log_mustnot $ZPOOL history -il $TESTPOOL + +log_assert "zpool history returns an error when run as a user" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zpool_import_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_import_001_neg.ksh new file mode 100755 index 000000000000..c73c12f482c8 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_import_001_neg.ksh @@ -0,0 +1,66 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013 by Delphix. All rights reserved. +# + +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg +. $STF_SUITE/include/libtest.shlib + +# +# DESCRIPTION: +# +# zpool import returns an error when run as a user +# +# STRATEGY: +# 1. Attempt to import an exported pool +# 2. Verify the command fails +# +# + +function check_for_import +{ + RESULT=$($ZPOOL list -H -o name | $GREP $TESTPOOL.exported) + if [ -n "$RESULT" ] + then + log_fail "Pool $TESTPOOL.export was successfully imported!" + fi +} + +verify_runnable "global" + +log_assert "zpool import returns an error when run as a user" +log_mustnot $ZPOOL import + +log_mustnot $ZPOOL import -a +check_for_import + +log_mustnot $ZPOOL import -d /$TESTDIR $TESTPOOL.exported +check_for_import + +log_pass "zpool import returns an error when run as a user" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zpool_import_002_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_import_002_neg.ksh new file mode 100755 index 000000000000..011cd1c0301e --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_import_002_neg.ksh @@ -0,0 +1,64 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013 by Delphix. All rights reserved. +# + +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg +. $STF_SUITE/include/libtest.shlib + +# +# DESCRIPTION: +# Executing 'zpool import' as regular user should denied. +# +# STRATEGY: +# 1. Create an array of options try to detect exported/destroyed pools. +# 2. Execute 'zpool import' with each element of the array by regular user. +# 3. Verify an error code is returned. +# + +verify_runnable "both" + +typeset testpool +if is_global_zone ; then + testpool=$TESTPOOL.exported +else + testpool=${TESTPOOL%%/*} +fi + +set -A args "" "-D" "-Df" "-f" "-f $TESTPOOL" "-Df $TESTPOOL" "-a" + +log_assert "Executing 'zpool import' by regular user fails" + +typeset -i i=0 +while [[ $i -lt ${#args[*]} ]]; do + log_mustnot $ZPOOL import ${args[i]} + ((i = i + 1)) +done + +log_pass "Executing 'zpool import' by regular user fails as expected." diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zpool_offline_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_offline_001_neg.ksh new file mode 100755 index 000000000000..6fa03c4272ef --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_offline_001_neg.ksh @@ -0,0 +1,66 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013 by Delphix. All rights reserved. +# + +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg +. $STF_SUITE/include/libtest.shlib + +# +# DESCRIPTION: +# +# zpool offline returns an error when run as a user +# +# STRATEGY: +# 1. Attempt to offline a device in a pool +# 2. Verify that the command fails +# +# + +function check_for_offline +{ + RESULT=$($ZPOOL status -v $TESTPOOL.virt | $GREP disk-1.dat \ + | $GREP OFFLINE ) + if [ -n "$RESULT" ] + then + log_fail "A disk was taken offline!" + fi +} + +verify_runnable "global" + +log_assert "zpool offline returns an error when run as a user" + +log_mustnot $ZPOOL offline $TESTPOOL.virt /$TESTDIR/disk-1.dat +check_for_offline + +log_mustnot $ZPOOL offline -t $TESTPOOL.virt /$TESTDIR/disk-1.dat +check_for_offline + +log_pass "zpool offline returns an error when run as a user" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zpool_online_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_online_001_neg.ksh new file mode 100755 index 000000000000..db886eb73044 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_online_001_neg.ksh @@ -0,0 +1,66 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013 by Delphix. All rights reserved. +# + +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg +. $STF_SUITE/include/libtest.shlib + +# +# DESCRIPTION: +# +# zpool online returns an error when run as a user +# +# STRATEGY: +# 1. Attempt to online a device in a pool +# 2. Verify the command fails +# +# + +function check_for_online +{ + RESULT=$($ZPOOL status -v $TESTPOOL.virt | $GREP disk-offline.dat \ + | $GREP ONLINE ) + if [ -n "$RESULT" ] + then + log_fail "A disk was brough online!" + fi +} + +verify_runnable "global" + +log_assert "zpool online returns an error when run as a user" + +log_mustnot $ZPOOL online $TESTPOOL.virt /$TESTDIR/disk-offline.dat +check_for_online + +log_mustnot $ZPOOL online -t $TESTPOOL.virt /$TESTDIR/disk-offline.dat +check_for_online + +log_pass "zpool online returns an error when run as a user" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zpool_remove_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_remove_001_neg.ksh new file mode 100755 index 000000000000..7e93bc0a4663 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_remove_001_neg.ksh @@ -0,0 +1,59 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013 by Delphix. All rights reserved. +# + +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg +. $STF_SUITE/include/libtest.shlib + +# +# DESCRIPTION: +# +# zpool remove returns an error when run as a user +# +# STRATEGY: +# 1. Attempt to remove a device from a pool +# 2. Verify the command fails +# +# + +verify_runnable "global" + +log_assert "zpool remove returns an error when run as a user" + +log_mustnot $ZPOOL remove $TESTPOOL.virt /$TESTDIR/disk-spare1.dat + +RESULT=$($ZPOOL status -v $TESTPOOL.virt | $GREP disk-spare1.dat) +if [ -z "$RESULT" ] +then + log_fail "A disk was removed from the pool!" +fi + + +log_pass "zpool remove returns an error when run as a user" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zpool_replace_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_replace_001_neg.ksh new file mode 100755 index 000000000000..12576bf03e3d --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_replace_001_neg.ksh @@ -0,0 +1,68 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013 by Delphix. All rights reserved. +# + +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg +. $STF_SUITE/include/libtest.shlib + +# +# DESCRIPTION: +# +# zpool replace returns an error when run as a user +# +# STRATEGY: +# 1. Attempt to replace a device in a pool +# 2. Verify the command fails +# +# + +function check_for_replace +{ + $SLEEP 10 + RESULT=$($ZPOOL status -v $TESTPOOL.virt | $GREP disk-additional.dat) + if [ -n "$RESULT" ] + then + log_fail "A disk was replaced in the pool!" + fi +} + +verify_runnable "global" + +log_assert "zpool replace returns an error when run as a user" + +log_mustnot $ZPOOL replace $TESTPOOL.virt /$TESTDIR/disk-1.dat \ + /$TESTDIR/disk-additional.dat +check_for_replace + +log_mustnot $ZPOOL replace -f $TESTPOOL.virt /$TESTDIR/disk-1.dat \ + /$TESTDIR/disk-additional.dat +check_for_replace + +log_pass "zpool replace returns an error when run as a user" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zpool_scrub_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_scrub_001_neg.ksh new file mode 100755 index 000000000000..abbdcd6ca201 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_scrub_001_neg.ksh @@ -0,0 +1,53 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013 by Delphix. All rights reserved. +# + +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg +. $STF_SUITE/include/libtest.shlib + +# +# DESCRIPTION: +# +# zpool scrub returns an error when run as a user +# +# STRATEGY: +# 1. Attempt to start a scrub on a pool +# 2. Verify the command fails +# +# + +verify_runnable "global" + +log_assert "zpool scrub returns an error when run as a user" + +log_mustnot $ZPOOL scrub $TESTPOOL +log_mustnot $ZPOOL scrub -s $TESTPOOL + +log_pass "zpool scrub returns an error when run as a user" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zpool_set_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_set_001_neg.ksh new file mode 100755 index 000000000000..e353d2dd8cec --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_set_001_neg.ksh @@ -0,0 +1,71 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013 by Delphix. All rights reserved. +# + +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg +. $STF_SUITE/include/libtest.shlib + +# +# DESCRIPTION: +# +# zpool set returns an error when run as a user +# +# STRATEGY: +# 1. Attempt to set some properties on a pool +# 2. Verify the command fails +# +# + +verify_runnable "global" + +log_assert "zpool set returns an error when run as a user" + +set -A props $POOL_NAMES +set -A prop_vals $POOL_VALS +set -A prop_new $POOL_ALTVALS + +while [[ $i -lt ${#args[*]} ]] +do + PROP=${props[$i]} + EXPECTED=${prop_vals[$i]} + NEW=${prop_new[$i]} + log_mustnot $POOL set $PROP=$NEW $TESTPOOL + + # Now verify that the above command did nothing + ACTUAL=$( $ZPOOL get $PROP $TESTPOOL | $GREP $PROP | $AWK '{print $1}' ) + if [ "$ACTUAL" != "$EXPECTED" ] + then + log_fail "Property $PROP was set to $ACTUAL, expected $EXPECTED" + fi + i=$(( $i + 1 )) +done + + +log_pass "zpool set returns an error when run as a user" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zpool_status_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_status_001_neg.ksh new file mode 100755 index 000000000000..54806b50af42 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_status_001_neg.ksh @@ -0,0 +1,76 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013 by Delphix. All rights reserved. +# + +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg +. $STF_SUITE/include/libtest.shlib + +# +# DESCRIPTION: +# +# zpool status works when run as a user +# +# STRATEGY: +# +# 1. Run zpool status as a user +# 2. Verify we get output +# + +function check_pool_status +{ + RESULT=$($GREP "pool:" /tmp/pool-status.$$) + if [ -z "$RESULT" ] + then + log_fail "No pool: string found in zpool status output!" + fi + $RM /tmp/pool-status.$$ +} + +verify_runnable "global" + +log_assert "zpool status works when run as a user" + +log_must eval "$ZPOOL status > /tmp/pool-status.$$" +check_pool_status + +log_must eval "$ZPOOL status -v > /tmp/pool-status.$$" +check_pool_status + +log_must eval "$ZPOOL status $TESTPOOL> /tmp/pool-status.$$" +check_pool_status + +log_must eval "$ZPOOL status -v $TESTPOOL > /tmp/pool-status.$$" +check_pool_status + +# $TESTPOOL.virt has an offline device, so -x will show it +log_must eval "$ZPOOL status -x $TESTPOOL.virt > /tmp/pool-status.$$" +check_pool_status + +log_pass "zpool status works when run as a user" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zpool_upgrade_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_upgrade_001_neg.ksh new file mode 100755 index 000000000000..2dc02b7f69dd --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_upgrade_001_neg.ksh @@ -0,0 +1,65 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013 by Delphix. All rights reserved. +# + +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg +. $STF_SUITE/include/libtest.shlib + +# +# DESCRIPTION: +# +# zpool upgrade returns an error when run as a user +# +# STRATEGY: +# +# 1. Attempt to upgrade a pool +# 2. Verify the command fails +# + +verify_runnable "global" + +log_assert "zpool upgrade returns an error when run as a user" + +log_onexit cleanup +# zpool upgrade returns 0 when it can't do anything +log_must $ZPOOL upgrade $TESTPOOL.virt + +# Now try to upgrade our version 1 pool +log_mustnot $ZPOOL upgrade v1-pool + +# if the pool has been upgraded, then v1-pool won't be listed in the output +# of zpool upgrade anymore +RESULT=$($ZPOOL upgrade | $GREP v1-pool) +if [ -z "$RESULT" ] +then + log_fail "A pool was upgraded successfully!" +fi + +log_pass "zpool upgrade returns an error when run as a user" diff --git a/tests/zfs-tests/tests/functional/cli_user/zfs_list/Makefile.am b/tests/zfs-tests/tests/functional/cli_user/zfs_list/Makefile.am new file mode 100644 index 000000000000..34390af64266 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/zfs_list/Makefile.am @@ -0,0 +1,12 @@ +pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_user/zfs_list +dist_pkgdata_SCRIPTS = \ + zfs_list.cfg \ + zfs_list.kshlib \ + setup.ksh \ + cleanup.ksh \ + zfs_list_001_pos.ksh \ + zfs_list_002_pos.ksh \ + zfs_list_003_pos.ksh \ + zfs_list_004_neg.ksh \ + zfs_list_007_pos.ksh \ + zfs_list_008_neg.ksh diff --git a/tests/zfs-tests/tests/functional/cli_user/zfs_list/cleanup.ksh b/tests/zfs-tests/tests/functional/cli_user/zfs_list/cleanup.ksh new file mode 100755 index 000000000000..115e00c47be5 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/zfs_list/cleanup.ksh @@ -0,0 +1,36 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2009 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013 by Delphix. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib +. $STF_SUITE/tests/functional/cli_root/zfs_get/zfs_get_list_d.kshlib + +depth_fs_cleanup +default_cleanup diff --git a/tests/zfs-tests/tests/functional/cli_user/zfs_list/setup.ksh b/tests/zfs-tests/tests/functional/cli_user/zfs_list/setup.ksh new file mode 100755 index 000000000000..66bcc06d869b --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/zfs_list/setup.ksh @@ -0,0 +1,70 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2009 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013 by Delphix. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib +. $STF_SUITE/tests/functional/cli_root/zfs_get/zfs_get_list_d.kshlib +. $STF_SUITE/tests/functional/cli_user/zfs_list/zfs_list.cfg + +DISK=${DISKS%% *} + +default_setup_noexit $DISK + +# create datasets and set checksum options +set -A cksumarray $CKSUMOPTS +typeset -i index=0 +for dataset in $DATASETS +do + log_must $ZFS create $TESTPOOL/$TESTFS/$dataset + $SLEEP 1 + log_must $ZFS snapshot $TESTPOOL/$TESTFS/${dataset}@snap + + $SLEEP 1 + if is_global_zone ; then + log_must $ZFS create -V 64M $TESTPOOL/$TESTFS/${dataset}-vol + $SLEEP 1 + log_must $ZFS snapshot $TESTPOOL/$TESTFS/${dataset}-vol@snap + fi + + # sleep to ensure that the datasets have different creation dates + $SLEEP 1 + log_must $ZFS set checksum=${cksumarray[$index]} \ + $TESTPOOL/$TESTFS/$dataset + if datasetexists $TESTPOOL/$TESTFS/${dataset}-vol; then + log_must $ZFS set checksum=${cksumarray[$index]} \ + $TESTPOOL/$TESTFS/${dataset}-vol + fi + + index=$((index + 1)) +done + +depth_fs_setup + +log_pass diff --git a/tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list.cfg b/tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list.cfg new file mode 100644 index 000000000000..59f367cfa544 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list.cfg @@ -0,0 +1,35 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013 by Delphix. All rights reserved. +# + +# Datasets (in order of creation date) and which checksum options +# we want to set for each dataset. +# These are used by various zfs list tests +export DATASETS="Apple Banana Carrot Orange apple banana carrot" +export CKSUMOPTS="on sha256 sha256 sha256 fletcher4 off fletcher2" diff --git a/tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list.kshlib b/tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list.kshlib new file mode 100644 index 000000000000..e64739dc317a --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list.kshlib @@ -0,0 +1,118 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2008 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013 by Delphix. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib + +# +# A function that verifies sort order. It takes as input +# a command, which gets executed. We then iterate over the results +# comparing that the sort order passed in via the list +# +function verify_sort { # command list name + + # now verify we've sorted by creation date: + typeset CMD=$1 + typeset list=$2 + typeset name=$3 + + typeset -i RET=0 + typeset -i index=1 + + # run the command to verify that it works + log_must eval "$CMD > /dev/null" + + # Now check the sort order + for dataset in $( $CMD ) + do + ACTUAL=$(basename $dataset) + if [ "$dataset" != "$TESTPOOL/$TESTFS" ] + then + EXPECTED=$($ECHO $list | $AWK "{print \$$index}") + if [ "$ACTUAL" != "$EXPECTED" ] + then + log_note "WARNING:" \ + "'$ACTUAL' does not equal '$EXPECTED'" + log_fail "ERROR: Sort by $name fails." + fi + + ((index = index + 1)) + fi + done + + # finally check to see if we have the expected number of elements + if [ $index -ne $($ECHO $list | $AWK '{print split($0,arr)+1}') ] + then + log_fail "Warning: " \ + "unexpected number of filesystems found in list output!" + fi +} + +# A function that verifies reverse sort order. It takes as input +# a command, which gets executed. We then iterate over the results +# comparing that the sort order passed in via the list +# +function verify_reverse_sort { # command list name + + typeset CMD=$1 + typeset list=$2 + typeset name=$3 + + # set our index to the be number of elements in the list + typeset -i index=$($ECHO $list | $AWK '{print split($0,arr)}') + + log_note "Checking reverse sort by '$name'," \ + "expecting the reverse of '$list'" + log_must eval "$CMD > /dev/null" + + for dataset in $( $CMD ) + do + ACTUAL=$(basename $dataset) + if [ "$dataset" != "$TESTPOOL/$TESTFS" ] + then + EXPECTED=$($ECHO $list | $AWK "{print \$$index}") + if [ "$ACTUAL" != "$EXPECTED" ] + then + log_note "Warning:" \ + "'$ACTUAL' does not equal to" \ + "the reverse of '$EXPECTED'" + log_fail "ERROR: Reverse sort by '$name' fails." + fi + + ((index = index - 1)) + fi + done + + # finally check to see if we have the expected number of elements + if [ $index -ne 0 ] + then + log_fail "Warning: " \ + "unexpected number of filesystems found in list output!" + fi +} diff --git a/tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list_001_pos.ksh b/tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list_001_pos.ksh new file mode 100755 index 000000000000..b0af4ebd9249 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list_001_pos.ksh @@ -0,0 +1,116 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2009 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013 by Delphix. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib +. $STF_SUITE/tests/functional/cli_root/zfs_get/zfs_get_list_d.kshlib + +# +# DESCRIPTION: +# Executing well-formed 'zfs list' commands should return success. +# +# STRATEGY: +# 1. Create an array of valid options. +# 2. Execute each element in the array. +# 3. Verify success is returned. +# + +verify_runnable "both" + +set -A args "list" "list -r" "list -H" \ + "list $TESTPOOL/$TESTFS" \ + "list -r $TESTPOOL/$TESTFS" "list -H $TESTPOOL/$TESTFS" \ + "list -rH $TESTPOOL/$TESTFS" "list -Hr $TESTPOOL/$TESTFS" \ + "list -o name $TESTPOOL/$TESTFS" "list -r -o name $TESTPOOL/$TESTFS" \ + "list -H -o name $TESTPOOL/$TESTFS" "list -rH -o name $TESTPOOL/$TESTFS" \ + "list -Hr -o name $TESTPOOL/$TESTFS" + +set -A d_args " " "-r" "-H" \ + "$TESTPOOL/$TESTFS" \ + "-r $TESTPOOL/$TESTFS" "-H $TESTPOOL/$TESTFS" \ + "-rH $TESTPOOL/$TESTFS" "-Hr $TESTPOOL/$TESTFS" \ + "-o name $TESTPOOL/$TESTFS" "-r -o name $TESTPOOL/$TESTFS" \ + "-H -o name $TESTPOOL/$TESTFS" "-rH -o name $TESTPOOL/$TESTFS" \ + "-Hr -o name $TESTPOOL/$TESTFS" + +typeset -i m=${#args[*]} +typeset -i n=0 +typeset -i k=0 +while (( n<${#depth_options[*]} )); +do + (( k=0 )) + while (( k<${#d_args[*]} )); + do + args[$m]="list"" -${depth_options[$n]}"" ${d_args[$k]}" + (( k+=1 )) + (( m+=1 )) + done + (( n+=1 )) +done + +set -A pathargs "list -r $TESTDIR" "list -H $TESTDIR" \ + "list -r ./../$TESTDIR" "list -H ./../$TESTDIR" + +set -A d_pathargs " $TESTDIR" "-r $TESTDIR" "-H $TESTDIR" \ + "-r ./../$TESTDIR" "-H ./../$TESTDIR" + +(( m=${#pathargs[*]} )) +(( n=0 )) +(( k=0 )) +while (( n<${#depth_options[*]} )); +do + (( k=0 )) + while (( k<${#d_pathargs[*]} )); + do + pathargs[$m]="list"" -${depth_options[$n]}"" ${d_pathargs[$k]}" + (( k+=1 )) + (( m+=1 )) + done + (( n+=1 )) +done + +log_assert "Verify 'zfs list [-rH] [-o property[,prop]*] [fs|clct|vol]'." + +typeset -i i=0 +while [[ $i -lt ${#args[*]} ]]; do + log_must eval "$ZFS ${args[i]} > /dev/null" + ((i = i + 1)) +done + +# Verify 'zfs list <path>' will succeed on absolute or relative path. + +cd /tmp +typeset -i i=0 +while [[ $i -lt ${#pathargs[*]} ]]; do + log_must eval "$ZFS ${pathargs[i]} > /dev/null" + ((i = i + 1)) +done + +log_pass "The sub-command 'list' succeeds as non-root." diff --git a/tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list_002_pos.ksh b/tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list_002_pos.ksh new file mode 100755 index 000000000000..3d546ecca87d --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list_002_pos.ksh @@ -0,0 +1,176 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2008 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013 by Delphix. All rights reserved. +# + +. $STF_SUITE/tests/functional/cli_user/zfs_list/zfs_list.kshlib + +# +# DESCRIPTION: +# The sort functionality in 'zfs list' works as expected. +# +# STRATEGY: +# 1. Using several zfs datasets with names, creation dates, checksum options +# 2. Sort the datasets by name, checksum options, creation date. +# 3. Verify that the datasets are sorted correctly. +# + +verify_runnable "both" + +# datasets ordered by name +fs_name="Apple Banana Carrot Orange apple banana carrot" +vol_name="Apple-vol Banana-vol Carrot-vol Orange-vol apple-vol" +vol_name="$vol_name banana-vol carrot-vol" +if is_global_zone ; then + snap_name="Apple-vol@snap Apple@snap Banana-vol@snap Banana@snap" + snap_name="$snap_name Carrot-vol@snap Carrot@snap Orange-vol@snap Orange@snap" + snap_name="$snap_name apple-vol@snap apple@snap banana-vol@snap banana@snap" + snap_name="$snap_name carrot-vol@snap carrot@snap" +else + snap_name="Apple@snap Banana@snap" + snap_name="$snap_name Carrot@snap Orange@snap" + snap_name="$snap_name apple@snap banana@snap" + snap_name="$snap_name carrot@snap" +fi + +fs_creation=$fs_name +vol_creation=$vol_name +if is_global_zone ; then + snap_creation="Apple@snap Apple-vol@snap Banana@snap Banana-vol@snap" + snap_creation="$snap_creation Carrot@snap Carrot-vol@snap Orange@snap Orange-vol@snap" + snap_creation="$snap_creation apple@snap apple-vol@snap banana@snap banana-vol@snap" + snap_creation="$snap_creation carrot@snap carrot-vol@snap" +else + snap_creation="Apple@snap Banana@snap" + snap_creation="$snap_creation Carrot@snap Orange@snap" + snap_creation="$snap_creation apple@snap banana@snap" + snap_creation="$snap_creation carrot@snap" +fi + +# +# datsets ordered by checksum options (note, Orange, Carrot & Banana have the +# same checksum options, so ZFS should revert to sorting them alphabetically by +# name) +# +fs_cksum="carrot apple banana Apple Banana Carrot Orange" +vol_cksum="carrot-vol apple-vol banana-vol Apple-vol Banana-vol" +vol_cksum="$vol_cksum Carrot-vol Orange-vol" +snap_cksum=$snap_creation + +fs_rev_cksum="carrot apple banana Apple Orange Carrot Banana" +vol_rev_cksum="carrot-vol apple-vol banana-vol Apple-vol Orange-vol" +vol_rev_cksum="$vol_rev_cksum Carrot-vol Banana-vol" + +log_assert "The sort functionality in 'zfs list' works as expected." + +# +# we must be in the C locale here, as running in other locales +# will make zfs use that locale's sort order. +# +LC_ALL=C; export LC_ALL + +# sort by creation +verify_sort \ + "$ZFS list -H -r -o name -s creation -t filesystem $TESTPOOL/$TESTFS" \ + "$fs_creation" "creation date" +if is_global_zone ; then + verify_sort \ + "$ZFS list -H -r -o name -s creation -t volume $TESTPOOL/$TESTFS" \ + "$vol_creation" "creation date" +fi +verify_sort \ + "$ZFS list -H -r -o name -s creation -t snapshot $TESTPOOL/$TESTFS" \ + "$snap_creation" "creation date" + +# sort by checksum +verify_sort \ + "$ZFS list -H -r -o name -s checksum -t filesystem $TESTPOOL/$TESTFS" \ + "$fs_cksum" "checksum" +if is_global_zone ; then + verify_sort \ + "$ZFS list -H -r -o name -s checksum -t volume $TESTPOOL/$TESTFS" \ + "$vol_cksum" "checksum" +fi +verify_sort \ + "$ZFS list -H -r -o name -s checksum -t snapshot $TESTPOOL/$TESTFS" \ + "$snap_cksum" "checksum" +verify_sort \ + "$ZFS list -H -r -o name -S checksum -t snapshot $TESTPOOL/$TESTFS" \ + "$snap_cksum" "checksum" + +# sort by name +verify_sort \ + "$ZFS list -H -r -o name -s name -t filesystem $TESTPOOL/$TESTFS" \ + "$fs_name" "name" +if is_global_zone ; then + verify_sort \ + "$ZFS list -H -r -o name -s name -t volume $TESTPOOL/$TESTFS" \ + "$vol_name" "name" +fi +verify_sort \ + "$ZFS list -H -r -o name -s name -t snapshot $TESTPOOL/$TESTFS" \ + "$snap_name" "name" + +# reverse sort by creation +verify_reverse_sort \ + "$ZFS list -H -r -o name -S creation -t filesystem $TESTPOOL/$TESTFS" \ + "$fs_creation" "creation date" +if is_global_zone ; then + verify_reverse_sort \ + "$ZFS list -H -r -o name -S creation -t volume $TESTPOOL/$TESTFS" \ + "$vol_creation" "creation date" +fi +verify_reverse_sort \ + "$ZFS list -H -r -o name -S creation -t snapshot $TESTPOOL/$TESTFS" \ + "$snap_creation" "creation date" + +# reverse sort by checksum +verify_reverse_sort \ + "$ZFS list -H -r -o name -S checksum -t filesystem $TESTPOOL/$TESTFS" \ + "$fs_rev_cksum" "checksum" +if is_global_zone ; then + verify_reverse_sort \ + "$ZFS list -H -r -o name -S checksum -t volume $TESTPOOL/$TESTFS" \ + "$vol_rev_cksum" "checksum" +fi + +# reverse sort by name +verify_reverse_sort \ + "$ZFS list -H -r -o name -S name -t filesystem $TESTPOOL/$TESTFS"\ + "$fs_name" "name" +if is_global_zone ; then + verify_reverse_sort \ + "$ZFS list -H -r -o name -S name -t volume $TESTPOOL/$TESTFS"\ + "$vol_name" "name" +fi +verify_reverse_sort \ + "$ZFS list -H -r -o name -S name -t snapshot $TESTPOOL/$TESTFS"\ + "$snap_name" "name" + +log_pass "The sort functionality in 'zfs list' works as expected." diff --git a/tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list_003_pos.ksh b/tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list_003_pos.ksh new file mode 100755 index 000000000000..f685456d78c3 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list_003_pos.ksh @@ -0,0 +1,76 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013 by Delphix. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib + +# +# DESCRIPTION: +# Verify 'zfs list -r' could recursively display any children +# of the dataset. +# +# STRATEGY: +# 1. Prepare a set of datasets by hierarchy. +# 2. Execute 'zfs list -r' at the top of these datasets. +# 3. Verify all child datasets are all be shown. +# + +function cleanup +{ + if [[ -f $tmpfile ]]; then + $RM -f $tmpfile + fi +} + +verify_runnable "both" +log_onexit cleanup + +log_assert "Verify 'zfs list -r' could display any children recursively." + +tmpfile=/var/tmp/zfslist.out.$$ +children="$TESTPOOL/$TESTFS" + +for fs in $DATASETS ; do + children="$children $TESTPOOL/$TESTFS/$fs" +done + +cd /tmp + +for path in $TESTPOOL/$TESTFS $TESTDIR ./../$TESTDIR ; do + $ZFS list -rH -o name $path > $tmpfile + for fs in $children ; do + $GREP "^${fs}$" $tmpfile > /dev/null 2>&1 + if (( $? != 0 )); then + log_fail "$fs not shown in the output list." + fi + done +done + +log_pass "'zfs list -r' could display any children recursively." diff --git a/tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list_004_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list_004_neg.ksh new file mode 100755 index 000000000000..13d6233d3c6f --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list_004_neg.ksh @@ -0,0 +1,63 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013 by Delphix. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib + +# +# DESCRIPTION: +# Verify 'zfs list [-r]' should fail while +# * the given dataset does not exist +# * the given path does not exist. +# * the given path does not belong to zfs. +# +# STRATEGY: +# 1. Create an array of invalid options. +# 2. Execute each element in the array. +# 3. Verify failure is returned. +# + +verify_runnable "both" + +log_assert "Verify 'zfs list [-r]' should fail while the given " \ + "dataset/path does not exist or not belong to zfs." + +paths="$TESTPOOL/NONEXISTFS $TESTPOOL/$TESTFS/NONEXISTFS \ + /$TESTDIR/NONEXISTFS /devices /tmp ./../devices ./../tmp" + +cd /tmp + +for fs in $paths ; do + log_mustnot $ZFS list $fs + log_mustnot $ZFS list -r $fs +done + +log_pass "'zfs list [-r]' fails while the given dataset/path does not exist " \ + "or not belong to zfs." diff --git a/tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list_007_pos.ksh b/tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list_007_pos.ksh new file mode 100755 index 000000000000..984bc77d3eb2 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list_007_pos.ksh @@ -0,0 +1,91 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2009 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013 by Delphix. All rights reserved. +# + +. $STF_SUITE/tests/functional/cli_root/zfs_get/zfs_get_list_d.kshlib + +# +# DESCRIPTION: +# 'zfs list -d <n>' should get expected output. +# +# STRATEGY: +# 1. 'zfs list -d <n>' to get the output. +# 2. 'zfs list -r|egrep' to get the expected output. +# 3. Compare the two outputs, they shoud be same. +# + +verify_runnable "both" + +set -A fs_type "all" "filesystem" "snapshot" +if is_global_zone ; then + set -A fs_type ${fs_type[*]} "volume" +fi + +function cleanup +{ + log_must $RM -f $DEPTH_OUTPUT + log_must $RM -f $EXPECT_OUTPUT +} + +log_onexit cleanup +log_assert "'zfs list -d <n>' should get expected output." + +mntpnt=/var/tmp +DEPTH_OUTPUT="$mntpnt/depth_output" +EXPECT_OUTPUT="$mntpnt/expect_output" +typeset -i old_val=0 +typeset -i j=0 +typeset -i fs=0 +typeset eg_opt="$DEPTH_FS"$ +for dp in ${depth_array[@]}; do + (( j=old_val+1 )) + while (( j<=dp && j<=MAX_DEPTH )); do + eg_opt="$eg_opt""|depth""$j"$ + (( j+=1 )) + done + (( fs=0 )) + while (( fs<${#fs_type[*]} )); do + if [[ "$dp" == "0" ]] && \ + [[ "${fs_type[$fs]}" == "volume" || "${fs_type[$fs]}" == "snapshot" ]]; then + log_must eval "$ZFS list -H -d $dp -o name -t ${fs_type[$fs]} $DEPTH_FS > $DEPTH_OUTPUT" + [[ -s "$DEPTH_OUTPUT" ]] && \ + log_fail "$DEPTH_OUTPUT should be null." + log_mustnot $ZFS list -rH -o name -t ${fs_type[$fs]} $DEPTH_FS | $EGREP -e '$eg_opt' + else + log_must eval "$ZFS list -H -d $dp -o name -t ${fs_type[$fs]} $DEPTH_FS > $DEPTH_OUTPUT" + log_must eval "$ZFS list -rH -o name -t ${fs_type[$fs]} $DEPTH_FS | $EGREP -e '$eg_opt' > $EXPECT_OUTPUT" + log_must $DIFF $DEPTH_OUTPUT $EXPECT_OUTPUT + fi + (( fs+=1 )) + done + (( old_val=dp )) +done + +log_pass "'zfs list -d <n>' should get expected output." diff --git a/tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list_008_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list_008_neg.ksh new file mode 100755 index 000000000000..74c0b8b71b47 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list_008_neg.ksh @@ -0,0 +1,56 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2009 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013 by Delphix. All rights reserved. +# + +. $STF_SUITE/tests/functional/cli_root/zfs_get/zfs_get_list_d.kshlib + +# +# DESCRIPTION: +# A negative depth or a non numeric depth should fail in 'zfs list -d <n>' +# +# STRATEGY: +# 1. Run zfs list -d with negative depth or non numeric depth +# 2. Verify that zfs list returns error +# + +verify_runnable "both" + +log_assert "A negative depth or a non numeric depth should fail in 'zfs list -d <n>'" + +set -A badargs "a" "AB" "aBc" "2A" "a2b" "aB2" "-1" "-32" "-999" + +typeset -i i=0 +while (( i < ${#badargs[*]} )) +do + log_mustnot eval "$ZFS list -d ${badargs[i]} $DEPTH_FS >/dev/null 2>&1" + (( i = i + 1 )) +done + +log_pass "A negative depth or a non numeric depth should fail in 'zfs list -d <n>'" diff --git a/tests/zfs-tests/tests/functional/cli_user/zpool_iostat/Makefile.am b/tests/zfs-tests/tests/functional/cli_user/zpool_iostat/Makefile.am new file mode 100644 index 000000000000..2c292b999938 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/zpool_iostat/Makefile.am @@ -0,0 +1,7 @@ +pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_user/zpool_iostat +dist_pkgdata_SCRIPTS = \ + setup.ksh \ + cleanup.ksh \ + zpool_iostat_001_neg.ksh \ + zpool_iostat_002_pos.ksh \ + zpool_iostat_003_neg.ksh diff --git a/tests/zfs-tests/tests/functional/cli_user/zpool_iostat/cleanup.ksh b/tests/zfs-tests/tests/functional/cli_user/zpool_iostat/cleanup.ksh new file mode 100755 index 000000000000..3166bd6ec16e --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/zpool_iostat/cleanup.ksh @@ -0,0 +1,34 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013 by Delphix. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib + +default_cleanup diff --git a/tests/zfs-tests/tests/functional/cli_user/zpool_iostat/setup.ksh b/tests/zfs-tests/tests/functional/cli_user/zpool_iostat/setup.ksh new file mode 100755 index 000000000000..d275e063b13a --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/zpool_iostat/setup.ksh @@ -0,0 +1,36 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013 by Delphix. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib + +DISK=${DISKS%% *} + +default_setup $DISK diff --git a/tests/zfs-tests/tests/functional/cli_user/zpool_iostat/zpool_iostat_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/zpool_iostat/zpool_iostat_001_neg.ksh new file mode 100755 index 000000000000..a1fac987eca4 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/zpool_iostat/zpool_iostat_001_neg.ksh @@ -0,0 +1,63 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013 by Delphix. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib + +# +# DESCRIPTION: +# Verify that 'zpool iostat' can be executed as non-root. +# +# STRATEGY: +# 1. Create an array of options. +# 2. Execute each element of the array. +# 3. Verify that a success is returned. +# + +verify_runnable "both" + +typeset testpool +if is_global_zone ; then + testpool=$TESTPOOL +else + testpool=${TESTPOOL%%/*} +fi + +set -A args "iostat" "iostat $testpool" + +log_assert "zpool iostat [pool_name ...] [interval]" + +typeset -i i=0 +while [[ $i -lt ${#args[*]} ]]; do + log_must $ZPOOL ${args[i]} + ((i = i + 1)) +done + +log_pass "The sub-command 'iostat' succeeds as non-root." diff --git a/tests/zfs-tests/tests/functional/cli_user/zpool_iostat/zpool_iostat_002_pos.ksh b/tests/zfs-tests/tests/functional/cli_user/zpool_iostat/zpool_iostat_002_pos.ksh new file mode 100755 index 000000000000..37062ca53669 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/zpool_iostat/zpool_iostat_002_pos.ksh @@ -0,0 +1,71 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2008 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013 by Delphix. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib + +# +# DESCRIPTION: +# Verify that 'zpool iostat [interval [count]' can be executed as non-root. +# +# STRATEGY: +# 1. Set the interval to 1 and count to 4. +# 2. Sleep for 4 seconds. +# 3. Verify that the output has 4 records. +# + +verify_runnable "both" + +typeset tmpfile=/var/tmp/zfsiostat.out.$$ +typeset -i stat_count=0 + +function cleanup +{ + if [[ -f $tmpfile ]]; then + $RM -f $tmpfile + fi +} + +log_onexit cleanup +log_assert "zpool iostat [pool_name ...] [interval] [count]" + +if ! is_global_zone ; then + TESTPOOL=${TESTPOOL%%/*} +fi + +$ZPOOL iostat $TESTPOOL 1 4 > $tmpfile 2>&1 & +sleep 4 +stat_count=$($GREP $TESTPOOL $tmpfile | $WC -l) + +if [[ $stat_count -ne 4 ]]; then + log_fail "zpool iostat [pool_name] [interval] [count] failed" +fi + +log_pass "zpool iostat [pool_name ...] [interval] [count] passed" diff --git a/tests/zfs-tests/tests/functional/cli_user/zpool_iostat/zpool_iostat_003_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/zpool_iostat/zpool_iostat_003_neg.ksh new file mode 100755 index 000000000000..d73f5d5c8e65 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/zpool_iostat/zpool_iostat_003_neg.ksh @@ -0,0 +1,65 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013 by Delphix. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib + +# +# DESCRIPTION: +# Executing 'zpool iostat' command with bad options fails. +# +# STRATEGY: +# 1. Create an array of badly formed 'zpool iostat' options. +# 2. Execute each element of the array. +# 3. Verify an error code is returned. +# + +verify_runnable "both" + +typeset testpool +if is_global_zone ; then + testpool=$TESTPOOL +else + testpool=${TESTPOOL%%/*} +fi + +set -A args "" "-?" "-f" "nonexistpool" "$TESTPOOL/$TESTFS" \ + "$testpool 1.23" "$testpool 0" "$testpool -1" "$testpool 1 0" \ + "$testpool 0 0" + +log_assert "Executing 'zpool iostat' with bad options fails" + +typeset -i i=1 +while [[ $i -lt ${#args[*]} ]]; do + log_mustnot $ZPOOL iostat ${args[i]} + ((i = i + 1)) +done + +log_pass "Executing 'zpool iostat' with bad options fails" diff --git a/tests/zfs-tests/tests/functional/cli_user/zpool_list/Makefile.am b/tests/zfs-tests/tests/functional/cli_user/zpool_list/Makefile.am new file mode 100644 index 000000000000..de8cb366924d --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/zpool_list/Makefile.am @@ -0,0 +1,6 @@ +pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_user/zpool_list +dist_pkgdata_SCRIPTS = \ + setup.ksh \ + cleanup.ksh \ + zpool_list_001_pos.ksh \ + zpool_list_002_neg.ksh diff --git a/tests/zfs-tests/tests/functional/cli_user/zpool_list/cleanup.ksh b/tests/zfs-tests/tests/functional/cli_user/zpool_list/cleanup.ksh new file mode 100755 index 000000000000..3166bd6ec16e --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/zpool_list/cleanup.ksh @@ -0,0 +1,34 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013 by Delphix. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib + +default_cleanup diff --git a/tests/zfs-tests/tests/functional/cli_user/zpool_list/setup.ksh b/tests/zfs-tests/tests/functional/cli_user/zpool_list/setup.ksh new file mode 100755 index 000000000000..d275e063b13a --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/zpool_list/setup.ksh @@ -0,0 +1,36 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013 by Delphix. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib + +DISK=${DISKS%% *} + +default_setup $DISK diff --git a/tests/zfs-tests/tests/functional/cli_user/zpool_list/zpool_list_001_pos.ksh b/tests/zfs-tests/tests/functional/cli_user/zpool_list/zpool_list_001_pos.ksh new file mode 100755 index 000000000000..4de88675fc37 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/zpool_list/zpool_list_001_pos.ksh @@ -0,0 +1,64 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2008 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013 by Delphix. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib + +# +# DESCRIPTION: +# Verify that 'zpool list' succeeds as non-root. +# +# STRATEGY: +# 1. Create an array of options. +# 2. Execute each element of the array. +# 3. Verify the command succeeds. +# + +verify_runnable "both" + +if ! is_global_zone; then + TESTPOOL=${TESTPOOL%%/*} +fi + +set -A args "list $TESTPOOL" "list -H $TESTPOOL" "list" "list -H" \ + "list -H -o name $TESTPOOL" "list -o name $TESTPOOL" \ + "list -o name,size,capacity,health,altroot $TESTPOOL" \ + "list -H -o name,size,capacity,health,altroot $TESTPOOL" + +log_assert "zpool list [-H] [-o filed[,filed]*] [<pool_name> ...]" + +typeset -i i=0 +while [[ $i -lt ${#args[*]} ]]; do + log_must $ZPOOL ${args[i]} + + ((i = i + 1)) +done + +log_pass "The sub-command 'list' succeeds as non-root." diff --git a/tests/zfs-tests/tests/functional/cli_user/zpool_list/zpool_list_002_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/zpool_list/zpool_list_002_neg.ksh new file mode 100755 index 000000000000..469437a38473 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/zpool_list/zpool_list_002_neg.ksh @@ -0,0 +1,57 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2008 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013 by Delphix. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib + +# +# DESCRIPTION: +# Executing 'zpool list' command with bad options fails. +# +# STRATEGY: +# 1. Create an array of badly formed 'zpool list' options. +# 2. Execute each element of the array. +# 3. Verify an error code is returned. +# + +verify_runnable "both" + +set -A args "" "-?" "-f" "-o" \ + "-o fakeproperty" "-o name,size,fakeproperty" + +log_assert "Executing 'zpool list' with bad options fails" + +typeset -i i=1 +while [[ $i -lt ${#args[*]} ]]; do + log_mustnot $ZPOOL list ${args[i]} + ((i = i + 1)) +done + +log_pass "Executing 'zpool list' with bad options fails" |