1#!/bin/ksh -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 28# 29# Copyright (c) 2016 by Delphix. All rights reserved. 30# 31 32. $STF_SUITE/tests/functional/cli_root/cli_common.kshlib 33 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 48verify_runnable "both" 49 50function cleanup 51{ 52 typeset snap 53 typeset bkup 54 55 for snap in $init_snap $inc_snap; do 56 snapexists $snap && \ 57 log_must zfs destroy -f $snap 58 done 59 60 datasetexists $rst_root && \ 61 log_must zfs destroy -Rf $rst_root 62 63 for bkup in $full_bkup $inc_bkup; do 64 [[ -e $bkup ]] && \ 65 log_must rm -f $bkup 66 done 67} 68 69log_assert "Verify 'zfs receive' fails with unsupported scenarios." 70log_onexit cleanup 71 72init_snap=$TESTPOOL/$TESTFS@initsnap 73inc_snap=$TESTPOOL/$TESTFS@incsnap 74rst_root=$TESTPOOL/rst_ctr 75rst_init_snap=$rst_root/$TESTFS@init_snap 76rst_inc_snap=$rst_root/$TESTFS@inc_snap 77full_bkup=/var/tmp/full_bkup.$$ 78inc_bkup=/var/tmp/inc_bkup.$$ 79 80log_must zfs create $rst_root 81log_must zfs snapshot $init_snap 82log_must eval "zfs send $init_snap > $full_bkup" 83 84log_note "'zfs receive' fails with invalid send streams." 85log_mustnot eval "zfs receive $rst_init_snap < /dev/zero" 86log_mustnot eval "zfs receive -d $rst_root </dev/zero" 87 88log_must eval "zfs receive $rst_init_snap < $full_bkup" 89 90log_note "Unmatched send stream with restoring filesystem" \ 91 " cannot be received." 92log_must zfs snapshot $inc_snap 93log_must eval "zfs send -i $init_snap $inc_snap > $inc_bkup" 94#make changes on the restoring filesystem 95log_must touch $ZFSROOT/$rst_root/$TESTFS/tmpfile 96log_mustnot eval "zfs receive $rst_inc_snap < $inc_bkup" 97log_mustnot eval "zfs receive -d $rst_root < $inc_bkup" 98 99log_pass "Unsupported scenarios to 'zfs receive' fail as expected." 100