1#!/usr/local/bin/ksh93 -p 2# 3# CDDL HEADER START 4# 5# The contents of this file are subject to the terms of the 6# Common Development and Distribution License (the "License"). 7# You may not use this file except in compliance with the License. 8# 9# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10# or http://www.opensolaris.org/os/licensing. 11# See the License for the specific language governing permissions 12# and limitations under the License. 13# 14# When distributing Covered Code, include this CDDL HEADER in each 15# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16# If applicable, add the following below this CDDL HEADER, with the 17# fields enclosed by brackets "[]" replaced with your own identifying 18# information: Portions Copyright [yyyy] [name of copyright owner] 19# 20# CDDL HEADER END 21# 22 23# $FreeBSD$ 24 25# 26# Copyright 2009 Sun Microsystems, Inc. All rights reserved. 27# Use is subject to license terms. 28# 29# ident "@(#)zpool_set_002_neg.ksh 1.3 09/01/12 SMI" 30# 31 32. $STF_SUITE/include/libtest.kshlib 33 34################################################################################ 35# 36# __stc_assertion_start 37# 38# ID: zpool_set_002_neg 39# 40# DESCRIPTION: 41# 42# Malformed zpool set commands are rejected 43# 44# STRATEGY: 45# 1. Create an array of many different malformed zfs set arguments 46# 2. Run zpool set for each arg checking each will exit with status code 1 47# 48# 49# TESTABILITY: explicit 50# 51# TEST_AUTOMATION_LEVEL: automated 52# 53# CODING_STATUS: COMPLETED (2007-03-05) 54# 55# __stc_assertion_end 56# 57################################################################################ 58 59verify_runnable "global" 60 61# note to self - need to make sure there isn't a pool called bootfs 62# before running this test... 63function cleanup { 64 destroy_pool bootfs 65 $RM $TMPDIR/zpool_set_002.${TESTCASE_ID}.dat 66} 67 68$ZPOOL upgrade -v 2>&1 | $GREP "bootfs pool property" > /dev/null 69if [ $? -ne 0 ] 70then 71 log_unsupported "Pool properties not supported on this release." 72fi 73 74 75log_assert "Malformed zpool set commands are rejected" 76 77if poolexists bootfs 78then 79 log_unsupported "Unable to run test on a machine with a pool called \ 80 bootfs" 81fi 82 83log_onexit cleanup 84 85# build up an array of bad arguments. 86set -A arguments "rubbish " \ 87 "foo@bar= " \ 88 "@@@= +pool " \ 89 "zpool bootfs " \ 90 "bootfs " \ 91 "bootfs +" \ 92 "bootfs=bootfs/123 " \ 93 "bootfs=bootfs@val " \ 94 "Bootfs=bootfs " \ 95 "- " \ 96 "== " \ 97 "set " \ 98 "@@ " \ 99 "12345 " \ 100 "€にほんご " \ 101 "/ " \ 102 "bootfs=bootfs /" \ 103 "bootfs=a%d%s " 104 105 106# here, we build up a large string. 107# a word to the ksh-wary, ${#array[@]} gives you the 108# total number of entries in an array, so array[${#array[@]}] 109# will index the last entry+1, ksh arrays start at index 0. 110COUNT=0 111while [ $COUNT -le 1025 ] 112do 113 bigname="${bigname}o" 114 COUNT=$(( $COUNT + 1 )) 115done 116 117# add an argument of maximum length property name 118arguments[${#arguments[@]}]="$bigname=value" 119 120# add an argument of maximum length property value 121arguments[${#arguments[@]}]="bootfs=$bigname" 122 123# Create a pool called bootfs (so-called, so as to trip any clashes between 124# property name, and pool name) 125# Also create a filesystem in this pool 126VDEV=$TMPDIR/zpool_set_002.${TESTCASE_ID}.vdev 127log_must create_vdevs $VDEV 128log_must $ZPOOL create bootfs $VDEV 129log_must $ZFS create bootfs/root 130 131typeset -i i=0; 132while [ $i -lt "${#arguments[@]}" ] 133do 134 log_mustnot eval "$ZPOOL set ${arguments[$i]} > /dev/null 2>&1" 135 136 # now also try with a valid pool in the argument list 137 log_mustnot eval "$ZPOOL set ${arguments[$i]}bootfs > /dev/null 2>&1" 138 139 # now also try with two valid pools in the argument list 140 log_mustnot eval "$ZPOOL set ${arguments[$i]}bootfs bootfs > /dev/null" 141 i=$(( $i + 1)) 142done 143 144log_pass "Malformed zpool set commands are rejected" 145