]> git.proxmox.com Git - mirror_zfs.git/blame - tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_004_neg.ksh
ZTS: avoid piping to special devices
[mirror_zfs.git] / tests / zfs-tests / tests / functional / cli_root / zfs_send / zfs_send_004_neg.ksh
CommitLineData
6bb24f4d
BB
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
c1d9abf9
JWK
28#
29# Copyright (c) 2016 by Delphix. All rights reserved.
30#
31
6bb24f4d
BB
32. $STF_SUITE/tests/functional/cli_root/cli_common.kshlib
33
34#
35# DESCRIPTION:
36# Verify 'zfs send' fails with malformed parameters.
37#
38# STRATEGY:
39# 1. Define malformed parameters in array
40# 2. Feed the parameters to 'zfs send'
41# 3. Verify the result
42#
43
44verify_runnable "both"
45
46function cleanup
47{
48 typeset snap f
49
50 for snap in $snap1 $snap2 $snap3; do
51 snapexists $snap && \
c1d9abf9 52 log_must zfs destroy -f $snap
6bb24f4d
BB
53 done
54
55 for f in $tmpfile1 $tmpfile2; do
56 if [[ -e $f ]]; then
c1d9abf9 57 rm -f $f
6bb24f4d
BB
58 fi
59 done
60}
61
62fs=$TESTPOOL/$TESTFS
63snap1=$fs@snap1
64snap2=$fs@snap2
65snap3=$fs@snap3
66
67set -A badargs \
c9539600 68 "" "$TESTPOOL" "$TESTFS" "$fs" "$fs@nonexistent_snap" "?" \
6bb24f4d
BB
69 "$snap1/blah" "$snap1@blah" "-i" "-x" "-i $fs" \
70 "-x $snap1 $snap2" "-i $snap1" \
71 "-i $snap2 $snap1" "$snap1 $snap2" "-i $snap1 $snap2 $snap3" \
72 "-ii $snap1 $snap2" "-iii $snap1 $snap2" " -i $snap2 $snap1/blah" \
73 "-i $snap2/blah $snap1" \
74 "-i $snap2/blah $snap1/blah" \
75 "-i $snap1 blah@blah" \
76 "-i blah@blah $snap1" \
77 "-i $snap1 ${snap2##*@}" "-i $snap1 @${snap2##*@}" \
78 "-i ${snap1##*@} ${snap2##*@}" "-i @${snap1##*@} @${snap2##*@}" \
79 "-i ${snap1##*@} $snap2/blah" "-i @${snap1##*@} $snap2/blah" \
80 "-i @@${snap1##*@} $snap2" "-i $snap1 -i $snap1 $snap2" \
81 "-i snap1 snap2" "-i $snap1 snap2" \
82 "-i $snap1 $snap2 -i $snap1 $snap2" \
83 "-i snap1 $snap2 -i snap1 $snap2"
84
85log_assert "Verify that invalid parameters to 'zfs send' are caught."
86log_onexit cleanup
87
c1d9abf9 88log_must zfs snapshot $snap1
6bb24f4d 89tmpfile1=$TESTDIR/testfile1.$$
c1d9abf9
JWK
90log_must touch $tmpfile1
91log_must zfs snapshot $snap2
6bb24f4d 92tmpfile2=$TESTDIR/testfile2.$$
c1d9abf9
JWK
93log_must touch $tmpfile2
94log_must zfs snapshot $snap3
6bb24f4d
BB
95
96typeset -i i=0
97while (( i < ${#badargs[*]} ))
98do
81f981cd 99 log_mustnot eval "zfs send ${badargs[i]} >$TEST_BASE_DIR/devnull"
6bb24f4d
BB
100
101 (( i = i + 1 ))
102done
103
104#Testing zfs send fails by send backup stream to terminal
105for arg in "$snap1" "-i $snap1 $snap2"; do
c1d9abf9 106 log_mustnot eval "zfs send $arg >/dev/console"
6bb24f4d
BB
107done
108
109log_pass "Invalid parameters to 'zfs send' are caught as expected."