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 server name space test - positive tests
  27 #
  28 
  29 # include all test enironment
  30 source SNSPC.env
  31 
  32 set TNAME $argv0
  33 
  34 # Start the assertion proc's here
  35 # --------------------------------------------------------------
  36 # a: Readdir on rootFH, only see pseudo nodes as dir, expect OK
  37 proc assertion_a {pnode} {
  38     global TNAME
  39     set expcode "OK"
  40     set ASSERTION \
  41         "Readdir on rootFH, only see pseudo nodes as dir, expect $expcode"
  42     putmsg stdout 0 "$TNAME{a}: $ASSERTION"
  43     set tag "$TNAME{a}"
  44 
  45     # First do the compound
  46     set res [compound {Putrootfh; Readdir 0 0 1024 8192 {type rdattr_error}}]
  47     if {$status != "$expcode"} {
  48         putmsg stderr 0 "\t Test UNRESOLVED: Readdir got status=($status)"
  49         putmsg stderr 0 "\t                  expected=($expcode)"
  50         putmsg stderr 1 "\t   res=($res)"
  51         return (-1)
  52     }
  53 
  54     # now check the results
  55     set rdres [lindex [lindex $res 1] 3]
  56     set match 0
  57     foreach entry $rdres {
  58         set name [lindex $entry 1]
  59         set type [extract_attr [lindex $entry 2] "type"]
  60         if {$type != "dir"} {
  61             putmsg stderr 0 "\t Test FAIL: invalid pseudo node type=($type)"
  62             putmsg stderr 1 "\t   rdres=($rdres)"
  63             return (-1)
  64         }
  65         if {$name == $pnode} {
  66                 set match 1
  67         }
  68     }
  69     if {$match == 0} {
  70         putmsg stderr 0 "\t Test FAIL: unable to find pseudo node for BASEDIRS."
  71         putmsg stderr 1 "\t   pnode=($pnode)"
  72         return (-1)
  73     }
  74     logres PASS
  75     return (0)
  76 }
  77 
  78 # b: Readdir on exported node, see whole dir, expect OK
  79 proc assertion_b {dfh} {
  80     global env
  81     global TNAME
  82     set expcode "OK"
  83     set ASSERTION "Readdir on exported node, see whole dir, expect $expcode"
  84     putmsg stdout 0 "$TNAME{b}: $ASSERTION"
  85     set tag "$TNAME{b}"
  86 
  87     # First do the compound
  88     set res [compound {Putfh $dfh; Readdir 0 0 1024 8192 {type rdattr_error}}]
  89     if {$status != "$expcode"} {
  90         putmsg stderr 0 "\t Test UNRESOLVED: Readdir got status=($status)"
  91         putmsg stderr 0 "\t                  expected=($expcode)"
  92         putmsg stderr 1 "\t   res=($res)"
  93         return (-1)
  94     }
  95 
  96     # now check the results; files should be included
  97     set rdres [lindex [lindex $res 1] 3]
  98     set nlist ""
  99     foreach entry $rdres {
 100         set name [lindex $entry 1]
 101         set nlist "$nlist $name"
 102         set type [extract_attr [lindex $entry 2] "type"]
 103         if {($name == $env(RWFILE)) && ($type != "reg")} {
 104             putmsg stderr 0 \
 105                 "\t Test FAIL: file($name) has type=($type), expected=(reg)"
 106             putmsg stderr 1 "\t   rdres=($rdres)"
 107             return (-1)
 108         }
 109     }
 110     set ffile "$env(ROFILE)"
 111     if {[lsearch -exact $nlist "$ffile"] == -1} {
 112         putmsg stderr 0 "\t Test FAIL: file($ffile) not found in name list."
 113         putmsg stderr 1 "\t   nlist=($nlist)"
 114         return (-1)
 115     }
 116     logres PASS
 117     return (0)
 118 }
 119 
 120 # c: Readdir on pseudo node has same results w/Lookupp, expect OK
 121 proc assertion_c {bdir nodename} {
 122     global TNAME
 123     set expcode "OK"
 124     set ASSERTION \
 125         "Readdir on pseudo node has same results w/Lookupp, expect $expcode"
 126     putmsg stdout 0 "$TNAME{c}: $ASSERTION"
 127     set tag "$TNAME{c}"
 128 
 129     if {[is_cipso $nodename]} {
 130         putmsg stderr 0 \
 131             "\t Test UNSUPPORTED: Not supported for Trusted Extensions CIPSO"
 132         putmsg stderr 1 "\t                   nodename=($nodename)"
 133         return (-1)
 134     }
 135 
 136     # First Readdir on the pseudo node
 137     set pnode [lrange $bdir 0 [expr [llength $bdir] - 2]]
 138     set bdfh [get_fh $pnode]
 139     set res [compound {Putfh $bdfh; Readdir 0 0 1024 8192 {type rdattr_error}}]
 140     if {$status != "$expcode"} {
 141         putmsg stderr 0 "\t Test UNRESOLVED: 1st Readdir got status=($status)"
 142         putmsg stderr 0 "\t                  expected=($expcode)"
 143         putmsg stderr 1 "\t   res=($res)"
 144         return (-1)
 145     }
 146     # Save the readdir list
 147     set rdres1 [lindex [lindex $res 1] 3]
 148 
 149     # Try Readdir again with LOOKUPP from BASEDIR
 150     set bfh [get_fh $bdir]
 151     set res [compound {Putfh $bfh; Lookupp; 
 152         Readdir 0 0 1024 8192 {type rdattr_error}}]
 153     if {$status != "$expcode"} {
 154         putmsg stderr 0 "\t Test UNRESOLVED: 2nd Readdir got status=($status)"
 155         putmsg stderr 0 "\t                  expected=($expcode)"
 156         putmsg stderr 1 "\t   res=($res)"
 157         return (-1)
 158     }
 159     # Save the readdir list
 160     set rdres2 [lindex [lindex $res 2] 3]
 161 
 162     # now check the results, both rdres should be the same
 163     if {"$rdres1" != "$rdres2"} {
 164         putmsg stderr 0 \
 165                 "\t Test FAIL: 2 Readdir's of same node got different results"
 166         putmsg stderr 1 "\t   rdres1=($rdres1)"
 167         putmsg stderr 1 "\t   rdres2=($rdres2)"
 168         return (-1)
 169     }
 170     logres PASS
 171     return (0)
 172 }
 173 
 174 
 175 # Start the main program here
 176 # --------------------------------------------------------------
 177 # connect to the test server
 178 if {[catch {connect -p ${PORT} -t ${TRANSPORT} ${SERVER}} msg]} {
 179         putmsg stderr 0 "Test UNINITIATED: unable to connect to $SERVER"
 180         putmsg stderr 1 $msg
 181         exit $UNINITIATED
 182 }
 183 
 184 set pnode [lindex $BASEDIRS 0]
 185 assertion_a $pnode
 186 
 187 set dfh [get_fh "$BASEDIRS $env(DIR0777)"]
 188 assertion_b $dfh
 189 
 190 assertion_c $BASEDIRS $env(SERVER)
 191 
 192 
 193 # --------------------------------------------------------------
 194 # disconnect and exit
 195 set tag ""
 196 disconnect
 197 exit $PASS