1#!/bin/ksh -p 2# 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 6# 1.0 of the CDDL. 7# 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. 11# 12 13# 14# Copyright 2017, loli10K <ezomori.nozomu@gmail.com>. All rights reserved. 15# 16 17. $STF_SUITE/include/libtest.shlib 18 19# 20# DESCRIPTION: 21# 'zfs diff' should only work with supported options. 22# 23# STRATEGY: 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 28# 29 30verify_runnable "both" 31 32function cleanup 33{ 34 for snap in $TESTSNAP1 $TESTSNAP2; do 35 if snapexists "$snap"; then 36 log_must zfs destroy "$snap" 37 fi 38 done 39} 40 41log_assert "'zfs diff' should only work with supported options." 42log_onexit cleanup 43 44typeset goodopts=("" "-F" "-H" "-t" "-FH" "-Ft" "-Ht" "-FHt") 45typeset badopts=("-f" "-h" "-h" "-T" "-Fx" "-Ho" "-tT" "-") 46 47DATASET="$TESTPOOL/$TESTFS" 48TESTSNAP1="$DATASET@snap1" 49TESTSNAP2="$DATASET@snap2" 50 51# 1. Create two snapshots 52log_must zfs snapshot "$TESTSNAP1" 53log_must zfs snapshot "$TESTSNAP2" 54 55# 2. Verify every supported option is accepted 56for opt in ${goodopts[@]} 57do 58 log_must zfs diff $opt "$TESTSNAP1" 59 log_must zfs diff $opt "$TESTSNAP1" "$DATASET" 60 log_must zfs diff $opt "$TESTSNAP1" "$TESTSNAP2" 61done 62 63# 3. Verify supported options raise an error with unsupported arguments 64for opt in ${goodopts[@]} 65do 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" 71done 72 73# 4. Verify other unsupported options raise an error 74for opt in ${badopts[@]} 75do 76 log_mustnot zfs diff $opt "$TESTSNAP1" "$DATASET" 77 log_mustnot zfs diff $opt "$TESTSNAP1" "$TESTSNAP2" 78done 79 80log_pass "'zfs diff' only works with supported options." 81