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# $FreeBSD$ 24 25# 26# Copyright 2007 Sun Microsystems, Inc. All rights reserved. 27# Use is subject to license terms. 28# 29# ident "@(#)zfs_send_001_pos.ksh 1.2 07/01/09 SMI" 30# 31 32. $STF_SUITE/tests/cli_root/cli_common.kshlib 33 34################################################################################# 35# 36# __stc_assertion_start 37# 38# ID: zfs_send_001_pos 39# 40# DESCRIPTION: 41# Verify 'zfs send' can create valid send streams as expected. 42# 43# STRATEGY: 44# 1. Fill in fs with some data 45# 2. Create a full send streams with the fs 46# 3. Receive the send stream and verify the data integrity 47# 4. Fill in fs with some new data 48# 5. Create an incremental send stream with the fs 49# 6. Receive the incremental send stream and verify the data integrity. 50# 51# TESTABILITY: explicit 52# 53# TEST_AUTOMATION_LEVEL: automated 54# 55# CODING_STATUS: COMPLETED (2005-09-06) 56# 57# __stc_assertion_end 58# 59################################################################################ 60 61verify_runnable "both" 62 63function cleanup 64{ 65 for snap in $init_snap $inc_snap $rst_snap $rst_inc_snap; do 66 snapexists $snap && \ 67 log_must $ZFS destroy -f $snap 68 done 69 70 datasetexists $rst_root && \ 71 log_must $ZFS destroy -Rf $rst_root 72 73 for file in $full_bkup $inc_bkup \ 74 $init_data $inc_data 75 do 76 [[ -e $file ]] && \ 77 log_must $RM -f $file 78 done 79 80 [[ -d $TESTDIR1 ]] && \ 81 log_must $RM -rf $TESTDIR1 82 83} 84 85log_assert "Verify 'zfs send' can create valid send streams as expected." 86log_onexit cleanup 87 88init_snap=$TESTPOOL/$TESTFS@init_snap 89inc_snap=$TESTPOOL/$TESTFS@inc_snap 90full_bkup=$TMPDIR/fullbkup.${TESTCASE_ID} 91inc_bkup=$TMPDIR/incbkup.${TESTCASE_ID} 92init_data=$TESTDIR/$TESTFILE1 93inc_data=$TESTDIR/$TESTFILE2 94orig_sum="" 95rst_sum="" 96rst_root=$TESTPOOL/rst_ctr 97rst_snap=$rst_root/$TESTFS@init_snap 98rst_inc_snap=$rst_root/$TESTFS@inc_snap 99rst_data=$TESTDIR1/$TESTFS/$TESTFILE1 100rst_inc_data=$TESTDIR1/$TESTFS/$TESTFILE2 101 102 103log_note "Verify 'zfs send' can create full send stream." 104 105#Pre-paration 106log_must $ZFS create $rst_root 107[[ ! -d $TESTDIR1 ]] && \ 108 log_must $MKDIR -p $TESTDIR1 109log_must $ZFS set mountpoint=$TESTDIR1 $rst_root 110 111log_must $FILE_WRITE -o create -f $init_data -b $BLOCK_SIZE -c $WRITE_COUNT 112 113log_must $ZFS snapshot $init_snap 114$ZFS send $init_snap > $full_bkup 115(( $? != 0 )) && \ 116 log_fail "'$ZFS send' fails to create full send" 117 118log_note "Verify the send stream is valid to receive." 119 120log_must $ZFS receive $rst_snap <$full_bkup 121receive_check $rst_snap ${rst_snap%%@*} 122compare_cksum $init_data $rst_data 123 124log_note "Verify 'zfs send -i' can create incremental send stream." 125 126log_must $FILE_WRITE -o create -f $inc_data -b $BLOCK_SIZE -c $WRITE_COUNT -d 0 127 128log_must $ZFS snapshot $inc_snap 129$ZFS send -i $init_snap $inc_snap > $inc_bkup 130(( $? != 0 )) && \ 131 log_fail "'$ZFS send -i' fails to create incremental send" 132 133log_note "Verify the incremental send stream is valid to receive." 134 135log_must $ZFS rollback $rst_snap 136log_must $ZFS receive $rst_inc_snap <$inc_bkup 137receive_check $rst_inc_snap 138compare_cksum $inc_data $rst_inc_data 139 140log_pass "Verifying 'zfs receive' succeed." 141