]>
git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blob - zfs/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_008_pos.ksh
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.
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.
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]
24 # Copyright 2008 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
28 .
$STF_SUITE/tests
/functional
/cli_root
/cli_common.kshlib
32 # Verifying 'zfs receive -vn [<filesystem|snapshot>]
33 # and zfs receive -vn -d <filesystem>'
36 # 1. Fill in fs with some data
37 # 2. Create full and incremental send stream
38 # 3. run zfs receive with -v option
39 # 3. Dryrun zfs receive with -vn option
40 # 3. Dryrun zfs receive with -vn -d option
41 # 4. Verify receive output and result
45 for dset
in $rst_snap $rst_fs $orig_snap; do
46 if datasetexists
$dset; then
47 log_must
$ZFS destroy
-fr $dset
51 for file in $fbackup $mnt_file $tmp_out; do
52 if [[ -f $file ]]; then
57 if datasetexists
$TESTPOOL/$TESTFS; then
58 log_must
$ZFS destroy
-Rf $TESTPOOL/$TESTFS
59 log_must
$ZFS create
$TESTPOOL/$TESTFS
60 log_must
$ZFS set mountpoint
=$TESTDIR $TESTPOOL/$TESTFS
64 verify_runnable
"both"
65 log_assert
"Verifying 'zfs receive -vn [<filesystem|snapshot>] " \
66 "and zfs receive -vn -d <filesystem>'"
70 typeset datasets
="$TESTPOOL/$TESTFS $TESTPOOL"
71 typeset rst_fs
=$TESTPOOL/$TESTFS/$TESTFS
72 typeset fbackup
=/var
/tmp
/fbackup.$$
73 typeset tmp_out
=/var
/tmp
/tmpout.$$
75 for orig_fs
in $datasets ; do
76 typeset rst_snap
=$rst_fs@snap
77 typeset orig_snap
=$orig_fs@snap
78 typeset verb_msg
="receiving full stream of ${orig_snap} into ${rst_snap}"
79 typeset dryrun_msg
="would receive full stream of ${orig_snap} into ${rst_snap}"
81 if ! datasetexists
$orig_fs; then
82 log_must
$ZFS create
$orig_fs
86 mntpnt
=$
(get_prop mountpoint
$orig_fs)
87 if [[ $?
-ne 0 ]] ; then
88 log_fail
"get_prop mountpoint $orig_fs failed"
91 typeset mnt_file
=$mntpnt/file1
93 log_must
$MKFILE 100m
$mnt_file
94 log_must
$ZFS snapshot
$orig_snap
95 log_must
eval "$ZFS send $orig_snap > $fbackup"
97 for opt
in "-v" "-vn"; do
98 if datasetexists
$rst_fs; then
99 log_must
$ZFS destroy
-fr $rst_fs
101 log_note
"Check ZFS receive $opt [<filesystem|snapshot>]"
102 log_must
eval "$ZFS receive $opt $rst_fs < $fbackup > $tmp_out 2>&1"
103 if [[ $opt == "-v" ]]; then
104 log_must
eval "$GREP \"$verb_msg\" $tmp_out >/dev/null 2>&1"
105 if ! datasetexists
$rst_snap; then
106 log_fail
"dataset was not received, even though the"\
110 log_must
eval "$GREP \"$dryrun_msg\" $tmp_out >/dev/null 2>&1"
111 if datasetexists
$rst_snap; then
112 log_fail
"dataset was received, even though the -nv"\
118 log_note
"Check ZFS receive -vn -d <filesystem>"
119 if ! datasetexists
$rst_fs; then
120 log_must
$ZFS create
$rst_fs
122 log_must
eval "$ZFS receive -vn -d -F $rst_fs <$fbackup >$tmp_out 2>&1"
123 typeset relative_path
=""
124 if [[ ${orig_fs} == *"/"* ]]; then
125 relative_path
=${orig_fs#*/}
128 typeset leaf_fs
=${rst_fs}/${relative_path}
130 rst_snap
=${leaf_fs}@snap
131 dryrun_msg
="would receive full stream of ${orig_snap} into ${rst_snap}"
133 log_must
eval "$GREP \"$dryrun_msg\" $tmp_out > /dev/null 2>&1"
135 if datasetexists
$rst_snap; then
136 log_fail
"dataset $rst_snap should not existed."
138 log_must
$ZFS destroy
-Rf $rst_fs
143 log_pass
"zfs receive -vn [<filesystem|snapshot>] and " \
144 "zfs receive -vn -d <filesystem>' succeed."