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 - positive tests
  27 #       verify writing to a file without Open using different offset/count
  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 # Create a temp file (size 0) for writing
  40 set newF "WRfile.[pid]"
  41 set tffh [creatv4_file [file join $BASEDIR $newF]]
  42 if { $tffh == $NULL } {
  43         putmsg stdout 0 "$TNAME: test setup - createv4_file"
  44         putmsg stderr 0 "\t UNINITIATED: unable to create tmp file, $newF"
  45         putmsg stderr 1 "  "
  46         exit $UNINITIATED
  47 }
  48         
  49 
  50 # Start testing
  51 # --------------------------------------------------------------
  52 # a: Write 0B data with Open, offset=0 - expect OK
  53 set expcode "OK"
  54 set ASSERTION "Write 0B data with Open, offset=0, expect $expcode"
  55 set tag "$TNAME{a}"
  56 putmsg stdout 0 "$tag: $ASSERTION"
  57 ckwrite $bfh "$newF" 0 0 $expcode 0 $PASS
  58 
  59 
  60 # b: Write 8K ascii with Open, offset=0 - expect OK
  61 set expcode "OK"
  62 set ASSERTION "Write 8K ascii with Open, offset=0, expect $expcode"
  63 set tag "$TNAME{b}"
  64 putmsg stdout 0 "$tag: $ASSERTION"
  65 set count 8192
  66 ckwrite $bfh "WR02-b" 0 $count $expcode $count $PASS
  67 
  68 
  69 # c: Write data 1B and skip 1B until 1K+2 - expect OK
  70 set expcode "OK"
  71 set ASSERTION "Write data 1B and skip 1B until 1K+2, expect $expcode"
  72 set tag "$TNAME{c}"
  73 putmsg stdout 0 "$tag: $ASSERTION"
  74 set offset 99
  75 set count 1
  76 set cont [ckwrite $bfh "WR02-c" $offset $count $expcode -1 $FAIL]
  77 # check to file size, must be 1K+2, i.e. 1026
  78 if {$cont == 0} {
  79         set res [compound {Putfh $bfh; Lookup "WR02-c"; Getattr size}]
  80         set nsize [lindex [lindex [lindex [lindex $res 2] 2] 0] 1]
  81         if {$nsize != 1026} {
  82             putmsg stderr 0 "\t Test FAIL: incorrect new filesize"
  83             putmsg stderr 0 "\t            expected=(1026), got=($nsize)."
  84         } else {
  85             logres PASS
  86         }
  87 }
  88 
  89 
  90 # --------------------------------------------------------------
  91 # Cleanup the temp file:
  92 set res [compound {Putfh $bfh; Remove $newF; Remove "WR02-b"; Remove "WR02-c"}]
  93 if { "$status" != "OK" } {
  94         putmsg stderr 0 "\t WARNING: cleanup to remove $newF failed"
  95         putmsg stderr 0 "\t          status=$status; please cleanup manually."
  96         putmsg stderr 1 "\t   res=($res)"
  97         putmsg stderr 1 "  "
  98         exit $WARNING
  99 }
 100 
 101 # disconnect and exit
 102 Disconnect
 103 exit $PASS