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 2008 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
26 #
27 # control program for SETATTR op tests
28
29
30 [[ -n $DEBUG && $DEBUG != 0 ]] && set -x
31
32 NAME=$(basename $0)
33 DIR=$(dirname $0)
34 CDIR=$(pwd)
35 TESTROOT=${TESTROOT:-"$CDIR/../../"}
36 TESTTAG="SETATTR"
37 TESTLIST=$(egrep -v "^#|^ *$" ${TESTTAG}.flist)
38
39 # sourcing framework global environment variables created after go_setup
40 # and for this purpose only this file should be sourced
41 CONFIGFILE=/var/tmp/nfsv4/config/config.suite
42 if [[ ! -f $CONFIGFILE ]]; then
43 echo "$NAME: CONFIGFILE[$CONFIGFILE] not found;"
44 echo "\texit UNINITIATED."
45 exit 6
46 fi
47 . $CONFIGFILE
48
49 #source support functions
50 TESTSH="$TESTROOT/testsh"
51 . $TESTSH
52
53 iscipso=0
54 is_cipso "vers=4" $SERVER
55 if (( $? == $CIPSO_NFSV4 )); then
56 iscipso=1
57
58 # We need to do "Setattr" operation in non-global zone
59 # for TX test, so add two tcl scripts to the zone.
60
61 # setattr_pos02{a}
62 cat > $ZONE_PATH/root/setattr_pos02 << __EOF
63 connect $SERVER
64 set res [compound {Putfh \$env(qfh); Lookup \$env(tf); \
65 Setattr {0 0} {{mode \$env(mode)}}; Getattr mode}]
66 puts "\$status \$res"
67 disconnect
68 __EOF
69
70 # setattr_neg04{a}
71 cat > $ZONE_PATH/root/setattr_neg04 << __EOF
72 connect $SERVER
73 # first get clientid
74 set verifier "[pid][expr int([expr [expr rand()] * 100000000])]"
75 set res [compound {Setclientid \$verifier \$env(owner) {0 0 0}}]
76 if {\$status == "OK"} {
77 set clientid [lindex [lindex [lindex \$res 0] 2] 0]
78 set verifier [lindex [lindex [lindex \$res 0] 2] 1]
79 } else {
80 puts stderr "Setclientid failed, status=\$status, res=\$res"
81 exit
82 }
83 set res [compound {Setclientid_confirm \$clientid \$verifier}]
84 # Secondly do "Open" to get stateid
85 set res [compound {Putfh \$env(qfh); Open 1 3 0 "\$clientid \$env(owner)" \
86 {0 0 {{mode 664} {size 0}}} {0 \$env(tf)}; Getfh}]
87 set stateid [lindex [lindex \$res 1] 2]
88 set rflags [lindex [lindex \$res 1] 4]
89 set nfh [lindex [lindex \$res 2] 2]
90 set OPEN4_RESULT_CONFIRM 2
91 if {[expr \$rflags & \$OPEN4_RESULT_CONFIRM] == \$OPEN4_RESULT_CONFIRM} {
92 set res [compound {Putfh \$nfh; Open_confirm \$stateid 2}]
93 if {\$status != "OK"} {
94 puts stderr "Open_confirm failed. status=(\$status). res=\$res"
95 exit
96 }
97 set stateid [lindex [lindex \$res 1] 2]
98 }
99 # Finally do "Setattr"
100 set res [compound {Putfh \$nfh; Setattr \$stateid {{size \$env(fsize)}}}]
101 if {\$status != "DQUOT"} {
102 puts stderr "\t Test Fail: Setattr return \$status, expected DQUOT"
103 } else {
104 puts stdout "\t Test PASS"
105 set res [compound {Putfh \$nfh; Close 3 \$stateid}]
106 }
107 disconnect
108 __EOF
109
110 fi
111
112 # Start the tests with some information
113 echo
114 echo "Testing at CLIENT=[$CLIENT] to SERVER=[$SERVER]"
115 echo "Started $TESTTAG op tests at [$(date)] ..."
116 echo
117
118 # Now ready to run the tests
119 (
120 for t in $TESTLIST; do
121 # Need to switch to $TUSER2 for quota testing
122 grep QUOT $t >/dev/null 2>&1
123 rc=$?
124 grep $TUSER2 /etc/passwd >/dev/null 2>&1
125 rc=$(( $rc + $iscipso + $? ))
126 if (( $rc == 0 )); then
127 su $TUSER2 -c "(. $CONFIGFILE; \
128 $TESTROOT/nfsh $t)"
129 else
130 $TESTROOT/nfsh $t
131 fi
132 done
133 )
134
135 [[ $iscipso == 1 ]] && rm $ZONE_PATH/root/setattr_pos02 \
136 $ZONE_PATH/root/setattr_neg04
137
138 echo
139 echo "Testing ends at [$(date)]."
140 echo
141 exit $PASS