1 #
2 # CDDL HEADER START
3 #
4 # The contents of this file are subject to the terms of the
5 # Common Development and Distribution License (the "License").
6 # You may not use this file except in compliance with the License.
7 #
8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 # or http://www.opensolaris.org/os/licensing.
10 # See the License for the specific language governing permissions
11 # and limitations under the License.
12 #
13 # When distributing Covered Code, include this CDDL HEADER in each
14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 # If applicable, add the following below this CDDL HEADER, with the
16 # fields enclosed by brackets "[]" replaced with your own identifying
17 # information: Portions Copyright [yyyy] [name of copyright owner]
18 #
19 # CDDL HEADER END
20 #
21
22 #
23 # Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 # Use is subject to license terms.
25 #
26 # NFSv4 OPENATTR operation test - positive tests
27
28 # include all test enironment
29 source OPENATTR.env
30
31 # connect to the test server
32 Connect
33
34 # setting local variables
35 set TNAME $argv0
36 set bfh [get_fh "$BASEDIRS"]
37
38
39 # Start testing
40 # --------------------------------------------------------------
41 # a: OPENATTR w/create on a regular file - expect OK
42 set expcode "OK"
43 set ASSERTION "OPENATTR w/create on a regular file, expect $expcode"
44 set tag "$TNAME{a}"
45 putmsg stdout 0 "$tag: $ASSERTION"
46 set res [compound {Putfh $bfh; Lookup $env(RWFILE); Openattr T; Getattr type}]
47 if {[ckres "Openattr" $status $expcode $res $FAIL] == "true"} {
48 # verify the type of new <cfh> is attrdir
49 set attr [extract_attr [lindex [lindex $res 3] 2] "type"]
50 if {$attr != "attrdir"} {
51 putmsg stderr 0 \
52 "\t Test FAIL: Openattr(T) got type=($attr), expected=(attrdir)"
53 putmsg stderr 1 "\t res=($res)"
54 } else {
55 logres PASS
56 }
57 }
58
59
60 # b: OPENATTR w/create on a symlinked directory
61 # Solaris server doesn't support this.
62 #
63 set ASSERTION "OPENATTR w/create on a symlinked directory, expect $expcode"
64 set tag "$TNAME{b}"
65 putmsg stdout 0 "$tag: $ASSERTION"
66 set res [compound {Putfh $bfh; Lookup $env(SYMLDIR); Openattr T; Getattr type}]
67 if { "$env(SRVOS)" == "Solaris" } {
68 set expcode "NOTSUPP"
69 ckres "Openattr" $status $expcode $res $PASS
70 } else {
71 set expcode "OK"
72 if {[ckres "Openattr" $status $expcode $res $FAIL] == "true"} {
73 # verify the type of new <cfh> is attrdir
74 set attr [extract_attr [lindex [lindex $res 3] 2] "type"]
75 if {$attr != "attrdir"} {
76 putmsg stderr 0 \
77 "\t Test FAIL: Openattr(T) got type=($attr), expected=(attrdir)"
78 putmsg stderr 1 "\t res=($res)"
79 } else {
80 logres PASS
81 }
82 }
83 }
84
85
86 # c: OPENATTR none-create on a file w/attrdir exists - expect OK
87 set expcode "OK"
88 set ASSERTION "OPENATTR none-create on a file w/attrdir exists, expect $expcode"
89 set tag "$TNAME{c}"
90 putmsg stdout 0 "$tag: $ASSERTION"
91 set res [compound {Putfh $bfh; Lookup $env(ATTRFILE); Openattr F;
92 Getattr type; Lookup $env(ATTRFILE_AT1); Getattr type}]
93 if {[ckres "Openattr" $status $expcode $res $FAIL] == "true"} {
94 # verify the type of new <cfh> is attrdir
95 set attrd [extract_attr [lindex [lindex $res 3] 2] "type"]
96 set attrf [extract_attr [lindex [lindex $res 5] 2] "type"]
97 if {$attrd != "attrdir"} {
98 putmsg stderr 0 \
99 "\t Test FAIL: Openattr(F) got type=($attr), expected=(attrdir)"
100 putmsg stderr 1 "\t res=($res)"
101 } else {
102 if {$attrf != "namedattr"} {
103 putmsg stderr 0 \
104 "\t Test FAIL: unexpected attr type in attrdir"
105 putmsg stderr 0 "got=($attr), expected=(namedattr)"
106 putmsg stderr 1 "\t res=($res)"
107 } else {
108 logres PASS
109 }
110 }
111 }
112
113
114 # d: OPENATTR(T) on a noperm_dir wattrdir readable - expect ACCESS
115 set expcode "ACCESS"
116 set ASSERTION "OPENATTR(T) on a noperm_dir w/attrdir readable, expect $expcode"
117 set tag "$TNAME{d}"
118 putmsg stdout 0 "$tag: $ASSERTION"
119 set res [compound {Putfh $bfh; Lookup $env(ATDIR_NP);
120 Openattr T; Getattr type; Lookup $env(ATTRDIR_AT1); Getattr type}]
121 ckres "Openattr" $status $expcode $res $PASS
122
123
124 # --------------------------------------------------------------
125 # disconnect and exit
126 Disconnect
127 exit $PASS