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 snapexists "$snap" && destroy_dataset "$snap" 36 done 37} 38 39log_assert "'zfs diff' should only work with supported options." 40log_onexit cleanup 41 42typeset goodopts=("" "-h" "-t" "-th" "-H" "-Hh" "-Ht" "-Hth" "-F" "-Fh" "-Ft" "-Fth" "-FH" "-FHh" "-FHt" "-FHth") 43typeset badopts=("-f" "-T" "-Fx" "-Ho" "-tT" "-") 44 45DATASET="$TESTPOOL/$TESTFS" 46TESTSNAP1="$DATASET@snap1" 47TESTSNAP2="$DATASET@snap2" 48 49# 1. Create two snapshots 50log_must zfs snapshot "$TESTSNAP1" 51log_must zfs snapshot "$TESTSNAP2" 52 53# 2. Verify every supported option is accepted 54for opt in ${goodopts[@]} 55do 56 log_must zfs diff $opt "$TESTSNAP1" 57 log_must zfs diff $opt "$TESTSNAP1" "$DATASET" 58 log_must zfs diff $opt "$TESTSNAP1" "$TESTSNAP2" 59done 60 61# 3. Verify supported options raise an error with unsupported arguments 62for opt in ${goodopts[@]} 63do 64 log_mustnot zfs diff $opt 65 log_mustnot zfs diff $opt "$DATASET" 66 log_mustnot zfs diff $opt "$DATASET@noexists" 67 log_mustnot zfs diff $opt "$DATASET" "$TESTSNAP1" 68 log_mustnot zfs diff $opt "$TESTSNAP2" "$TESTSNAP1" 69done 70 71# 4. Verify other unsupported options raise an error 72for opt in ${badopts[@]} 73do 74 log_mustnot zfs diff $opt "$TESTSNAP1" "$DATASET" 75 log_mustnot zfs diff $opt "$TESTSNAP1" "$TESTSNAP2" 76done 77 78log_pass "'zfs diff' only works with supported options." 79