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 LOOKUP operation test - more of negative tests
  27 
  28 # include all test enironment
  29 source LOOKUP.env
  30 
  31 # connect to the test server
  32 Connect
  33 
  34 # setting local variables
  35 set TNAME $argv0
  36 set bfh [get_fh $BASEDIRS]
  37 
  38 # Start testing
  39 # --------------------------------------------------------------
  40 # a: Lookup with an obj not exist, expect NOENT
  41 set expcode "NOENT"
  42 set ASSERTION "Lookup with an obj not exist, expect $expcode"
  43 putmsg stdout 0 "$TNAME{a}: $ASSERTION"
  44 set res [compound {Putfh $bfh; Lookup "NOENT.[pid]"}]
  45 ckres "Lookup" $status $expcode $res $PASS
  46 
  47 
  48 # d: Lookup with CFH as a file, expect NOTDIR
  49 set expcode "NOTDIR"
  50 set ASSERTION "Lookup with CFH as a file, expect $expcode"
  51 putmsg stdout 0 "$TNAME{d}: $ASSERTION"
  52 set res [compound {Putfh $bfh; Lookup $env(TEXTFILE); Lookup $env(TEXTFILE)}]
  53 ckres "Lookup" $status $expcode $res $PASS
  54 
  55 
  56 # e: Lookup with CFH as a fifo, expect NOTDIR
  57 set expcode "NOTDIR"
  58 set ASSERTION "Lookup with CFH as a fifo, expect $expcode"
  59 putmsg stdout 0 "$TNAME{e}: $ASSERTION"
  60 set tobj "FIFO[pid]"
  61 set res [compound {Putfh $bfh; Create $tobj {{mode 0666}} f; Getfh}]
  62 set tfh [lindex [lindex $res 2] 2]
  63 set res [compound {Putfh $tfh; Lookup newfile}]
  64 ckres "Lookup" $status $expcode $res $PASS
  65 set res [compound {Putfh $bfh; Remove $tobj}]
  66 
  67 
  68 # m: try to Lookup of expired FH, expect FHEXPIRED
  69 set expcode "FHEXPIRED"
  70 set ASSERTION "Lookup an expired FH, expect $expcode"
  71 #putmsg stdout 0 "$TNAME{m}: $ASSERTION"
  72 #puts "\t Test UNTESTED: XXX need server hook for FH expired.\n"
  73 
  74 
  75 # n: Lookup with cfh is bad, expect BADHANDLE
  76 set expcode "BADHANDLE"
  77 set ASSERTION "Lookup with cfh is bad, expect $expcode"
  78 #putmsg stdout 0 "$TNAME{n}: $ASSERTION"
  79 #puts "\t Test UNTESTED: XXX need hook from server to set cfh to a bad FH\n"
  80 
  81 
  82 # w: Lookup with component name too long, expect NAMETOOLONG
  83 set expcode "NAMETOOLONG"
  84 set ASSERTION "Lookup with component name too long, expect $expcode"
  85 #putmsg stdout 0 "$TNAME{w}: $ASSERTION"
  86 #puts "\t Test UNTESTED: XXX how to create an obj w/nametoolong for lookup?\n"
  87 
  88 
  89 # x: Lookup with WrongSec, expect WRONGSEC
  90 set expcode "WRONGSEC"
  91 set ASSERTION "Lookup with wrongSec, expect $expcode"
  92 putmsg stdout 0 "$TNAME{x}: $ASSERTION"
  93 # check for $KRB5DIR to make sure KRB5 is setup in $SERVER
  94   set kpath [path2comp $env(KRB5DIR) $DELM]
  95   set dname [lrange $kpath 0 end-1]
  96   set lname [lrange $kpath end end]
  97   set kfh [get_fh $dname]
  98   set res [compound {Putfh $kfh; Secinfo $lname}]
  99   set slist [lindex [lindex $res 1] 2]
 100   if {[lsearch -regexp $slist "KRB5"] == -1} {
 101         putmsg stderr 0 "\t Test NOTINUSE: KRB5 is not setup in server."
 102   } else {
 103         set res [compound {Putfh $kfh; Lookup $lname}]
 104         ckres "Lookup" $status $expcode $res $PASS
 105   }
 106 
 107 
 108 # y: XXX how do we simulate some server errors:
 109 #       NFS4ERR_MOVED
 110 #       NFS4ERR_SERVERFAULT
 111 #       NFS4ERR_RESOURCE
 112 #       NFS4ERR_IO
 113 
 114 
 115 # --------------------------------------------------------------
 116 # disconnect and exit
 117 Disconnect
 118 exit $PASS