7290 ZFS test suite needs to control what utilities it can run
[unleashed.git] / usr / src / test / zfs-tests / tests / functional / cli_root / zfs_send / zfs_send_002_pos.ksh
blob0c21e4175f1016ee8654a9918e989031812e33d9
1 #!/bin/ksh -p
3 # CDDL HEADER START
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]
20 # CDDL HEADER END
24 # Copyright 2007 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
29 # Copyright (c) 2012, 2016 by Delphix. All rights reserved.
32 . $STF_SUITE/tests/functional/cli_root/cli_common.kshlib
33 . $STF_SUITE/tests/functional/cli_root/zfs_send/zfs_send.cfg
36 # DESCRIPTION:
37 # Verify 'zfs send' can generate valid streams with a property setup.
39 # STRATEGY:
40 # 1. Setup property for filesystem
41 # 2. Fill in some data into filesystem
42 # 3. Create a full send streams
43 # 4. Receive the send stream
44 # 5. Verify the receive result
47 verify_runnable "both"
49 function cleanup
51 snapexists $snap && \
52 log_must zfs destroy $snap
54 datasetexists $ctr && \
55 log_must zfs destroy -r $ctr
57 [[ -e $origfile ]] && \
58 log_must rm -f $origfile
60 [[ -e $stream ]] && \
61 log_must rm -f $stream
64 function do_testing # <prop> <prop_value>
66 typeset property=$1
67 typeset prop_val=$2
69 log_must zfs set $property=$prop_val $fs
70 file_write -o create -f $origfile -b $BLOCK_SIZE -c $WRITE_COUNT
71 log_must zfs snapshot $snap
72 zfs send $snap > $stream
73 (( $? != 0 )) && \
74 log_fail "'zfs send' fails to create send streams."
75 zfs receive -d $ctr <$stream
76 (( $? != 0 )) && \
77 log_fail "'zfs receive' fails to receive send streams."
79 #verify receive result
80 ! datasetexists $rstfs && \
81 log_fail "'zfs receive' fails to restore $rstfs"
82 ! snapexists $rstfssnap && \
83 log_fail "'zfs receive' fails to restore $rstfssnap"
84 if [[ ! -e $rstfile ]] || [[ ! -e $rstsnapfile ]]; then
85 log_fail " Data lost after receiving stream"
88 compare_cksum $origfile $rstfile
89 compare_cksum $origsnapfile $rstsnapfile
91 #Destroy datasets and stream for next testing
92 log_must zfs destroy $snap
93 if is_global_zone ; then
94 log_must zfs destroy -r $rstfs
95 else
96 log_must zfs destroy -r $ds_path
98 log_must rm -f $stream
101 log_assert "Verify 'zfs send' generates valid streams with a property setup"
102 log_onexit cleanup
104 fs=$TESTPOOL/$TESTFS
105 snap=$fs@$TESTSNAP
106 ctr=$TESTPOOL/$TESTCTR
107 if is_global_zone; then
108 rstfs=$ctr/$TESTFS
109 else
110 ds_path=$ctr/${ZONE_CTR}0
111 rstfs=$ds_path/$TESTFS
113 rstfssnap=$rstfs@$TESTSNAP
114 snapdir=".zfs/snapshot/$TESTSNAP"
115 origfile=$TESTDIR/$TESTFILE1
116 rstfile=/$rstfs/$TESTFILE1
117 origsnapfile=$TESTDIR/$snapdir/$TESTFILE1
118 rstsnapfile=/$rstfs/$snapdir/$TESTFILE1
119 stream=/var/tmp/streamfile.$$
121 set -A props "compression" "checksum" "recordsize"
122 set -A propval "on lzjb" "on fletcher2 fletcher4 sha256" \
123 "512 1k 4k 8k 16k 32k 64k 128k"
125 #Create a dataset to receive the send stream
126 log_must zfs create $ctr
128 typeset -i i=0
129 while (( i < ${#props[*]} ))
131 for value in ${propval[i]}
133 do_testing ${props[i]} $value
134 done
136 (( i = i + 1 ))
137 done
139 log_pass "'zfs send' generates streams with a property setup as expected."