1#!/usr/local/bin/ksh93 -p
2#
3# CDDL HEADER START
4#
5# The contents of this file are subject to the terms of the
6# Common Development and Distribution License (the "License").
7# You may not use this file except in compliance with the License.
8#
9# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10# or http://www.opensolaris.org/os/licensing.
11# See the License for the specific language governing permissions
12# and limitations under the License.
13#
14# When distributing Covered Code, include this CDDL HEADER in each
15# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16# If applicable, add the following below this CDDL HEADER, with the
17# fields enclosed by brackets "[]" replaced with your own identifying
18# information: Portions Copyright [yyyy] [name of copyright owner]
19#
20# CDDL HEADER END
21#
22
23# $FreeBSD$
24
25#
26# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
27# Use is subject to license terms.
28#
29# ident	"@(#)zfs_rollback_003_neg.ksh	1.5	08/08/15 SMI"
30#
31
32. $STF_SUITE/include/libtest.kshlib
33. $STF_SUITE/tests/cli_root/zfs_rollback/zfs_rollback_common.kshlib
34
35#################################################################################
36#
37# __stc_assertion_start
38#
39# ID: zfs_rollback_003_neg
40#
41# DESCRIPTION:
42#	Separately verify 'zfs rollback ''|-f|-r|-rf|-R|-rR will fail in
43#	different conditions.
44#
45# STRATEGY:
46#	1. Create pool and file system
47#	2. Create 'snap' and 'snap1' of this file system.
48#	3. Run 'zfs rollback ""|-f <snap>' and it should fail.
49#	4. Create 'clone1' based on 'snap1'.
50#	5. Run 'zfs rollback -r|-rf <snap>' and it should fail.
51#
52# TESTABILITY: explicit
53#
54# TEST_AUTOMATION_LEVEL: automated
55#
56# CODING_STATUS: COMPLETED (2005-07-20)
57#
58# __stc_assertion_end
59#
60################################################################################
61
62verify_runnable "both"
63
64function cleanup
65{
66	$PKILL ${DD##*/}
67	for snap in $FSSNAP0 $FSSNAP1 $FSSNAP2; do
68		if snapexists $snap; then
69			log_must $ZFS destroy -Rf $snap
70		fi
71	done
72}
73
74log_assert "Separately verify 'zfs rollback ''|-f|-r|-rf will fail in " \
75	"different conditions."
76log_onexit cleanup
77
78# Create snapshot1 and snapshot2 for this file system.
79#
80create_snapshot $TESTPOOL/$TESTFS $TESTSNAP
81create_snapshot $TESTPOOL/$TESTFS $TESTSNAP1
82
83# Run 'zfs rollback ""|-f <snap>' and it should fail.
84#
85log_mustnot $ZFS rollback $TESTPOOL/$TESTFS@$TESTSNAP
86log_mustnot $ZFS rollback -f $TESTPOOL/$TESTFS@$TESTSNAP
87
88# Create 'clone1' based on 'snap1'.
89#
90create_clone $TESTPOOL/$TESTFS@$TESTSNAP1 $TESTPOOL/$TESTCLONE1
91
92# Run 'zfs rollback -r|-rf <snap>' and it should fail.
93#
94log_mustnot $ZFS rollback -r $TESTPOOL/$TESTFS@$TESTSNAP
95log_mustnot $ZFS rollback -rf $TESTPOOL/$TESTFS@$TESTSNAP
96
97log_pass "zfs rollback ''|-f|-r|-rf will fail in different conditions " \
98	"passed."
99