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 GETATTR operation test - positive tests
  27 #       verify getattr to get supported_attrs
  28 
  29 # include all test enironment
  30 source GETATTR.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 req_attrs "supported_attrs type fh_expire_type change size link_support
  39     symlink_support named_attr fsid unique_handles lease_time rdattr_error"
  40 
  41 # Start testing
  42 # --------------------------------------------------------------
  43 # a: Getattr of a file w/supported_attr, expect OK
  44 set expcode "OK"
  45 set ASSERTION "Getattr of a file w/supported_attr, expect $expcode"
  46 putmsg stdout 0 "$TNAME{a}: $ASSERTION"
  47 set res [compound {Putfh $bfh; Lookup $env(RWFILE); Getfh;
  48         Getattr {supported_attrs type}; Getfh}]
  49 set cont [ckres "Getattr" $status $expcode $res $FAIL]
  50 # verify the attr return the min require attrs
  51   if {! [string equal $cont "false"]} {
  52         set attrs [lindex [lindex [lindex [lindex $res 3] 2] 0] 1]
  53         foreach an $req_attrs {
  54             if {[lsearch -exact $attrs "$an"] == -1} {
  55                 putmsg stderr 0 "\t Test FAIL: attr($an) was not returned."
  56                 putmsg stderr 1 "\t   res=($res)"
  57                 putmsg stderr 1 "\t   attrs=($attrs)"
  58                 putmsg stderr 1 "\t   an=($an)"
  59                 putmsg stderr 1 "  "
  60                 set cont false
  61                 break
  62             }
  63         }
  64   }
  65 # verify FH is not changed after successful Getattr op
  66   set fh1 [lindex [lindex $res 2] 2]
  67   set fh2 [lindex [lindex $res 4] 2]
  68   fh_equal $fh1 $fh2 $cont $PASS
  69 
  70 
  71 # b: Get supported_attrs of a file & check its value, expect OK
  72 set expcode "OK"
  73 set ASSERTION "Get supported_attrs of a file & check its value, expect $expcode"
  74 putmsg stdout 0 "$TNAME{b}: $ASSERTION"
  75 set res [compound {Putfh $bfh; Lookup $env(ROFILE); Getfh;
  76         Getattr "$req_attrs"; Getfh}]
  77 set cont [ckres "Getattr" $status $expcode $res $FAIL]
  78 # verify all attr returned and with good value
  79   if {! [string equal $cont "false"]} {
  80         set attrs [lrange [lindex [lindex $res 3] 2] 1 end]
  81         foreach al $attrs {
  82             set name [lindex $al 0]
  83             set val [lindex $al 1]
  84             switch -exact -- $name {
  85               type { if {"$val" != "reg"} {
  86                 putmsg stderr 0 "\t Test FAIL: attr($al) returned unexpected."
  87                 set cont false
  88                 break
  89               } }
  90               rdattr_error { if {"$val" != "OK"} {
  91                 putmsg stderr 0 "\t Test FAIL: attr($al) returned unexpected."
  92                 set cont false
  93                 break
  94               } }
  95               default { # XX what other attr can we check here?
  96                 break
  97               }
  98             }
  99         }
 100   }
 101 # verify FH is not changed after successful Getattr op
 102   set fh1 [lindex [lindex $res 2] 2]
 103   set fh2 [lindex [lindex $res 4] 2]
 104   fh_equal $fh1 $fh2 $cont $PASS
 105 
 106 
 107 # c: Get supported_attrs of a dir & check its value, expect OK
 108 set expcode "OK"
 109 set ASSERTION "Get supported_attrs of a dir & check its value, expect $expcode"
 110 putmsg stdout 0 "$TNAME{c}: $ASSERTION"
 111 set res [compound {Putfh $bfh; Lookup $env(DIR0777); Getfh;
 112         Getattr "$req_attrs"; Getfh}]
 113 set cont [ckres "Getattr" $status $expcode $res $FAIL]
 114 # verify all attr returned and with good value
 115   if {! [string equal $cont "false"]} {
 116         set attrs [lrange [lindex [lindex $res 3] 2] 1 end]
 117         foreach al $attrs {
 118             set name [lindex $al 0]
 119             set val [lindex $al 1]
 120             switch -exact -- $name {
 121               type { if {"$val" != "dir"} {
 122                 putmsg stderr 0 "\t Test FAIL: attr($al) returned unexpected."
 123                 set cont false
 124                 break
 125               } }
 126               rdattr_error { if {"$val" != "OK"} {
 127                 putmsg stderr 0 "\t Test FAIL: attr($al) returned unexpected."
 128                 set cont false
 129                 break
 130               } }
 131               default { # XX what other attr can we check here?
 132                 break
 133               }
 134             }
 135         }
 136   }
 137 # verify FH is not changed after successful Getattr op
 138   set fh1 [lindex [lindex $res 2] 2]
 139   set fh2 [lindex [lindex $res 4] 2]
 140   fh_equal $fh1 $fh2 $cont $PASS
 141 
 142 
 143 # d: Get supported_attrs of noperm_dir & check its value, expect OK
 144 set expcode "OK"
 145 set ASSERTION "Get supported_attrs of noperm_dir & check its value, expect $expcode"
 146 putmsg stdout 0 "$TNAME{d}: $ASSERTION"
 147 set res [compound {Putfh $bfh; Lookup $env(DNOPERM); Getfh;
 148         Getattr "$req_attrs"; Getfh}]
 149 set cont [ckres "Getattr" $status $expcode $res $FAIL]
 150 # verify all attr returned and with good value
 151   if {! [string equal $cont "false"]} {
 152         set attrs [lrange [lindex [lindex $res 3] 2] 1 end]
 153         foreach al $attrs {
 154             set name [lindex $al 0]
 155             set val [lindex $al 1]
 156             switch -exact -- $name {
 157               type { if {"$val" != "dir"} {
 158                 putmsg stderr 0 "\t Test FAIL: attr($al) returned unexpected."
 159                 set cont false
 160                 break
 161               } }
 162               rdattr_error { if {"$val" != "OK"} {
 163                 putmsg stderr 0 "\t Test FAIL: attr($al) returned unexpected."
 164                 set cont false
 165                 break
 166               } }
 167               default { # XX what other attr can we check here?
 168                 break
 169               }
 170             }
 171         }
 172   }
 173 # verify FH is not changed after successful Getattr op
 174   set fh1 [lindex [lindex $res 2] 2]
 175   set fh2 [lindex [lindex $res 4] 2]
 176   fh_equal $fh1 $fh2 $cont $PASS
 177 
 178 
 179 # --------------------------------------------------------------
 180 # disconnect and exit
 181 Disconnect
 182 exit $PASS