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) '.', expect INVAL|NOENT
  51 set expcode "INVAL|NOENT"
  52 set ASSERTION "Open (NOCREATE) of '.', expect $expcode"
  53 set tag "$TNAME{a}"
  54 putmsg stdout 0 "$tag: $ASSERTION"
  55 set res [compound {Putfh $bfh; Open $seqid 3 0 "$cid $owner-a" \
  56         {0 0 {{mode 0644}}} {0 "."}; Getfh}]
  57 ckres "Open" $status $expcode $res $PASS
  58 
  59 
  60 # b: Open(CREATE/UNCHECKED) '.', expect INVAL|OK
  61 set expcode "INVAL|OK"
  62 set ASSERTION "Open (CREATE/UNCHECKED) of '.', expect $expcode"
  63 set tag "$TNAME{b}"
  64 putmsg stdout 0 "$tag: $ASSERTION"
  65 set res [compound {Putfh $bfh; Open $seqid 3 0 "$cid $owner-b" \
  66         {1 0 {{mode 0644}}} {0 "."}; Getfh}]
  67 ckres "Open" $status $expcode $res $PASS
  68 
  69 
  70 # c: Open(NOCREATE) '..', expect INVAL|NOENT
  71 set expcode "INVAL|NOENT"
  72 set ASSERTION "Open (NOCREATE) of '..', expect $expcode"
  73 set tag "$TNAME{c}"
  74 putmsg stdout 0 "$tag: $ASSERTION"
  75 set res [compound {Putfh $bfh; Open $seqid 3 0 "$cid $owner-c" \
  76         {0 0 {{mode 0644}}} {0 ".."}; Getfh}]
  77 ckres "Open" $status $expcode $res $PASS
  78 
  79 
  80 # d: Open(CREATE/UNCHECKED) '..', expect INVAL|OK
  81 set expcode "INVAL|OK"
  82 set ASSERTION "Open (CREATE/UNCHECKED) of '..', expect $expcode"
  83 set tag "$TNAME{d}"
  84 putmsg stdout 0 "$tag: $ASSERTION"
  85 set res [compound {Putfh $bfh; Open $seqid 3 0 "$cid $owner-d" \
  86         {1 0 {{mode 0644}}} {0 ".."}; Getfh}]
  87 ckres "Open" $status $expcode $res $PASS
  88 
  89 
  90 # g: Open(CREATE) with empty filename, expect INVAL
  91 set expcode "INVAL"
  92 set ASSERTION "Open(CREATE) with empty filename, expect $expcode"
  93 set tag "$TNAME{g}"
  94 putmsg stdout 0 "$tag: $ASSERTION"
  95 set res [compound {Putfh $bfh; Open $seqid 3 0 "$cid $owner-g" \
  96         {1 0 {{mode 0644}}} {0 ""}; Getfh}]
  97 ckres "Open" $status $expcode $res $PASS
  98 
  99 
 100 # h: Open(CREATE) with 'name' includes path delimiter, expect INVAL
 101 set expcode "INVAL"
 102 set ASSERTION "Open with 'name' includes path delimiter, expect $expcode"
 103 set tag "$TNAME{h}"
 104 putmsg stdout 0 "$tag: $ASSERTION"
 105 set res [compound {Putfh $bfh; Open $seqid 3 0 "$cid $owner-h" \
 106         {1 0 {{mode 0644}}} {0 "XX${DELM}xx"}; Getfh}]
 107 ckres "Open" $status $expcode $res $PASS
 108 
 109 
 110 # m: Open(NOCREATE) with invalid access(0), expect INVAL
 111 set expcode "INVAL"
 112 set ASSERTION "Open(NOCREATE) with invalid access(0), expect $expcode"
 113 set tag "$TNAME{m}"
 114 putmsg stdout 0 "$tag: $ASSERTION"
 115 set res [compound {Putfh $bfh; Open $seqid 0 0 "$cid $owner-m" \
 116         {0 0 {{mode 0644}}} {0 "$env(ROFILE)"}; Getfh}]
 117 ckres "Open" $status $expcode $res $PASS
 118 
 119 
 120 # n: Open(NOCREATE) with invalid access(4), expect INVAL
 121 set expcode "INVAL"
 122 set ASSERTION "Open(NOCREATE) with invalid access(4), expect $expcode"
 123 set tag "$TNAME{n}"
 124 putmsg stdout 0 "$tag: $ASSERTION"
 125 set res [compound {Putfh $bfh; Open $seqid 4 0 "$cid $owner-n" \
 126         {0 0 {{mode 0644}}} {0 "$env(ROFILE)"}; Getfh}]
 127 ckres "Open" $status $expcode $res $PASS
 128 
 129 
 130 # o: Open(NOCREATE) with invalid deny(4), expect INVAL
 131 set expcode "INVAL"
 132 set ASSERTION "Open(NOCREATE) with invalid deny(4), expect $expcode"
 133 set tag "$TNAME{o}"
 134 putmsg stdout 0 "$tag: $ASSERTION"
 135 set res [compound {Putfh $bfh; Open $seqid 3 4 "$cid $owner-o" \
 136         {0 0 {{mode 0644}}} {0 "$env(ROFILE)"}; Getfh}]
 137 ckres "Open" $status $expcode $res $PASS
 138 
 139 
 140 # p: Open(NOCREATE) with invalid deny(-1), expect INVAL
 141 set expcode "INVAL"
 142 set ASSERTION "Open(NOCREATE) with invalid deny(-1), expect $expcode"
 143 set tag "$TNAME{p}"
 144 putmsg stdout 0 "$tag: $ASSERTION"
 145 set res [compound {Putfh $bfh; Open $seqid 3 -1 "$cid $owner-p" \
 146         {0 0 {{mode 0644}}} {0 "$env(ROFILE)"}; Getfh}]
 147 ckres "Open" $status $expcode $res $PASS
 148 
 149 
 150 # q: Open(CREATE/GUARDED) w/RO attribute, expect INVAL
 151 set expcode "INVAL"
 152 set ASSERTION "Open(CREATE) w/read-only attribute, expect $expcode"
 153 set tag "$TNAME{q}"
 154 putmsg stdout 0 "$tag: $ASSERTION"
 155 set res [compound {Putfh $bfh; Open $seqid 3 0 "$cid owner-q" \
 156         {1 1 {{maxname 257}}} {0 "$TNAME-m"};
 157         Getfh}]
 158 ckres "Open" $status $expcode $res $PASS
 159 
 160 
 161 # --------------------------------------------------------------
 162 # disconnect and exit
 163 Disconnect
 164 exit $PASS