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# 24# Copyright 2007 Sun Microsystems, Inc. All rights reserved. 25# Use is subject to license terms. 26. $STF_SUITE/include/libtest.kshlib 27 28################################################################################ 29# 30# __stc_assertion_start 31# 32# ID: snapshot_005_pos 33# 34# DESCRIPTION: 35# to the originally snapshot'd file system, after the file 36# system has been changed. Uses 'sum -r'. 37# 38# STRATEGY: 39# 1) Create a file in the zfs dataset 40# 2) Sum the file for later comparison 41# 3) Create a snapshot of the dataset 42# 4) Append to the original file 43# 5) Verify both checksums match 44# 45# TESTABILITY: explicit 46# 47# TEST_AUTOMATION_LEVEL: automated 48# 49# CODING_STATUS: COMPLETED (2005-07-04) 50# 51# __stc_assertion_end 52# 53############################################################################### 54 55verify_runnable "both" 56 57function cleanup 58{ 59 snapexists $SNAPCTR 60 if [[ $? -eq 0 ]]; then 61 log_must $ZFS destroy $SNAPCTR 62 fi 63 64 if [[ -e $SNAPDIR1 ]]; then 65 log_must $RM -rf $SNAPDIR1 > /dev/null 2>&1 66 fi 67 68 if [[ -e $TESTDIR ]]; then 69 log_must $RM -rf $TESTDIR/* > /dev/null 2>&1 70 fi 71} 72 73log_assert "Verify that a snapshot of a dataset is identical to " \ 74 "the original dataset." 75log_onexit cleanup 76 77log_note "Create a file in the zfs filesystem..." 78log_must $FILE_WRITE -o create -f $TESTDIR1/$TESTFILE -b $BLOCKSZ \ 79 -c $NUM_WRITES -d $DATA 80 81log_note "Sum the file, save for later comparison..." 82FILE_SUM=`$SUM -r $TESTDIR1/$TESTFILE | $AWK '{ print $1 }'` 83log_note "FILE_SUM = $FILE_SUM" 84 85log_note "Create a snapshot and mount it..." 86log_must $ZFS snapshot $SNAPCTR 87 88log_note "Append to the original file..." 89log_must $FILE_WRITE -o append -f $TESTDIR1/$TESTFILE -b $BLOCKSZ \ 90 -c $NUM_WRITES -d $DATA 91 92SNAP_FILE_SUM=`$SUM -r $SNAPDIR1/$TESTFILE | $AWK '{ print $1 }'` 93if [[ $SNAP_FILE_SUM -ne $FILE_SUM ]]; then 94 log_fail "Sums do not match, aborting!! ($SNAP_FILE_SUM != $FILE_SUM)" 95fi 96 97log_pass "Both Sums match. ($SNAP_FILE_SUM == $FILE_SUM)" 98