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# ident	"@(#)onoffs_001_pos.ksh	1.2	07/01/09 SMI"
28#
29
30. $STF_SUITE/include/libtest.kshlib
31. $STF_SUITE/tests/cli_root/zfs_set/zfs_set_common.kshlib
32
33###############################################################################
34#
35# __stc_assertion_start
36#
37# ID: onoffs_001_pos
38#
39# DESCRIPTION:
40# Setting a valid value to atime, readonly, or setuid on file
41# system or volume. It should be successful.
42#
43# STRATEGY:
44# 1. Create pool and filesystem & volume within it.
45# 2. Setting valid value, it should be successful.
46#
47# TESTABILITY: explicit
48#
49# TEST_AUTOMATION_LEVEL: automated
50#
51# CODING_STATUS: COMPLETED (2005-07-04)
52#
53# __stc_assertion_end
54#
55################################################################################
56
57verify_runnable "both"
58
59function cleanup
60{
61	log_must $ZFS mount -a
62}
63
64log_onexit cleanup
65
66set -A props "atime" "readonly" "setuid"
67set -A values "on" "off"
68
69if is_global_zone ; then
70	set -A dataset "$TESTPOOL/$TESTFS" "$TESTPOOL/$TESTCTR" "$TESTPOOL/$TESTVOL"
71else
72	set -A dataset "$TESTPOOL/$TESTFS" "$TESTPOOL/$TESTCTR"
73fi
74
75log_assert "Setting a valid value to atime, readonly, or setuid on file" \
76	"system or volume. It should be successful."
77
78typeset -i i=0
79typeset -i j=0
80typeset -i k=0
81while (( i < ${#dataset[@]} )); do
82	j=0
83	while (( j < ${#props[@]} )); do
84		k=0
85		while (( k < ${#values[@]} )); do
86			if [[ ${dataset[i]} == "$TESTPOOL/$TESTVOL" &&  \
87			    ${props[j]} != "readonly" ]]
88			then
89				set_n_check_prop "${values[k]}" "${props[j]}" \
90				    "${dataset[i]}" "false"
91			else
92				set_n_check_prop "${values[k]}" "${props[j]}" \
93					"${dataset[i]}"
94			fi
95
96			(( k += 1 ))
97		done
98		(( j += 1 ))
99	done
100	(( i += 1 ))
101done
102
103log_pass "Setting a valid value to atime, readonly, or setuid on file" \
104	"system or volume pass."
105