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 not-support attributes
  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 oseqid 1
  45 set owner "$TNAME-OpenOwner"
  46 
  47 
  48 # Start testing
  49 # --------------------------------------------------------------
  50 # a: Open(create/UNCHECK) w/readonly attr , expect INVAL
  51 set expcode "INVAL"
  52 set ASSERTION "Open(create/UNCHECK) w/readonly attribute , expect $expcode"
  53 set tag "$TNAME{a}"
  54 putmsg stdout 0 "$tag: $ASSERTION"
  55 set tmpFa "$tag"
  56 set res [compound {Putfh $bfh; 
  57         Open $oseqid 3 0 "$cid ${owner}-a" \
  58         {1 0 {{time_modify_set "1034718056 0"} {type reg}}} {0 $tmpFa}; Getfh}]
  59 ckres "Open" $status $expcode $res $PASS
  60 
  61 
  62 # b: Open(create/GUARDED) w/readonly attr , expect INVAL
  63 set expcode "INVAL"
  64 set ASSERTION "Open(create/GUARDED) w/readonly attribute , expect $expcode"
  65 set tag "$TNAME{b}"
  66 putmsg stdout 0 "$tag: $ASSERTION"
  67 set tmpFb "$tag"
  68 set res [compound {Putfh $bfh; 
  69         Open $oseqid 3 0 "$cid ${owner}-b" \
  70         {1 1 {{named_attr "false"} {mode 0666}}} {0 $tmpFb}; Getfh}]
  71 ckres "Open" $status $expcode $res $PASS
  72 
  73 
  74 # m: Open(create/UNCHECKED) w/not-supported attr , expect ATTRNOTSUPP
  75 set expcode "ATTRNOTSUPP"
  76 set ASSERTION "Open(create/UNCHECKED) w/unsupported attr, expect $expcode"
  77 set tag "$TNAME{m}"
  78 putmsg stdout 0 "$tag: $ASSERTION"
  79 # Check 'system' is not in supported_attr
  80 set nsattr "system"
  81 set res [compound {Putfh $bfh; Getattr supported_attrs}]
  82 if {[lsearch -exact [lindex [lindex [lindex $res 1] 2] 1] $nsattr] >= 0} {
  83     putmsg stdout 0 "\t Test NOTINUSE: attr($nsattr) is in supported_attrs list"
  84 } else {
  85     set tmpFm "$tag"
  86     set res [compound {Putfh $bfh; 
  87         Open $oseqid 3 0 "$cid ${owner}-m" \
  88         {1 0 {{$nsattr "false"} {mode 0666}}} {0 $tmpFm}; Getfh}]
  89     set cont [ckres "Open" $status $expcode $res $FAIL]
  90     if {! [string equal $cont "false"]} {
  91         # Verify $tmpFm is not created
  92         set res [compound {Putfh $bfh; Lookup $tmpFm}]
  93         if {$status != "NOENT"} {
  94             putmsg stderr 0 "\t Test FAIL: ndir=($tmpFm) created unexpectedly"
  95             putmsg stderr 1 "\t   res=($res)"
  96             putmsg stderr 1 "  "
  97         } else {
  98            logres PASS
  99         }
 100     }
 101 }
 102 
 103 
 104 # n: Open(create/GUARDED) w/not-supported attr , expect ATTRNOTSUPP
 105 set expcode "ATTRNOTSUPP"
 106 set ASSERTION "Open(create/GUARDED) w/unsupported attr, expect $expcode"
 107 set tag "$TNAME{n}"
 108 putmsg stdout 0 "$tag: $ASSERTION"
 109 # Check 'hidden' is not in supported_attr
 110 set nsattr "hidden"
 111 set res [compound {Putfh $bfh; Getattr supported_attrs}]
 112 if {[lsearch -exact [lindex [lindex [lindex $res 1] 2] 1] $nsattr] >= 0} {
 113     putmsg stdout 0 "\t Test NOTINUSE: attr($nsattr) is in supported_attrs list"
 114 } else {
 115     set tmpFn "$tag"
 116     set res [compound {Putfh $bfh; 
 117         Open $oseqid 3 0 "$cid ${owner}-m" \
 118         {1 0 {{$nsattr "false"} {mode 0666}}} {0 $tmpFn}; Getfh}]
 119     set cont [ckres "Open" $status $expcode $res $FAIL]
 120     if {! [string equal $cont "false"]} {
 121         # Verify $tmpFn is not created
 122         set res [compound {Putfh $bfh; Lookup $tmpFn}]
 123         if {$status != "NOENT"} {
 124             putmsg stderr 0 "\t Test FAIL: ndir=($tmpFn) created unexpectedly"
 125             putmsg stderr 1 "\t   res=($res)"
 126             putmsg stderr 1 "  "
 127         } else {
 128            logres PASS
 129         }
 130     }
 131 }
 132 # --------------------------------------------------------------
 133 # disconnect and exit
 134 Disconnect
 135 exit $PASS