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