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