1 #! /usr/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 2009 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
26 #
27
28 . ${STF_SUITE}/include/nfsgen.kshlib
29
30 NAME=$(basename $0)
31 CDIR=$(dirname $0)
32
33 # Turn on debug info, if requested
34 export _NFS_STF_DEBUG=$_NFS_STF_DEBUG:$NFSGEN_DEBUG
35 [[ :$NFSGEN_DEBUG: = *:${NAME}:* || :${NFSGEN_DEBUG}: = *:all:* ]] \
36 && set -x
37
38 if [[ $IS_KRB5 == 1 ]]; then
39 echo "Open and lock test don't support krb5"
40 exit $STF_PASS
41 fi
42
43 [[ $SETUP == none ]] && deleg_conf=none \
44 || deleg_conf="on off"
45
46 typeset -i i
47 RUNTEST=${STF_SUITE}/tests/openlock/runtests
48 for deleg in $deleg_conf; do
49 for tprog in opentest locktest; do
50 for scen in A B C D E; do
51 i=1
52 mode_index=0
53 # open tests
54 if [[ $tprog == "opentest" ]]; then
55 while (( $mode_index < 7)); do
56 [[ $scen == A && $mode_index > 3 ]] && break;
57 [[ $scen == B && $mode_index > 3 ]] && break;
58 # for scenarioD, we only set mode to 0600
59 [[ $scen == D && $mode_index != 0 ]] && break;
60 oflag_index=0
61 while (( $oflag_index < 4)); do
62 [[ $scen == D && $oflag_index > 2 ]] && break;
63
64 [[ $deleg == "none" ]] \
65 && prefix=open_scen${scen}_pos \
66 || prefix=open_Deleg${deleg}_scen${scen}_pos
67 tname=$(get_casename $prefix $i)
68 echo "adding $tname: scenario${scen}, \c"
69 echo "DELEG=$deleg, MODE_INDEX=$mode_index, \c"
70 echo "OFLAG_INDEX=$oflag_index"
71 stf_addassert -u root -t $tname -c $RUNTEST \
72 "$tprog $tname $deleg $scen $mode_index $oflag_index"
73 i=`expr $i + 1`
74 oflag_index=`expr $oflag_index + 1`
75
76 # We only have one case for E
77 # set mode to 0755 and flag to O_TRUNC
78 [[ $scen == E ]] && break 2;
79 done
80 mode_index=`expr $mode_index + 1`
81 done
82 # lock tests
83 else
84 [[ $scen == "D" || $scen == "E" ]] && break
85 while (( $mode_index < 3)); do
86 for oflag_index in 0 1 2 3; do
87 # mode(0400) is only allowed to combine with flag(O_RDONLY)
88 [[ $mode_index == 1 && $oflag_index != 3 ]] && continue
89
90 # mode(0200) is only allowed to combine with flag(O_WRONLY)
91 [[ $mode_index == 2 && $oflag_index != 2 ]] && continue
92
93 [[ $deleg == "none" ]] \
94 && prefix=lock_scen${scen}_pos \
95 || prefix=lock_Deleg${deleg}_scen${scen}_pos
96 tname=$(get_casename $prefix $i)
97 echo "adding $tname: scenario${scen}, \c"
98 echo "DELEG=$deleg, MODE_INDEX=$mode_index, \c"
99 echo "OFLAG_INDEX=$oflag_index"
100 stf_addassert -u root -t $tname -c $RUNTEST \
101 "$tprog $tname $deleg $scen $mode_index $oflag_index"
102 i=`expr $i + 1`
103
104 # We only have one case for C, set mode to 0600
105 # flag to O_CREAT|O_TRUNC|O_RDWR
106 [[ $scen == C ]] && break 2;
107 done
108 mode_index=`expr $mode_index + 1`
109 done
110 fi
111 done
112 done
113 done
114
115 exit 0