1#!/bin/ksh -p 2# 3# CDDL HEADER START 4# 5# This file and its contents are supplied under the terms of the 6# Common Development and Distribution License ("CDDL"), version 1.0. 7# You may only use this file in accordance with the terms of version 8# 1.0 of the CDDL. 9# 10# A full copy of the text of the CDDL should have accompanied this 11# source. A copy of the CDDL is also available via the Internet at 12# http://www.illumos.org/license/CDDL. 13# 14# CDDL HEADER END 15# 16 17# 18# Copyright (c) 2019 by Tim Chase. All rights reserved. 19# Copyright (c) 2019 Lawrence Livermore National Security, LLC. 20# 21 22. $STF_SUITE/include/libtest.shlib 23. $STF_SUITE/tests/functional/cli_root/zpool_trim/zpool_trim.kshlib 24 25# 26# DESCRIPTION: 27# A badly formed parameter passed to 'zpool trim' should 28# return an error. 29# 30# STRATEGY: 31# 1. Create an array containing bad 'zpool trim' parameters. 32# 2. For each element, execute the sub-command. 33# 3. Verify it returns an error. 34# 35 36DISK1=${DISKS%% *} 37DISK2="$(echo $DISKS | cut -d' ' -f2)" 38 39verify_runnable "global" 40 41set -A args "1" "-a" "-?" "--%" "-123456" "0.5" "-o" "-b" "-b no" "-z 2" 42 43log_assert "Execute 'zpool trim' using invalid parameters." 44 45log_must zpool create -f $TESTPOOL mirror $DISK1 $DISK2 46 47typeset -i i=0 48while [[ $i -lt ${#args[*]} ]]; do 49 log_mustnot zpool trim ${args[i]} $TESTPOOL 50 ((i = i + 1)) 51done 52 53log_pass "Invalid parameters to 'zpool trim' fail as expected." 54