1*f67950b2SNasf-Fan#!/bin/ksh -p
2*f67950b2SNasf-Fan#
3*f67950b2SNasf-Fan# CDDL HEADER START
4*f67950b2SNasf-Fan#
5*f67950b2SNasf-Fan# The contents of this file are subject to the terms of the
6*f67950b2SNasf-Fan# Common Development and Distribution License (the "License").
7*f67950b2SNasf-Fan# You may not use this file except in compliance with the License.
8*f67950b2SNasf-Fan#
9*f67950b2SNasf-Fan# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*f67950b2SNasf-Fan# or http://www.opensolaris.org/os/licensing.
11*f67950b2SNasf-Fan# See the License for the specific language governing permissions
12*f67950b2SNasf-Fan# and limitations under the License.
13*f67950b2SNasf-Fan#
14*f67950b2SNasf-Fan# When distributing Covered Code, include this CDDL HEADER in each
15*f67950b2SNasf-Fan# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*f67950b2SNasf-Fan# If applicable, add the following below this CDDL HEADER, with the
17*f67950b2SNasf-Fan# fields enclosed by brackets "[]" replaced with your own identifying
18*f67950b2SNasf-Fan# information: Portions Copyright [yyyy] [name of copyright owner]
19*f67950b2SNasf-Fan#
20*f67950b2SNasf-Fan# CDDL HEADER END
21*f67950b2SNasf-Fan#
22*f67950b2SNasf-Fan
23*f67950b2SNasf-Fan#
24*f67950b2SNasf-Fan# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
25*f67950b2SNasf-Fan# Use is subject to license terms.
26*f67950b2SNasf-Fan#
27*f67950b2SNasf-Fan
28*f67950b2SNasf-Fan#
29*f67950b2SNasf-Fan# Copyright (c) 2017 by Fan Yong. All rights reserved.
30*f67950b2SNasf-Fan#
31*f67950b2SNasf-Fan
32*f67950b2SNasf-Fan. $STF_SUITE/tests/functional/projectquota/projectquota_common.kshlib
33*f67950b2SNasf-Fan
34*f67950b2SNasf-Fan#
35*f67950b2SNasf-Fan#
36*f67950b2SNasf-Fan# DESCRIPTION:
37*f67950b2SNasf-Fan#	Check 'zfs project' invalid options combinations
38*f67950b2SNasf-Fan#
39*f67950b2SNasf-Fan#
40*f67950b2SNasf-Fan# STRATEGY:
41*f67950b2SNasf-Fan#	Verify the following:
42*f67950b2SNasf-Fan#	1. "-c" only supports "-d", "-p", "-r" and "-0".
43*f67950b2SNasf-Fan#	2. "-C" only supports "-r" and "-k".
44*f67950b2SNasf-Fan#	3. "-s" only supports "-r" and "-p".
45*f67950b2SNasf-Fan#	4. "-c", "-C" and "-s" can NOT be specified together.
46*f67950b2SNasf-Fan#	5. "-d" can overwirte former "-r".
47*f67950b2SNasf-Fan#	6. "-r" can overwirte former "-d".
48*f67950b2SNasf-Fan#	7. "-0" must be together with "-c".
49*f67950b2SNasf-Fan#	8. "-d" must be on directory.
50*f67950b2SNasf-Fan#	9. "-r" must be on directory.
51*f67950b2SNasf-Fan#	10. "-p" must be together with "-c -r" or "-s".
52*f67950b2SNasf-Fan#
53*f67950b2SNasf-Fan
54*f67950b2SNasf-Fanfunction cleanup
55*f67950b2SNasf-Fan{
56*f67950b2SNasf-Fan	log_must rm -rf $PRJDIR
57*f67950b2SNasf-Fan}
58*f67950b2SNasf-Fan
59*f67950b2SNasf-Fanlog_onexit cleanup
60*f67950b2SNasf-Fan
61*f67950b2SNasf-Fanlog_assert "Check 'zfs project' invalid options combinations"
62*f67950b2SNasf-Fan
63*f67950b2SNasf-Fanlog_must mkdir $PRJDIR
64*f67950b2SNasf-Fanlog_must mkdir $PRJDIR/a1
65*f67950b2SNasf-Fanlog_must touch $PRJDIR/a2
66*f67950b2SNasf-Fan
67*f67950b2SNasf-Fanlog_mustnot zfs project -c
68*f67950b2SNasf-Fanlog_mustnot zfs project -c -k $PRJDIR/a1
69*f67950b2SNasf-Fanlog_mustnot zfs project -c -C $PRJDIR/a1
70*f67950b2SNasf-Fanlog_mustnot zfs project -c -s $PRJDIR/a1
71*f67950b2SNasf-Fanlog_must zfs project -c -d -r $PRJDIR/a1
72*f67950b2SNasf-Fanlog_must zfs project -c -r -d $PRJDIR/a1
73*f67950b2SNasf-Fanlog_mustnot zfs project -c -d $PRJDIR/a2
74*f67950b2SNasf-Fanlog_mustnot zfs project -c -r $PRJDIR/a2
75*f67950b2SNasf-Fan
76*f67950b2SNasf-Fanlog_mustnot zfs project -C
77*f67950b2SNasf-Fanlog_mustnot zfs project -C -c $PRJDIR/a1
78*f67950b2SNasf-Fanlog_mustnot zfs project -C -d $PRJDIR/a1
79*f67950b2SNasf-Fanlog_mustnot zfs project -C -p 100 $PRJDIR/a1
80*f67950b2SNasf-Fanlog_mustnot zfs project -C -s $PRJDIR/a1
81*f67950b2SNasf-Fanlog_mustnot zfs project -C -r -0 $PRJDIR/a1
82*f67950b2SNasf-Fanlog_mustnot zfs project -C -0 $PRJDIR/a1
83*f67950b2SNasf-Fan
84*f67950b2SNasf-Fanlog_mustnot zfs project -s
85*f67950b2SNasf-Fanlog_mustnot zfs project -s -d $PRJDIR/a1
86*f67950b2SNasf-Fanlog_mustnot zfs project -s -k $PRJDIR/a1
87*f67950b2SNasf-Fanlog_mustnot zfs project -s -r -0 $PRJDIR/a1
88*f67950b2SNasf-Fanlog_mustnot zfs project -s -0 $PRJDIR/a1
89*f67950b2SNasf-Fanlog_mustnot zfs project -s -r $PRJDIR/a2
90*f67950b2SNasf-Fan
91*f67950b2SNasf-Fanlog_mustnot zfs project -p 100
92*f67950b2SNasf-Fanlog_mustnot zfs project -p -1 $PRJDIR/a2
93*f67950b2SNasf-Fanlog_mustnot zfs project -p 100 -d $PRJDIR/a1
94*f67950b2SNasf-Fanlog_mustnot zfs project -p 100 -k $PRJDIR/a1
95*f67950b2SNasf-Fanlog_mustnot zfs project -p 100 -0 $PRJDIR/a1
96*f67950b2SNasf-Fanlog_mustnot zfs project -p 100 -r -0 $PRJDIR/a1
97*f67950b2SNasf-Fan
98*f67950b2SNasf-Fanlog_mustnot zfs project
99*f67950b2SNasf-Fanlog_mustnot zfs project -0 $PRJDIR/a2
100*f67950b2SNasf-Fanlog_mustnot zfs project -k $PRJDIR/a2
101*f67950b2SNasf-Fanlog_mustnot zfs project -S $PRJDIR/a1
102*f67950b2SNasf-Fan
103*f67950b2SNasf-Fanlog_pass "Check 'zfs project' invalid options combinations"
104