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 2009 Sun Microsystems, Inc.  All rights reserved.
27# Use is subject to license terms.
28#
29# ident	"@(#)rsend_013_pos.ksh	1.1	09/01/12 SMI"
30#
31
32. $STF_SUITE/tests/rsend/rsend.kshlib
33
34#################################################################################
35#
36# __stc_assertion_start
37#
38# ID: rsend_013_pos
39#
40# DESCRIPTION:
41#	zfs receive -dF with incremental stream will destroy all the
42#	dataset that not exist on the sender side.
43#
44# STRATEGY:
45#	1. Setup test model
46#	2. Send -R @final on pool
47#	3. Destroy some dataset within the @final, and create @destroy
48#	4. Send -R -I @final @destroy on pool
49#	5. Verify receive -dF will destroy all the dataset that not exist
50#	   on the sender side.
51#
52# TESTABILITY: explicit
53#
54# TEST_AUTOMATION_LEVEL: automated
55#
56# CODING_STATUS: COMPLETED (2008-12-15)
57#
58# __stc_assertion_end
59#
60################################################################################
61
62verify_runnable "both"
63
64function cleanup
65{
66	cleanup_pool $POOL2
67	cleanup_pool $POOL
68	log_must setup_test_model $POOL
69}
70
71log_assert "zfs receive -dF will destroy all the dataset that not exist" \
72	"on the sender side"
73log_onexit cleanup
74
75cleanup
76
77#
78# Duplicate POOL2 for testing
79#
80log_must eval "$ZFS send -R $POOL@final > $BACKDIR/pool-final-R"
81log_must eval "$ZFS receive -dF $POOL2 < $BACKDIR/pool-final-R"
82
83log_must $ZFS destroy -Rf $POOL/$FS
84log_must $ZFS destroy -Rf $POOL/pclone
85
86if is_global_zone ; then
87	log_must $ZFS destroy -Rf $POOL/vol
88fi
89log_must $ZFS snapshot -r $POOL@destroy
90
91log_must eval "$ZFS send -R -I @final $POOL@destroy > " \
92	"$BACKDIR/pool-final-destroy-IR"
93log_must eval "$ZFS receive -dF $POOL2 < $BACKDIR/pool-final-destroy-IR"
94
95dstds=$(get_dst_ds $POOL $POOL2)
96log_must cmp_ds_subs $POOL $dstds
97log_must cmp_ds_cont $POOL $dstds
98
99log_pass "zfs receive -dF will destroy all the dataset that not exist" \
100	"on the sender side"
101