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_006_pos 33# 34# DESCRIPTION: 35# An archive of a zfs dataset and an archive of its snapshot 36# changed sinced the snapshot was taken. 37# 38# STRATEGY: 39# 1) Create some files in a ZFS dataset 40# 2) Create a tarball of the dataset 41# 3) Create a snapshot of the dataset 42# 4) Remove all the files in the original dataset 43# 5) Create a tarball of the snapshot 44# 6) Extract each tarball and compare directory structures 45# 46# TESTABILITY: explicit 47# 48# TEST_AUTOMATION_LEVEL: automated 49# 50# CODING_STATUS: COMPLETED (2005-07-04) 51# 52# __stc_assertion_end 53# 54################################################################################ 55 56verify_runnable "both" 57 58function cleanup 59{ 60 if [[ -d $CWD ]]; then 61 cd $CWD || log_fail "Could not cd $CWD" 62 fi 63 64 snapexists $SNAPCTR 65 if [[ $? -eq 0 ]]; then 66 log_must $ZFS destroy $SNAPCTR 67 fi 68 69 if [[ -e $SNAPDIR1 ]]; then 70 log_must $RM -rf $SNAPDIR1 > /dev/null 2>&1 71 fi 72 73 if [[ -e $TESTDIR1 ]]; then 74 log_must $RM -rf $TESTDIR1/* > /dev/null 2>&1 75 fi 76 77 if [[ -e $TMPDIR/zfs_snapshot2.${TESTCASE_ID} ]]; then 78 log_must $RM -rf $TMPDIR/zfs_snapshot2.${TESTCASE_ID} > /dev/null 2>&1 79 fi 80 81} 82 83log_assert "Verify that an archive of a dataset is identical to " \ 84 "an archive of the dataset's snapshot." 85 86log_onexit cleanup 87 88typeset -i COUNT=21 89typeset OP=create 90 91[[ -n $TESTDIR1 ]] && $RM -rf $TESTDIR1/* > /dev/null 2>&1 92 93log_note "Create files in the zfs dataset ..." 94populate_dir $TESTDIR1/file $COUNT $NUM_WRITES $BLOCKSZ $DATA 95 96log_note "Create a tarball from $TESTDIR1 contents..." 97CWD=$PWD 98cd $TESTDIR1 || log_fail "Could not cd $TESTDIR1" 99log_must $TAR cf $TESTDIR1/tarball.original.tar file* 100cd $CWD || log_fail "Could not cd $CWD" 101 102log_note "Create a snapshot and mount it..." 103log_must $ZFS snapshot $SNAPCTR 104 105log_note "Remove all of the original files..." 106log_must $RM -f $TESTDIR1/file* > /dev/null 2>&1 107 108log_note "Create tarball of snapshot..." 109CWD=$PWD 110cd $SNAPDIR1 || log_fail "Could not cd $SNAPDIR1" 111log_must $TAR cf $TESTDIR1/tarball.snapshot.tar file* 112cd $CWD || log_fail "Could not cd $CWD" 113 114log_must $MKDIR $TESTDIR1/original 115log_must $MKDIR $TESTDIR1/snapshot 116 117CWD=$PWD 118cd $TESTDIR1/original || log_fail "Could not cd $TESTDIR1/original" 119log_must $TAR xf $TESTDIR1/tarball.original.tar 120 121cd $TESTDIR1/snapshot || log_fail "Could not cd $TESTDIR1/snapshot" 122log_must $TAR xf $TESTDIR1/tarball.snapshot.tar 123 124cd $CWD || log_fail "Could not cd $CWD" 125 126$DIRCMP $TESTDIR1/original $TESTDIR1/snapshot > $TMPDIR/zfs_snapshot2.${TESTCASE_ID} 127$GREP different $TMPDIR/zfs_snapshot2.${TESTCASE_ID} >/dev/null 2>&1 128if [[ $? -ne 1 ]]; then 129 log_fail "Directory structures differ." 130fi 131 132log_pass "Directory structures match." 133