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_receive_005_neg 34# 35# DESCRIPTION: 36# Verify 'zfs receive' fails with unsupported scenarios. 37# including: 38# (1) Invalid send streams; 39# (2) The received incremental send doesn't match the filesystem 40# latest status. 41# 42# STRATEGY: 43# 1. Preparation for unsupported scenarios 44# 2. Execute 'zfs receive' 45# 3. Verify the results are failed 46# 47# TESTABILITY: explicit 48# 49# TEST_AUTOMATION_LEVEL: automated 50# 51# CODING_STATUS: COMPLETED (2005-09-06) 52# 53# __stc_assertion_end 54# 55################################################################################ 56 57verify_runnable "both" 58 59function cleanup 60{ 61 typeset snap 62 typeset bkup 63 64 for snap in $init_snap $inc_snap; do 65 snapexists $snap && \ 66 log_must $ZFS destroy -f $snap 67 done 68 69 datasetexists $rst_root && \ 70 log_must $ZFS destroy -Rf $rst_root 71 72 for bkup in $full_bkup $inc_bkup; do 73 [[ -e $bkup ]] && \ 74 log_must $RM -f $bkup 75 done 76} 77 78log_assert "Verify 'zfs receive' fails with unsupported scenarios." 79log_onexit cleanup 80 81init_snap=$TESTPOOL/$TESTFS@initsnap 82inc_snap=$TESTPOOL/$TESTFS@incsnap 83rst_root=$TESTPOOL/rst_ctr 84rst_init_snap=$rst_root/$TESTFS@init_snap 85rst_inc_snap=$rst_root/$TESTFS@inc_snap 86full_bkup=$TMPDIR/full_bkup.${TESTCASE_ID} 87inc_bkup=$TMPDIR/inc_bkup.${TESTCASE_ID} 88 89log_must $ZFS create $rst_root 90log_must $ZFS snapshot $init_snap 91log_must eval "$ZFS send $init_snap > $full_bkup" 92 93log_note "'zfs receive' fails with invalid send streams." 94log_mustnot eval "$ZFS receive $rst_init_snap < /dev/zero" 95log_mustnot eval "$ZFS receive -d $rst_root </dev/zero" 96 97log_must eval "$ZFS receive $rst_init_snap < $full_bkup" 98 99log_note "Unmatched send stream with restoring filesystem" \ 100 " cannot be received." 101log_must $ZFS snapshot $inc_snap 102log_must eval "$ZFS send -i $init_snap $inc_snap > $inc_bkup" 103#make changes on the restoring filesystem 104log_must $TOUCH $ZFSROOT/$rst_root/$TESTFS/tmpfile 105log_mustnot eval "$ZFS receive $rst_inc_snap < $inc_bkup" 106log_mustnot eval "$ZFS receive -d $rst_root < $inc_bkup" 107 108log_pass "Unsupported scenarios to 'zfs receive' fail as expected." 109