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 2006 Sun Microsystems, Inc. All rights reserved.
24 # Use is subject to license terms.
25 #
26 # NFSv4 OPEN operation test - negative tests
27 # Verify server returns correct errors with negative requests.
28
29 # include all test enironment
30 source OPEN.env
31
32 # connect to the test server
33 Connect
34
35 # setting local variables
36 set TNAME $argv0
37 set bfh [get_fh $BASEDIRS]
38 set cid [getclientid $TNAME.[pid]]
39 if {$cid == -1} {
40 putmsg stdout 0 "$TNAME: test setup - getclientid"
41 putmsg stderr 0 "\t Test UNRESOLVED: unable to get clientid"
42 exit $UNRESOLVED
43 }
44 set seqid 1
45 set owner "$TNAME-OpenOwner"
46
47
48 # Start testing
49 # --------------------------------------------------------------
50 # a: Open(NOCREATE) access=R, a file w/mode=000, expect ACCESS
51 set expcode "ACCESS"
52 set ASSERTION "Open(NOCREATE) access=R, a file w/mode=000, expect $expcode"
53 set tag "$TNAME{a}"
54 putmsg stdout 0 "$tag: $ASSERTION"
55 set res [compound {Putfh $bfh; Open $seqid 1 0 "$cid $owner-a" \
56 {0 0 {{mode 0644}}} {0 $env(FNOPERM)}}]
57 ckres "Open" $status $expcode $res $PASS
58
59
60 # b: Open(NOCREATE) access=W, a file w/mode=444, expect ACCESS
61 set expcode "ACCESS"
62 set ASSERTION "Open(NOCREATE) access=W, a file w/mode=444, expect $expcode"
63 set tag "$TNAME{b}"
64 putmsg stdout 0 "$tag: $ASSERTION"
65 set res [compound {Putfh $bfh; Open $seqid 2 0 "$cid $owner-b" \
66 {0 0 {{mode 0644}}} {0 $env(ROFILE)}}]
67 ckres "Open" $status $expcode $res $PASS
68
69
70 # c: Open(NOCREATE) a file under dir_noperm, expect ACCESS
71 set expcode "ACCESS"
72 set ASSERTION "Open(NOCREATE) a file under dir_noperm, expect $expcode"
73 set tag "$TNAME{c}"
74 putmsg stdout 0 "$tag: $ASSERTION"
75 set res [compound {Putfh $bfh; Lookup $env(DNOPERM);
76 Open $seqid 3 0 "$cid $owner-c" {0 0 {{mode 0644}}} {0 $env(ROFILE)}}]
77 ckres "Open" $status $expcode $res $PASS
78
79
80 # d: Open(CREATE/UNCHECKED) in a dir w/o WRITE permission, expect ACCESS
81 set expcode "ACCESS"
82 set ASSERTION "Open(CREATE/UNCHECKED) in a dir w/o WRITE perm, expect $expcode"
83 set tag "$TNAME{d}"
84 putmsg stdout 0 "$tag: $ASSERTION"
85 set res [compound {Putfh $bfh; Lookup $env(DIR0755);
86 Open $seqid 3 0 "$cid owner-d" {1 0 {{mode 0644}}} {0 "$TNAME-d"};
87 Getfh}]
88 ckres "Open" $status $expcode $res $PASS
89
90
91 # e: Open(CREATE/UNCHECKED) access=RW, w/file exist & RO, expect ACCESS
92 set expcode "ACCESS"
93 set ASSERTION \
94 "Open(CREATE/UNCHECKED) access=RW, w/file exist & RO, expect $expcode"
95 set tag "$TNAME{e}"
96 putmsg stdout 0 "$tag: $ASSERTION"
97 set res [compound {Putfh $bfh; Open $seqid 3 0 "$cid $owner-e" \
98 {1 0 {{mode 0644}}} {0 "$env(ROEMPTY)"}; Getfh}]
99 ckres "Open" $status $expcode $res $PASS
100
101
102 # m: Open(CREATE/UNCHECKED) size=1,access=R, w/file exist & RO, expect ACCESS
103 set expcode "ACCESS"
104 set ASSERTION \
105 "Open(CREATE/UNCHECKED) sz=0,access=R, w/file is RO, expect $expcode"
106 set tag "$TNAME{m}"
107 putmsg stdout 0 "$tag: $ASSERTION"
108 set res [compound {Putfh $bfh; Open $seqid 1 0 "$cid $owner-m" \
109 {1 0 {{size 0}}} {0 "$env(ROFILE)"}; Getfh}]
110 ckres "Open" $status $expcode $res $PASS
111
112
113 # --------------------------------------------------------------
114 # disconnect and exit
115 Disconnect
116 exit $PASS