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 READ operation test - negative tests
  27 #       verify SERVER errors returned with invalid read.
  28 
  29 # include all test enironment
  30 source READ.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 read a file without <cfh> - expect NOFILEHANDLE
  43 set expcode "NOFILEHANDLE"
  44 set ASSERTION "Try to read a file without <cfh>, expect $expcode"
  45 set tag "$TNAME{a}"
  46 putmsg stdout 0 "$tag: $ASSERTION"
  47 set res [compound {Read {0 0} 0 1024}]
  48 ckres "Read" $status $expcode $res $PASS
  49 
  50 
  51 # b: Try to read a file without READ permission - expect ACCESS
  52 set expcode "ACCESS"
  53 set ASSERTION "Try to read a file without READ permission, expect $expcode"
  54 set tag "$TNAME{b}"
  55 putmsg stdout 0 "$tag: $ASSERTION"
  56 set res [compound {Putfh $bfh; Lookup $env(FNOPERM); Read {0 0} 0 1024}]
  57 ckres "Read" $status $expcode $res $PASS
  58 
  59 
  60 # c: Try to read a directory - expect ISDIR
  61 set expcode "ISDIR"
  62 set ASSERTION "Try to read a directory <cfh>=dir, expect $expcode"
  63 set tag "$TNAME{c}"
  64 putmsg stdout 0 "$tag: $ASSERTION"
  65 set res [compound {Putfh $bfh; Read {0 0} 0 1024}]
  66 ckres "Read" $status $expcode $res $PASS
  67 
  68 
  69 # d: Try to read a none-regular file - expect INVAL
  70 set expcode "INVAL"
  71 set ASSERTION "Try to read a none-regular file, expect $expcode"
  72 set tag "$TNAME{d}"
  73 putmsg stdout 0 "$tag: $ASSERTION"
  74 set res [compound {Putfh $bfh; Lookup $env(BLKFILE); Read {0 0} 0 1024}]
  75 ckres "Read" $status $expcode $res $PASS
  76 
  77 
  78 # e: Try to read a symlink - expect INVAL
  79 set expcode "INVAL"
  80 set ASSERTION "Try to read a symlink, expect $expcode"
  81 set tag "$TNAME{e}"
  82 putmsg stdout 0 "$tag: $ASSERTION"
  83 set res [compound {Putfh $bfh; Lookup $env(SYMLFILE); Read {0 0} 0 1024}]
  84 ckres "Read" $status $expcode $res $PASS
  85 
  86 
  87 # s: try to Read a file while it is removed, expect STALE
  88 set expcode "STALE"
  89 set ASSERTION "try to Read a file while it is removed, expect $expcode"
  90 #set tag "$TNAME{s}"
  91 #putmsg stdout 0 "$tag: $ASSERTION"
  92 #set tmpF "Read_tmpF.[pid]"
  93 #set tfh [creatv4_file [file join $BASEDIR $tmpF]]
  94 #if { $tfh == $NULL } {
  95 #        putmsg stderr 0 "\t UNINITIATED: unable to create tmp file."
  96 #        putmsg stderr 1 "  "
  97 #        exit $UNRESOLVED
  98 #}
  99 #check_op "Putfh $bfh; Remove $tmpF" "OK" "UNINITIATED"
 100 # XXX Putfh $tfh would STALE, need a separate thread to remove the file
 101 #set res [compound {Putfh $tfh; Read {0 0} 0 2047; Getfh}]
 102 #ckres "Read" $status $expcode $res $PASS
 103 #puts "\t TEST UNTESTED: XXX need a separate thread to remove the file\n"
 104 
 105 
 106 # --------------------------------------------------------------
 107 # disconnect and exit
 108 Disconnect
 109 exit $PASS