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