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 WRITE operation test - negative tests
  27 #       verify SERVER errors returned with invalid write.
  28 
  29 # include all test enironment
  30 source WRITE.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 
  39 
  40 # Start testing
  41 # --------------------------------------------------------------
  42 # a: Try to write a file without <cfh> - expect NOFILEHANDLE
  43 set expcode "NOFILEHANDLE"
  44 set ASSERTION "Try to write a file without <cfh>, expect $expcode"
  45 set tag "$TNAME{a}"
  46 putmsg stdout 0 "$tag: $ASSERTION"
  47 set res [compound {Write {0 0} 0 f a "Just a test"}]
  48 ckres "Write" $status $expcode $res $PASS
  49 
  50 
  51 # b: Try to write a file without WRITE permission - expect ACCESS
  52 set expcode "ACCESS"
  53 set ASSERTION "Try to write a file without WRITE permission, expect $expcode"
  54 set tag "$TNAME{b}"
  55 putmsg stdout 0 "$tag: $ASSERTION"
  56 set res [compound {Putfh $bfh; Lookup $env(ROFILE); 
  57         Write {0 0} 1 u a "Write_neg01\{b\}"}]
  58 ckres "Write" $status $expcode $res $PASS
  59 
  60 
  61 # c: Try to write a directory - expect ISDIR
  62 set expcode "ISDIR"
  63 set ASSERTION "Try to write a directory <cfh>=dir, expect $expcode"
  64 set tag "$TNAME{c}"
  65 putmsg stdout 0 "$tag: $ASSERTION"
  66 set res [compound {Putfh $bfh; Write {0 0} 2 d a "Write_neg01\{c\}"}]
  67 ckres "Write" $status $expcode $res $PASS
  68 
  69 
  70 # d: Try to write a none-regular file - expect INVAL
  71 set expcode "INVAL"
  72 set ASSERTION "Try to write a none-regular file, expect $expcode"
  73 set tag "$TNAME{d}"
  74 putmsg stdout 0 "$tag: $ASSERTION"
  75 set res [compound {Putfh $bfh; Lookup $env(BLKFILE); 
  76         Write {0 0} 3 f a "Write_neg01\{d\}"}]
  77 ckres "Write" $status $expcode $res $PASS
  78 
  79 
  80 # e: Try to write a symlink - expect INVAL
  81 set expcode "INVAL"
  82 set ASSERTION "Try to write a symlink, expect $expcode"
  83 set tag "$TNAME{e}"
  84 putmsg stdout 0 "$tag: $ASSERTION"
  85 set res [compound {Putfh $bfh; Lookup $env(SYMLFILE);
  86         Write {0 0} 4 f a "Write_neg01\{d\}"}]
  87 ckres "Write" $status $expcode $res $PASS
  88 
  89 
  90 # i: write to a file w/big offset (-1) - expect FBIG
  91 set expcode "FBIG"
  92 set ASSERTION "write to a file w/big offset (-1), expect $expcode"
  93 set tag "$TNAME{i}"
  94 putmsg stdout 0 "$tag: $ASSERTION"
  95 #set res [compound {Putfh $bfh; Lookup $env(RWFILE);
  96 #       Write {0 0} -1 u a "Write_neg01\{i\}-EFBIG"}]
  97 #ckres "Write" $status $expcode $res $PASS
  98 putmsg stdout 0 "\t TEST UNTESTED: XXX commented out due to following bug:"
  99 putmsg stdout 0 "\t     4665413 - nfsd coredumped"
 100 
 101 
 102 # j: write to a file w/offset=2^63-2 for 2 bytes  - expect FBIG
 103 set expcode "FBIG"
 104 set ASSERTION "write w/offset=2^63-2 for 2 bytes, expect $expcode"
 105 set tag "$TNAME{j}"
 106 putmsg stdout 0 "$tag: $ASSERTION"
 107 #set res [compound {Putfh $bfh; Lookup $env(RWFILE);
 108 #       Write {0 0} 9223372036854775806 u a "xx"}]
 109 #ckres "Write" $status $expcode $res $PASS
 110 putmsg stdout 0 "\t TEST UNTESTED: XXX commented out due to following bug:"
 111 putmsg stdout 0 "\t     4665413 - nfsd coredumped"
 112 
 113 
 114 # s: try to Write a file while it is removed, expect STALE
 115 set expcode "STALE"
 116 set ASSERTION "try to Write a file while it is removed, expect $expcode"
 117 set tag "$TNAME{s}"
 118 #putmsg stdout 0 "$tag: $ASSERTION"
 119 #set tmpF "Write_tmpF.[pid]"
 120 #set tfh [creatv4_file [file join $BASEDIR $tmpF]]
 121 #if { $tfh == $NULL } {
 122 #        putmsg stderr 0 "\t UNINITIATED: unable to create tmp file."
 123 #        putmsg stderr 1 "  "
 124 #        exit $UNINITIATED
 125 #}
 126 #check_op "Putfh $bfh; Remove $tmpF" "OK" "UNINITIATED"
 127 # XXX Putfh $tfh would STALE, need a separate thread to remove the file
 128 #set res [compound {Putfh $tfh; Write {0 0} 1 f a "Write_neg01\{s\}" ; Getfh}]
 129 #ckres "Write" $status $expcode $res $PASS
 130 #puts "\t TEST UNTESTED: XXX need a separate thread to remove the file\n"
 131 
 132 
 133 # --------------------------------------------------------------
 134 # disconnect and exit
 135 Disconnect
 136 exit $PASS