]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - tests/zfs-tests/tests/functional/redacted_send/redacted_negative.ksh
Vendor import of openzfs master @ 184df27eef0abdc7ab2105b21257f753834b936b
[FreeBSD/FreeBSD.git] / tests / zfs-tests / tests / functional / redacted_send / redacted_negative.ksh
1 #!/bin/ksh
2
3 #
4 # This file and its contents are supplied under the terms of the
5 # Common Development and Distribution License ("CDDL"), version 1.0.
6 # You may only use this file in accordance with the terms of version
7 # 1.0 of the CDDL.
8 #
9 # A full copy of the text of the CDDL should have accompanied this
10 # source.  A copy of the CDDL is also available via the Internet at
11 # http://www.illumos.org/license/CDDL.
12 #
13
14 #
15 # Copyright (c) 2018 by Delphix. All rights reserved.
16 #
17
18 . $STF_SUITE/tests/functional/redacted_send/redacted.kshlib
19
20 #
21 # Description:
22 # Test that redacted send correctly detects invalid arguments.
23 #
24
25 typeset sendfs="$POOL2/sendfs"
26 typeset recvfs="$POOL2/recvfs"
27 typeset clone1="$POOL2/clone1"
28 typeset clone2="$POOL2/clone2"
29 typeset clone3="$POOL2/clone3"
30 typeset clone3="$POOL2/clone4"
31 typeset tmpdir="$(get_prop mountpoint $POOL)/tmp"
32 typeset stream=$(mktemp $tmpdir/stream.XXXX)
33
34 log_onexit redacted_cleanup $sendfs $recvfs $clone3
35
36 log_must zfs create $sendfs
37 log_must zfs snapshot $sendfs@snap1
38 log_must zfs snapshot $sendfs@snap2
39 log_must zfs snapshot $sendfs@snap3
40 log_must zfs clone $sendfs@snap2 $clone1
41 log_must zfs snapshot $clone1@snap
42 log_must zfs bookmark $clone1@snap $clone1#book
43 log_must zfs clone $sendfs@snap2 $clone2
44 log_must zfs snapshot $clone2@snap
45
46 # Incompatible flags
47 log_must zfs redact $sendfs@snap2 book $clone1@snap
48 log_mustnot eval "zfs send -R --redact book $sendfs@snap2 >/dev/null"
49
50 typeset arg
51 for arg in "$sendfs" "$clone1#book"; do
52         log_mustnot eval "zfs send --redact book $arg >/dev/null"
53 done
54
55 # Bad redaction list arguments
56 log_mustnot zfs redact $sendfs@snap1
57 log_mustnot zfs redact $sendfs@snap1 book
58 log_mustnot zfs redact $sendfs#book1 book4 $clone1
59 log_mustnot eval "zfs send --redact $sendfs#book $sendfs@snap >/dev/null"
60
61 # Redaction snapshots not a descendant of tosnap
62 log_mustnot zfs redact $sendfs@snap2 book $sendfs@snap2
63 log_must zfs redact $sendfs@snap2 book2 $clone1@snap $clone2@snap
64 log_must eval "zfs send --redact book2 $sendfs@snap2 >$stream"
65 log_must zfs redact $sendfs@snap2 book3 $clone1@snap $clone2@snap
66 log_must eval "zfs send -i $sendfs@snap1 --redact book3 $sendfs@snap2 \
67     >/dev/null"
68 log_mustnot zfs redact $sendfs@snap3 $sendfs@snap3 $clone1@snap
69
70 # Full redacted sends of redacted datasets are not allowed.
71 log_must eval "zfs recv $recvfs <$stream"
72 log_must zfs snapshot $recvfs@snap
73 log_must zfs clone $recvfs@snap $clone3
74 log_must zfs snapshot $clone3@snap
75 log_mustnot zfs redact $recvfs@snap book5 $clone3@snap
76
77 # Nor may a redacted dataset appear in the redaction list.
78 log_mustnot zfs redact testpool2/recvfs@snap2 book7 testpool2/recvfs@snap
79
80 # Non-redaction bookmark cannot be sent and produces invalid argument error
81 log_must zfs bookmark "$sendfs@snap1" "$sendfs#book8"
82 log_must eval "zfs send --redact book8 -i $sendfs@snap1 $sendfs@snap2 2>&1 | head -n 100 | grep 'not a redaction bookmark'"
83
84 # Error messages for common usage errors
85 log_mustnot_expect "not contain '#'"    zfs redact $sendfs@snap1 \#book $sendfs@snap2
86 log_mustnot_expect "not contain '#'"    zfs redact $sendfs@snap1 $sendfs#book $sendfs@snap2
87 log_mustnot_expect "full dataset names" zfs redact $sendfs@snap1 book @snap2
88 log_mustnot_expect "full dataset names" zfs redact $sendfs@snap1 book @snap2
89 log_mustnot_expect "full dataset names" zfs redact $sendfs@snap1 \#book @snap2
90 log_mustnot_expect "descendent of snapshot" zfs redact $sendfs@snap2 book $sendfs@snap1
91
92 log_pass "Verify that redacted send correctly detects invalid arguments."