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 COMMIT operation test - positive tests
  27 
  28 # include all test enironment
  29 source COMMIT.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: basic Commit entire file of unsync data, expect OK
  41 set expcode "OK"
  42 set ASSERTION "basic Commit entire file of unsync data, expect $expcode"
  43 set tag "$TNAME{a}"
  44 putmsg stdout 0 "$tag: $ASSERTION"
  45 set newFa "Com-a.[pid]"
  46 set tfh [creatv4_file [file join $BASEDIR $newFa] 0666 1024]
  47 # writ some data w/unsync flag:
  48 set data [string repeat "a" 1024]
  49 set res [compound {Putfh $tfh; Write {0 0} 1024 u a $data; 
  50         Write {0 0} 2048 u a $data; Commit 0 0; Getfh}]
  51 set cont [ckres "Commit" $status $expcode $res $FAIL]
  52 # Now verify filehandle after COMMIT remain the same
  53 fh_equal $tfh [lindex [lindex $res 4] 2] $cont $PASS
  54 
  55 
  56 # b: Commit only portion of unsync data, expect OK
  57 set expcode "OK"
  58 set ASSERTION "Commit only portion of unsync data, expect $expcode"
  59 set tag "$TNAME{b}"
  60 putmsg stdout 0 "$tag: $ASSERTION"
  61 set newFb "Com-b.[pid]"
  62 set tfh [creatv4_file [file join $BASEDIR $newFb]]
  63 # writ some data w/unsync flag:
  64 set data [string repeat "b" 2047]
  65 set res [compound {Putfh $tfh; Write {0 0} 0 u a $data; 
  66         Write {0 0} 2048 u a $data; Commit 10 1024; Getfh}]
  67 set cont [ckres "Commit" $status $expcode $res $FAIL]
  68 # Now verify filehandle after COMMIT remain the same
  69 fh_equal $tfh [lindex [lindex $res 4] 2] $cont $PASS
  70 
  71 
  72 # c: Commit of data_sync data, expect OK
  73 set expcode "OK"
  74 set ASSERTION "Commit of data_sync data, expect $expcode"
  75 set tag "$TNAME{c}"
  76 putmsg stdout 0 "$tag: $ASSERTION"
  77 set newFc "Com-c.[pid]"
  78 set tfh [creatv4_file [file join $BASEDIR $newFc]]
  79 # writ some data w/data_sync flag:
  80 set data [string repeat "c" 4097]
  81 set res [compound {Putfh $tfh; Write {0 0} 1 d a $data; 
  82         Commit 12 0; Getfh}]
  83 set cont [ckres "Commit" $status $expcode $res $FAIL]
  84 # Now verify filehandle after COMMIT remain the same
  85 fh_equal $tfh [lindex [lindex $res 3] 2] $cont $PASS
  86 
  87 
  88 # d: Try to do Commit twice of same data, expect OK
  89 set expcode "OK"
  90 set ASSERTION "Try to do Commit twice of same data, expect $expcode"
  91 set tag "$TNAME{d}"
  92 putmsg stdout 0 "$tag: $ASSERTION"
  93 set newFd "Com-d.[pid]"
  94 set tfh [creatv4_file [file join $BASEDIR $newFd]]
  95 # writ some data w/file_sync flag:
  96 set data [string repeat "d" 8196]
  97 set res [compound {Putfh $tfh; Write {0 0} 0 f a $data; 
  98         Commit 10 1024; Commit 1000 4096; Getfh}]
  99 set cont [ckres "Commit" $status $expcode $res $FAIL]
 100 # Now verify filehandle after COMMIT remain the same
 101 fh_equal $tfh [lindex [lindex $res 4] 2] $cont $PASS
 102 
 103 
 104 # --------------------------------------------------------------
 105 # Cleanup the temp file:
 106 set res [compound {Putfh $bfh; Remove $newFa; 
 107         Remove $newFb; Remove $newFc; Remove $newFd}]
 108 if { "$status" != "OK" } {
 109         putmsg stderr 0 "\t WARNING: cleanup to remove tmp files failed"
 110         putmsg stderr 0 "\t          status=$status; please cleanup manually."
 111         putmsg stderr 1 "\t   res=($res)"
 112         putmsg stderr 1 "  "
 113         exit $WARNING
 114 }
 115 
 116 # disconnect and exit
 117 Disconnect
 118 exit $PASS