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 2007 Sun Microsystems, Inc. All rights reserved. 27# Use is subject to license terms. 28# 29# ident "@(#)zfs_unmount_007_neg.ksh 1.3 07/10/09 SMI" 30# 31 32. $STF_SUITE/tests/cli_root/zfs_mount/zfs_mount.kshlib 33. $STF_SUITE/tests/cli_root/zfs_unmount/zfs_unmount.kshlib 34 35################################################################################ 36# 37# __stc_assertion_start 38# 39# ID: zfs_unmount_007_neg 40# 41# DESCRIPTION: 42# Try each 'zfs unmount' with inapplicable scenarios to make sure 43# it returns an error. include: 44# * Multiple filesystem|mountpoint specified 45# * '-a', but also with a specific filesystem|mountpoint. 46# 47# STRATEGY: 48# 1. Create an array of parameters 49# 2. For each parameter in the array, execute the sub-command 50# 3. Verify an error is returned. 51# 52# TESTABILITY: explicit 53# 54# TEST_AUTOMATION_LEVEL: automated 55# 56# CODING_STATUS: COMPLETED (2005-07-12) 57# 58# __stc_assertion_end 59# 60################################################################################ 61 62verify_runnable "both" 63 64multifs="$TESTFS $TESTFS1" 65datasets="" 66 67for fs in $multifs ; do 68 datasets="$datasets $TESTPOOL/$fs" 69done 70 71set -A args "$unmountall $TESTPOOL/$TESTFS" \ 72 "$unmountcmd $datasets" 73 74function setup_all 75{ 76 typeset fs 77 78 for fs in $multifs ; do 79 setup_filesystem "$DISKS" "$TESTPOOL" \ 80 "$fs" \ 81 "${TEST_BASE_DIR%%/}/testroot${TESTCASE_ID}/$TESTPOOL/$fs" 82 done 83 return 0 84} 85 86function cleanup_all 87{ 88 typeset fs 89 90 cleanup_filesystem "$TESTPOOL" "$TESTFS1" 91 log_must $ZFS set mountpoint=$TESTDIR $TESTPOOL/$TESTFS 92 93 [[ -d ${TEST_BASE_DIR%%/}/testroot${TESTCASE_ID} ]] && \ 94 $RM -rf ${TEST_BASE_DIR%%/}/testroot${TESTCASE_ID} 95 96 return 0 97} 98 99function verify_all 100{ 101 typeset fs 102 103 for fs in $multifs ; do 104 log_must mounted $TESTPOOL/$fs 105 done 106 return 0 107} 108 109log_assert "Badly-formed 'zfs $unmountcmd' with inapplicable scenarios " \ 110 "should return an error." 111log_onexit cleanup_all 112 113log_must setup_all 114 115typeset -i i=0 116while (( i < ${#args[*]} )); do 117 log_mustnot $ZFS ${args[i]} 118 ((i = i + 1)) 119done 120 121log_must verify_all 122 123log_pass "Badly formed 'zfs $unmountcmd' with inapplicable scenarios " \ 124 "fail as expected." 125