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 - positive tests
  27 #       verify reading of a binary file with different offset/count
  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 # Get the size of the $ZIPFILE file
  40 set res [compound {Putfh $bfh; Lookup $env(ZIPFILE); Getattr size}]
  41 set fsize [lindex [lindex [lindex [lindex $res 2] 2] 0] 1]
  42 
  43 
  44 # Start testing
  45 # --------------------------------------------------------------
  46 # a: Read a binary file < 1K (1023 byte) - expect OK
  47 set expcode "OK"
  48 set ASSERTION "Read a binary file < 1K (1023 byte), expect $expcode"
  49 set tag "$TNAME{a}"
  50 putmsg stdout 0 "$tag: $ASSERTION"
  51 set count 1023
  52 set explen $fsize
  53 set expeof "true"
  54 if {$count < $fsize} {
  55         set explen $count
  56         set expeof false
  57 }
  58 ckread $bfh "$env(ZIPFILE)" 0 $count $expcode $explen $expeof
  59 
  60 
  61 # b: Read a binary file > 1K (1025 byte) - expect OK
  62 set expcode "OK"
  63 set ASSERTION "Read a binary file > 1K (1025 byte), expect $expcode"
  64 set tag "$TNAME{b}"
  65 putmsg stdout 0 "$tag: $ASSERTION"
  66 set count 1025
  67 set explen $fsize
  68 set expeof "true"
  69 if {$count < $fsize} {
  70         set explen $count
  71         set expeof false
  72 }
  73 ckread $bfh "$env(ZIPFILE)" 0 $count $expcode $explen $expeof
  74 
  75 
  76 # c: Read a binary file till the end of the file, count>32k - expect OK
  77 set expcode "OK"
  78 set ASSERTION "Read a binary file till EOF, count>32k, expect $expcode"
  79 set tag "$TNAME{c}"
  80 putmsg stdout 0 "$tag: $ASSERTION"
  81 set count 32768
  82 set explen -1
  83 if {$count > $fsize} {
  84         set explen $fsize
  85 }
  86 ckread $bfh "$env(ZIPFILE)" 0 $count $expcode $explen "true"
  87 
  88 
  89 # d: Read a text file 1B at a time till EOF - expect OK
  90 set expcode "OK"
  91 set ASSERTION "Read a binary file 1B at a time till EOF, expect $expcode"
  92 set tag "$TNAME{d}"
  93 putmsg stdout 0 "$tag: $ASSERTION"
  94 set offset [expr $fsize / 3]
  95 set count 1
  96 set explen -1
  97 ckread $bfh "$env(TEXTFILE)" $offset $count $expcode $explen "true"
  98 
  99 
 100 # m: Read a file using special stateid (w/out Open) - expect OK
 101 set expcode "OK"
 102 set ASSERTION "Read a file using special stateid (w/out Open), expect $expcode"
 103 set tag "$TNAME{m}"
 104 putmsg stdout 0 "$tag: $ASSERTION"
 105 set stateid {0 0}
 106 set res [compound {Putfh $bfh; Lookup $env(TEXTFILE); Read $stateid 0 1024}]
 107 ckres "Read" $status $expcode $res $PASS
 108 
 109 
 110 # --------------------------------------------------------------
 111 # disconnect and exit
 112 Disconnect
 113 exit $PASS