bb5e3b2f129cc39517b925419c22f69a378ec023eh#! /bin/ksh -p
d3d50737e566cade9a08d73d2af95105ac7cd960Rafael Vanoni#
bb5e3b2f129cc39517b925419c22f69a378ec023eh# CDDL HEADER START
bb5e3b2f129cc39517b925419c22f69a378ec023eh#
bb5e3b2f129cc39517b925419c22f69a378ec023eh# The contents of this file are subject to the terms of the
bb5e3b2f129cc39517b925419c22f69a378ec023eh# Common Development and Distribution License (the "License").
bb5e3b2f129cc39517b925419c22f69a378ec023eh# You may not use this file except in compliance with the License.
bb5e3b2f129cc39517b925419c22f69a378ec023eh#
bb5e3b2f129cc39517b925419c22f69a378ec023eh# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
bb5e3b2f129cc39517b925419c22f69a378ec023eh# or http://www.opensolaris.org/os/licensing.
bb5e3b2f129cc39517b925419c22f69a378ec023eh# See the License for the specific language governing permissions
bb5e3b2f129cc39517b925419c22f69a378ec023eh# and limitations under the License.
bb5e3b2f129cc39517b925419c22f69a378ec023eh#
bb5e3b2f129cc39517b925419c22f69a378ec023eh# When distributing Covered Code, include this CDDL HEADER in each
bb5e3b2f129cc39517b925419c22f69a378ec023eh# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
bb5e3b2f129cc39517b925419c22f69a378ec023eh# If applicable, add the following below this CDDL HEADER, with the
bb5e3b2f129cc39517b925419c22f69a378ec023eh# fields enclosed by brackets "[]" replaced with your own identifying
bb5e3b2f129cc39517b925419c22f69a378ec023eh# information: Portions Copyright [yyyy] [name of copyright owner]
bb5e3b2f129cc39517b925419c22f69a378ec023eh#
bb5e3b2f129cc39517b925419c22f69a378ec023eh# CDDL HEADER END
bb5e3b2f129cc39517b925419c22f69a378ec023eh#
bb5e3b2f129cc39517b925419c22f69a378ec023eh
bb5e3b2f129cc39517b925419c22f69a378ec023eh#
bb5e3b2f129cc39517b925419c22f69a378ec023eh# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
bb5e3b2f129cc39517b925419c22f69a378ec023eh# Use is subject to license terms.
bb5e3b2f129cc39517b925419c22f69a378ec023eh#
bb5e3b2f129cc39517b925419c22f69a378ec023eh
bb5e3b2f129cc39517b925419c22f69a378ec023eh#
bb5e3b2f129cc39517b925419c22f69a378ec023eh# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
bb5e3b2f129cc39517b925419c22f69a378ec023eh#
bb5e3b2f129cc39517b925419c22f69a378ec023eh
bb5e3b2f129cc39517b925419c22f69a378ec023eh. $STF_SUITE/include/libtest.shlib
bb5e3b2f129cc39517b925419c22f69a378ec023eh. $STF_SUITE/tests/functional/snapshot/snapshot.cfg
bb5e3b2f129cc39517b925419c22f69a378ec023eh
bb5e3b2f129cc39517b925419c22f69a378ec023eh#
bb5e3b2f129cc39517b925419c22f69a378ec023eh# DESCRIPTION:
bb5e3b2f129cc39517b925419c22f69a378ec023eh# to the originally snapshot'd file system, after the file
bb5e3b2f129cc39517b925419c22f69a378ec023eh# system has been changed. Uses 'sum -r'.
bb5e3b2f129cc39517b925419c22f69a378ec023eh#
bb5e3b2f129cc39517b925419c22f69a378ec023eh# STRATEGY:
bb5e3b2f129cc39517b925419c22f69a378ec023eh# 1) Create a file in the zfs dataset
bb5e3b2f129cc39517b925419c22f69a378ec023eh# 2) Sum the file for later comparison
bb5e3b2f129cc39517b925419c22f69a378ec023eh# 3) Create a snapshot of the dataset
bb5e3b2f129cc39517b925419c22f69a378ec023eh# 4) Append to the original file
bb5e3b2f129cc39517b925419c22f69a378ec023eh# 5) Verify both checksums match
bb5e3b2f129cc39517b925419c22f69a378ec023eh#
bb5e3b2f129cc39517b925419c22f69a378ec023eh
bb5e3b2f129cc39517b925419c22f69a378ec023ehverify_runnable "both"
bb5e3b2f129cc39517b925419c22f69a378ec023eh
bb5e3b2f129cc39517b925419c22f69a378ec023ehfunction cleanup
bb5e3b2f129cc39517b925419c22f69a378ec023eh{
bb5e3b2f129cc39517b925419c22f69a378ec023eh snapexists $SNAPCTR
bb5e3b2f129cc39517b925419c22f69a378ec023eh if [[ $? -eq 0 ]]; then
bb5e3b2f129cc39517b925419c22f69a378ec023eh log_must zfs destroy $SNAPCTR
bb5e3b2f129cc39517b925419c22f69a378ec023eh fi
bb5e3b2f129cc39517b925419c22f69a378ec023eh
bb5e3b2f129cc39517b925419c22f69a378ec023eh if [[ -e $SNAPDIR1 ]]; then
bb5e3b2f129cc39517b925419c22f69a378ec023eh log_must rm -rf $SNAPDIR1 > /dev/null 2>&1
bb5e3b2f129cc39517b925419c22f69a378ec023eh fi
bb5e3b2f129cc39517b925419c22f69a378ec023eh
bb5e3b2f129cc39517b925419c22f69a378ec023eh if [[ -e $TESTDIR ]]; then
bb5e3b2f129cc39517b925419c22f69a378ec023eh log_must rm -rf $TESTDIR/* > /dev/null 2>&1
bb5e3b2f129cc39517b925419c22f69a378ec023eh fi
bb5e3b2f129cc39517b925419c22f69a378ec023eh}
bb5e3b2f129cc39517b925419c22f69a378ec023eh
bb5e3b2f129cc39517b925419c22f69a378ec023ehlog_assert "Verify that a snapshot of a dataset is identical to " \
bb5e3b2f129cc39517b925419c22f69a378ec023eh "the original dataset."
922d2c76afbee21520ffa2088c4e60dcb80d3945ehlog_onexit cleanup
922d2c76afbee21520ffa2088c4e60dcb80d3945eh
bb5e3b2f129cc39517b925419c22f69a378ec023ehlog_note "Create a file in the zfs filesystem..."
bb5e3b2f129cc39517b925419c22f69a378ec023ehlog_must file_write -o create -f $TESTDIR1/$TESTFILE -b $BLOCKSZ \
bb5e3b2f129cc39517b925419c22f69a378ec023eh -c $NUM_WRITES -d $DATA
bb5e3b2f129cc39517b925419c22f69a378ec023eh
bb5e3b2f129cc39517b925419c22f69a378ec023ehlog_note "Sum the file, save for later comparison..."
922d2c76afbee21520ffa2088c4e60dcb80d3945ehFILE_SUM=`sum -r $TESTDIR1/$TESTFILE | awk '{ print $1 }'`
922d2c76afbee21520ffa2088c4e60dcb80d3945ehlog_note "FILE_SUM = $FILE_SUM"
bb5e3b2f129cc39517b925419c22f69a378ec023eh
bb5e3b2f129cc39517b925419c22f69a378ec023ehlog_note "Create a snapshot and mount it..."
bb5e3b2f129cc39517b925419c22f69a378ec023ehlog_must zfs snapshot $SNAPCTR
bb5e3b2f129cc39517b925419c22f69a378ec023eh
bb5e3b2f129cc39517b925419c22f69a378ec023ehlog_note "Append to the original file..."
bb5e3b2f129cc39517b925419c22f69a378ec023ehlog_must file_write -o append -f $TESTDIR1/$TESTFILE -b $BLOCKSZ \
922d2c76afbee21520ffa2088c4e60dcb80d3945eh -c $NUM_WRITES -d $DATA
922d2c76afbee21520ffa2088c4e60dcb80d3945eh
922d2c76afbee21520ffa2088c4e60dcb80d3945ehSNAP_FILE_SUM=`sum -r $SNAPDIR1/$TESTFILE | awk '{ print $1 }'`
bb5e3b2f129cc39517b925419c22f69a378ec023ehif [[ $SNAP_FILE_SUM -ne $FILE_SUM ]]; then
bb5e3b2f129cc39517b925419c22f69a378ec023eh log_fail "Sums do not match, aborting!! ($SNAP_FILE_SUM != $FILE_SUM)"
bb5e3b2f129cc39517b925419c22f69a378ec023ehfi
bb5e3b2f129cc39517b925419c22f69a378ec023eh
bb5e3b2f129cc39517b925419c22f69a378ec023ehlog_pass "Both Sums match. ($SNAP_FILE_SUM == $FILE_SUM)"
bb5e3b2f129cc39517b925419c22f69a378ec023eh