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 REMOVE operation test - negative tests
  27 
  28 # include all test enironment
  29 source REMOVE.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: Remove without Putrootfh, expect NOFILEHANDLE
  41 set expcode "NOFILEHANDLE"
  42 set ASSERTION "Try to do remove with no Putrootfh, expect $expcode"
  43 putmsg stdout 0 "$TNAME{a}: $ASSERTION"
  44 set res [compound {Remove $env(DIR0777)}]
  45 ckres "Remove" $status $expcode $res $PASS
  46 
  47 
  48 # b: Try to Remove an entry under dir_noperm, expect ACCESS
  49 set expcode "ACCESS"
  50 set ASSERTION "Remove an entry under dir_noperm, expect $expcode"
  51 putmsg stdout 0 "$TNAME{b}: $ASSERTION"
  52 set res [compound {Putfh $bfh; Lookup "$env(DNOPERM)"; Remove rwfile}]
  53 ckres "Remove" $status $expcode $res $PASS
  54 
  55 
  56 # c: Try to Remove an entry with empty name, expect INVAL
  57 set expcode "INVAL"
  58 set ASSERTION "Remove an entry w/empty name, expect $expcode"
  59 putmsg stdout 0 "$TNAME{c}: $ASSERTION"
  60 set res [compound {Putfh $bfh; Remove ""; Getfh}]
  61 ckres "Remove" $status $expcode $res $PASS
  62 
  63 
  64 # d: Try to Remove an entry with target=".", expect INVAL|NOENT
  65 set expcode "INVAL|NOENT"
  66 set ASSERTION "Remove an entry w/target=\".\", expect $expcode"
  67 putmsg stdout 0 "$TNAME{d}: $ASSERTION"
  68 set res [compound {Putfh $bfh; Remove "."; Getfh}]
  69 ckres "Remove" $status $expcode $res $PASS
  70 
  71 
  72 # e: Try to Remove an entry with target="..", expect INVAL|NOENT
  73 set expcode "INVAL|NOENT"
  74 set ASSERTION "Remove an entry w/target=\"..\", expect $expcode"
  75 putmsg stdout 0 "$TNAME{e}: $ASSERTION"
  76 set res [compound {Putfh $bfh; Remove ".."; Getfh}]
  77 ckres "Remove" $status $expcode $res $PASS
  78 
  79 
  80 # f: Try to Remove w/target name includes path delimiter, expect INVAL|NOENT
  81 set expcode "INVAL|NOENT"
  82 set ASSERTION "Remove an entry w/target=\"xx${DELM}xx\", expect $expcode"
  83 putmsg stdout 0 "$TNAME{f}: $ASSERTION"
  84 set res [compound {Putfh $bfh; Remove "dir${DELM}file"; Getfh}]
  85 ckres "Remove" $status $expcode $res $PASS
  86 
  87 
  88 # i: Try to Remove an none-existing entry, expect NOENT
  89 set expcode "NOENT"
  90 set ASSERTION "Remove an none-existing entry, expect $expcode"
  91 putmsg stdout 0 "$TNAME{i}: $ASSERTION"
  92 set res [compound {Putfh $bfh; Remove "No-such.thing"; Getfh}]
  93 ckres "Remove" $status $expcode $res $PASS
  94 
  95 
  96 # j: Try to Remove an entry with too long name, expect NAMETOOLONG
  97 set expcode "NAMETOOLONG"
  98 set ASSERTION "Remove an entry w/target name too long, expect $expcode"
  99 putmsg stdout 0 "$TNAME{j}: $ASSERTION"
 100 set tname [set_maxname $bfh]
 101 if {$tname != $NULL} {
 102     set res [compound {Putfh $bfh; Remove $tname; Getfh}]
 103     ckres "Remove" $status $expcode $res $PASS
 104 } else {
 105     putmsg stderr 0 "\t UNINITIATED: unable to set maxname"
 106     putmsg stderr 1 "\t   tname=($tname)"
 107     putmsg stderr 1 "  "
 108 }
 109 
 110 
 111 # k: Remove when CFH removed, expect STALE
 112 set expcode "STALE"
 113 set ASSERTION "Remove when CFH removed, expect $expcode"
 114 #putmsg stdout 0 "$TNAME{k}: $ASSERTION"
 115 #puts "\t Test UNTESTED: XXX need hook to remove <CFH> from server.\n"
 116 
 117 
 118 # m: Remove with WrongSec, expect WRONGSEC
 119 set expcode "WRONGSEC"
 120 set ASSERTION "Remove with WrongSec, expect $expcode"
 121 #putmsg stdout 0 "$TNAME{m}: $ASSERTION"
 122 #puts "\t Test UNTESTED: XXX need server change SEC w/KRB5.\n"
 123 
 124 
 125 # n: try to Remove of expired FH, expect FHEXPIRED
 126 set expcode "FHEXPIRED"
 127 set ASSERTION "Remove an expired FH, expect $expcode"
 128 #putmsg stdout 0 "$TNAME{n}: $ASSERTION"
 129 #puts "\t Test UNTESTED: XXX need hook to get FH expired.\n"
 130 
 131 
 132 # o: try to Remove of bad FH, expect BADHANDLE
 133 set expcode "BADHANDLE"
 134 set ASSERTION "Remove with a bad FH, expect $expcode"
 135 #putmsg stdout 0 "$TNAME{o}: $ASSERTION"
 136 #puts "\t Test UNTESTED: XXX need hooks in server to set CFH bad.\n"
 137 
 138 
 139 # x: XXX how do we simulate some server errors:
 140 #       NFS4ERR_MOVE
 141 #       NFS4ERR_IO
 142 #       NFS4ERR_SERVERFAULT
 143 #       NFS4ERR_RESOURCE
 144 
 145 
 146 # --------------------------------------------------------------
 147 # disconnect and exit
 148 Disconnect
 149 exit $PASS