1#!/bin/ksh -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/include/libtest.shlib
28
29#
30# DESCRIPTION:
31# A reservation of 'none' (which is an alias for 0) should be allowed. This
32# test verifies that is true.
33#
34# STRATEGY:
35# 1. Create a new file system in the test pool.
36# 2. Set the reservation to 'none'.
37# 3. Verify the associated reservation is indeed 0.
38# 4. Repeat with reservation set to 0.
39#
40
41verify_runnable "both"
42
43# Use a unique value so earlier test failures will not impact this test.
44RESERVATION="reserve"-$$
45RESERVATION2="reserve2"-$$
46
47function cleanup
48{
49	typeset FS
50	for FS in $TESTPOOL/$RESERVATION $TESTPOOL/$RESERVATION2
51	do
52		if datasetexists $FS ; then
53			log_must $ZFS unmount $FS
54			log_must $ZFS destroy $FS
55		fi
56	done
57}
58
59log_onexit cleanup
60
61log_assert "Ensure a reservation of 0 or 'none' is allowed."
62
63log_must $ZFS create $TESTPOOL/$RESERVATION
64log_must $ZFS create $TESTPOOL/$RESERVATION2
65
66log_must $ZFS set reservation=0 $TESTPOOL/$RESERVATION
67log_must $ZFS set reservation=none $TESTPOOL/$RESERVATION2
68
69for FS in $TESTPOOL/$RESERVATION $TESTPOOL/$RESERVATION2
70do
71
72	reserve=`$ZFS get -pH reservation $FS | $AWK '{print $3}'`
73	if [[ $reserve -ne 0 ]]; then
74		log_fail "ZFS get -p reservation did not return 0"
75	fi
76
77	reserve=`$ZFS get -H reservation $FS | $AWK '{print $3}'`
78	if [[ $reserve != "none" ]]; then
79		log_fail "ZFS get reservation did not return 'none'"
80	fi
81done
82
83log_pass "Successfully set reservation to 0 and 'none'"
84