3 # This file and its contents are supplied under the terms of the
4 # Common Development and Distribution License ("CDDL"), version 1.0.
5 # You may only use this file in accordance with the terms of version
8 # A full copy of the text of the CDDL should have accompanied this
9 # source. A copy of the CDDL is also available via the Internet at
10 # http://www.illumos.org/license/CDDL.
14 # Copyright 2017, loli10K <ezomori.nozomu@gmail.com>. All rights reserved.
17 . $STF_SUITE/include/libtest.shlib
21 # 'zfs diff' should only work with supported options.
24 # 1. Create two snapshots
25 # 2. Verify every supported option is accepted
26 # 3. Verify supported options raise an error with unsupported arguments
27 # 4. Verify other unsupported options raise an error
30 verify_runnable "both"
34 for snap in $TESTSNAP1 $TESTSNAP2; do
35 if snapexists "$snap"; then
36 log_must zfs destroy "$snap"
41 log_assert "'zfs diff' should only work with supported options."
44 typeset goodopts=("" "-F" "-H" "-t" "-FH" "-Ft" "-Ht" "-FHt")
45 typeset badopts=("-f" "-h" "-h" "-T" "-Fx" "-Ho" "-tT" "-")
47 DATASET="$TESTPOOL/$TESTFS"
48 TESTSNAP1="$DATASET@snap1"
49 TESTSNAP2="$DATASET@snap2"
51 # 1. Create two snapshots
52 log_must zfs snapshot "$TESTSNAP1"
53 log_must zfs snapshot "$TESTSNAP2"
55 # 2. Verify every supported option is accepted
56 for opt in ${goodopts[@]}
58 log_must zfs diff $opt "$TESTSNAP1"
59 log_must zfs diff $opt "$TESTSNAP1" "$DATASET"
60 log_must zfs diff $opt "$TESTSNAP1" "$TESTSNAP2"
63 # 3. Verify supported options raise an error with unsupported arguments
64 for opt in ${goodopts[@]}
66 log_mustnot zfs diff $opt
67 log_mustnot zfs diff $opt "$DATASET"
68 log_mustnot zfs diff $opt "$DATASET@noexists"
69 log_mustnot zfs diff $opt "$DATASET" "$TESTSNAP1"
70 log_mustnot zfs diff $opt "$TESTSNAP2" "$TESTSNAP1"
73 # 4. Verify other unsupported options raise an error
74 for opt in ${badopts[@]}
76 log_mustnot zfs diff $opt "$TESTSNAP1" "$DATASET"
77 log_mustnot zfs diff $opt "$TESTSNAP1" "$TESTSNAP2"
80 log_pass "'zfs diff' only works with supported options."