1 #! /usr/local/bin/ksh93 -p
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.
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.
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]
26 # Copyright 2007 Sun Microsystems, Inc. All rights reserved.
27 # Use is subject to license terms.
29 # ident "@(#)rollback_001_pos.ksh 1.2 07/01/09 SMI"
31 . $STF_SUITE/include/libtest.kshlib
33 ################################################################################
35 # __stc_assertion_start
37 # ID: rollback_001_pos
40 # Populate a file system and take a snapshot. Add some more files to the
41 # file system and rollback to the last snapshot. Verify no post snapshot
45 # 1. Empty a file system
46 # 2. Populate the file system
47 # 3. Take a snapshot of the file system
48 # 4. Add new files to the file system
49 # 5. Perform a rollback
50 # 6. Verify the snapshot and file system agree
52 # TESTABILITY: explicit
54 # TEST_AUTOMATION_LEVEL: automated
56 # CODING_STATUS: COMPLETED (2005-07-04)
60 ################################################################################
62 verify_runnable "both"
68 log_must $ZFS destroy $SNAPFS
70 [[ -e $TESTDIR ]] && \
71 log_must $RM -rf $TESTDIR/* > /dev/null 2>&1
74 log_assert "Verify that a rollback to a previous snapshot succeeds."
78 [[ -n $TESTDIR ]] && \
79 log_must $RM -rf $TESTDIR/* > /dev/null 2>&1
83 log_note "Populate the $TESTDIR directory (prior to snapshot)"
84 populate_dir $TESTDIR/before_file $COUNT $NUM_WRITES $BLOCKSZ ITER
85 log_must $ZFS snapshot $SNAPFS
87 FILE_COUNT=`$LS -Al $SNAPDIR | $GREP -v "total" | wc -l`
88 if [[ $FILE_COUNT -ne $COUNT ]]; then
90 log_fail "AFTER: $SNAPFS contains $FILE_COUNT files(s)."
93 log_note "Populate the $TESTDIR directory (post snapshot)"
94 populate_dir $TESTDIR/after_file $COUNT $NUM_WRITES $BLOCKSZ ITER
97 # Now rollback to latest snapshot
99 log_must $ZFS rollback $SNAPFS
101 FILE_COUNT=`$LS -Al $TESTDIR/after* 2> /dev/null | $GREP -v "total" | wc -l`
102 if [[ $FILE_COUNT -ne 0 ]]; then
104 log_fail "$TESTDIR contains $FILE_COUNT after* files(s)."
107 FILE_COUNT=`$LS -Al $TESTDIR/before* 2> /dev/null \
108 | $GREP -v "total" | wc -l`
109 if [[ $FILE_COUNT -ne $COUNT ]]; then
111 log_fail "$TESTDIR contains $FILE_COUNT before* files(s)."
114 log_pass "The rollback operation succeeded."