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