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# DESCRIPTION:
36*f67950b2SNasf-Fan#	Check the invalid parameter of zfs set project{obj}quota
37*f67950b2SNasf-Fan#
38*f67950b2SNasf-Fan#
39*f67950b2SNasf-Fan# STRATEGY:
40*f67950b2SNasf-Fan#	1. check the invalid zfs set project{obj}quota to fs
41*f67950b2SNasf-Fan#	2. check the valid zfs set project{obj}quota to snapshots
42*f67950b2SNasf-Fan#
43*f67950b2SNasf-Fan
44*f67950b2SNasf-Fanfunction cleanup
45*f67950b2SNasf-Fan{
46*f67950b2SNasf-Fan	if datasetexists $snap_fs; then
47*f67950b2SNasf-Fan		log_must zfs destroy $snap_fs
48*f67950b2SNasf-Fan	fi
49*f67950b2SNasf-Fan
50*f67950b2SNasf-Fan	log_must cleanup_projectquota
51*f67950b2SNasf-Fan}
52*f67950b2SNasf-Fan
53*f67950b2SNasf-Fanlog_onexit cleanup
54*f67950b2SNasf-Fan
55*f67950b2SNasf-Fanlog_assert "Check the invalid parameter of zfs set project{obj}quota"
56*f67950b2SNasf-Fantypeset snap_fs=$QFS@snap
57*f67950b2SNasf-Fan
58*f67950b2SNasf-Fanlog_must zfs snapshot $snap_fs
59*f67950b2SNasf-Fan
60*f67950b2SNasf-Fanset -A no_prjs "mms1234" "ss@#" "root-122" "-1"
61*f67950b2SNasf-Fanfor prj in "${no_prjs[@]}"; do
62*f67950b2SNasf-Fan	log_mustnot zfs set projectquota@$prj=100m $QFS
63*f67950b2SNasf-Fandone
64*f67950b2SNasf-Fan
65*f67950b2SNasf-Fanlog_note "can set all numeric id even that id does not exist"
66*f67950b2SNasf-Fanlog_must zfs set projectquota@12345678=100m $QFS
67*f67950b2SNasf-Fan
68*f67950b2SNasf-Fanset -A sizes "100mfsd" "m0.12m" "GGM" "-1234-m" "123m-m"
69*f67950b2SNasf-Fanfor size in "${sizes[@]}"; do
70*f67950b2SNasf-Fan	log_note "can not set projectquota with invalid size parameter"
71*f67950b2SNasf-Fan	log_mustnot zfs set projectquota@$PRJID1=$size $QFS
72*f67950b2SNasf-Fandone
73*f67950b2SNasf-Fan
74*f67950b2SNasf-Fanlog_note "can not set projectquota to snapshot $snap_fs"
75*f67950b2SNasf-Fanlog_mustnot zfs set projectquota@$PRJID1=100m $snap_fs
76*f67950b2SNasf-Fan
77*f67950b2SNasf-Fanfor prj in "${no_prjs[@]}"; do
78*f67950b2SNasf-Fan	log_mustnot zfs set projectobjquota@$prj=100 $QFS
79*f67950b2SNasf-Fandone
80*f67950b2SNasf-Fan
81*f67950b2SNasf-Fanlog_note "can not set projectobjquota with invalid size parameter"
82*f67950b2SNasf-Fanlog_mustnot zfs set projectobjquota@$PRJID2=100msfsd $QFS
83*f67950b2SNasf-Fan
84*f67950b2SNasf-Fanlog_note "can not set projectobjquota to snapshot $snap_fs"
85*f67950b2SNasf-Fanlog_mustnot zfs set projectobjquota@$PRJID2=100m $snap_fs
86*f67950b2SNasf-Fan
87*f67950b2SNasf-Fanlog_pass "Check the invalid parameter of zfs set project{obj}quota"
88