comparison usr/src/test/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_004_neg.ksh @ 13899:0bcf78798346

3311 Want a test framework for arbitrary OS unit tests 3312 Add a testrunner package for OS unit tests 3313 Add a testrunner package to convert ZFS tests from STF Reviewed by: Matt Ahrens <matthew.ahrens@delphix.com> Reviewed by: Will Guyette <will.guyette@delphix.com> Reviewed by: Dan Kimmel <dan.kimmel@delphix.com> Reviewed by: Adam Leventhal <ahl@delphix.com> Reviewed by: Henrik Mattson <henrik.mattson@delphix.com> Reviewed by: Sonu Pillai <sonu.pillai@delphix.com> Reviewed by: Christopher Siden <chris.siden@delphix.com> Reviewed by: George Wilson <george.wilson@delphix.com> Reviewed by: Richard Lowe <richlowe@richlowe.net> Approved by: Richard Lowe <richlowe@richlowe.net>
author John Wren Kennedy <john.kennedy@delphix.com>
date Wed, 05 Dec 2012 22:04:50 -0500
parents
children
comparison
equal deleted inserted replaced
13898:7f822b09519b 13899:0bcf78798346
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 2008 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
26 #
27
28 . $STF_SUITE/tests/functional/cli_root/cli_common.kshlib
29
30 #
31 # DESCRIPTION:
32 # Verify 'zfs send' fails with malformed parameters.
33 #
34 # STRATEGY:
35 # 1. Define malformed parameters in array
36 # 2. Feed the parameters to 'zfs send'
37 # 3. Verify the result
38 #
39
40 verify_runnable "both"
41
42 function cleanup
43 {
44 typeset snap f
45
46 for snap in $snap1 $snap2 $snap3; do
47 snapexists $snap && \
48 log_must $ZFS destroy -f $snap
49 done
50
51 for f in $tmpfile1 $tmpfile2; do
52 if [[ -e $f ]]; then
53 $RM -f $f
54 fi
55 done
56 }
57
58 fs=$TESTPOOL/$TESTFS
59 snap1=$fs@snap1
60 snap2=$fs@snap2
61 snap3=$fs@snap3
62
63 set -A badargs \
64 "" "$TESTPOOL" "$TESTFS" "$fs" "$fs@nonexisten_snap" "?" \
65 "$snap1/blah" "$snap1@blah" "-i" "-x" "-i $fs" \
66 "-x $snap1 $snap2" "-i $snap1" \
67 "-i $snap2 $snap1" "$snap1 $snap2" "-i $snap1 $snap2 $snap3" \
68 "-ii $snap1 $snap2" "-iii $snap1 $snap2" " -i $snap2 $snap1/blah" \
69 "-i $snap2/blah $snap1" \
70 "-i $snap2/blah $snap1/blah" \
71 "-i $snap1 blah@blah" \
72 "-i blah@blah $snap1" \
73 "-i $snap1 ${snap2##*@}" "-i $snap1 @${snap2##*@}" \
74 "-i ${snap1##*@} ${snap2##*@}" "-i @${snap1##*@} @${snap2##*@}" \
75 "-i ${snap1##*@} $snap2/blah" "-i @${snap1##*@} $snap2/blah" \
76 "-i @@${snap1##*@} $snap2" "-i $snap1 -i $snap1 $snap2" \
77 "-i snap1 snap2" "-i $snap1 snap2" \
78 "-i $snap1 $snap2 -i $snap1 $snap2" \
79 "-i snap1 $snap2 -i snap1 $snap2"
80
81 log_assert "Verify that invalid parameters to 'zfs send' are caught."
82 log_onexit cleanup
83
84 log_must $ZFS snapshot $snap1
85 tmpfile1=$TESTDIR/testfile1.$$
86 log_must $TOUCH $tmpfile1
87 log_must $ZFS snapshot $snap2
88 tmpfile2=$TESTDIR/testfile2.$$
89 log_must $TOUCH $tmpfile2
90 log_must $ZFS snapshot $snap3
91
92 typeset -i i=0
93 while (( i < ${#badargs[*]} ))
94 do
95 log_mustnot eval "$ZFS send ${badargs[i]} >/dev/null"
96
97 (( i = i + 1 ))
98 done
99
100 #Testing zfs send fails by send backup stream to terminal
101 for arg in "$snap1" "-i $snap1 $snap2"; do
102 log_mustnot eval "$ZFS send $arg >/dev/console"
103 done
104
105 log_pass "Invalid parameters to 'zfs send' are caught as expected."