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