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 RENEW operation test - positive tests
  27 
  28 # include all test enironment
  29 source RENEW.env
  30 
  31 # connect to the test server
  32 Connect
  33 
  34 # setting local variables
  35 set TNAME $argv0
  36 set tag "$TNAME.setup"
  37 set bfh [get_fh "$BASEDIRS"]
  38 
  39 # first setup clientid for the tests and get the server lease_time
  40 set owner "$TNAME.[pid]"
  41 set clientid [getclientid $owner]
  42 if {$clientid == -1} {
  43         putmsg stdout 0 "$TNAME: test setup"
  44         putmsg stderr 0 "Test UNRESOLVED: getclientid failed"
  45         exit $UNRESOLVED
  46 }
  47 
  48 set leasetm $LEASE_TIME
  49 
  50 set tf "$env(RWFILE)"
  51 
  52 
  53 # Start testing
  54 # --------------------------------------------------------------
  55 # a: Renew with a good clientid, expect OK
  56 set expcode "OK"
  57 set ASSERTION "Renew with a good clientid, expect $expcode"
  58 set tag "$TNAME{a}"
  59 putmsg stdout 0 "$tag: $ASSERTION"
  60 set res [compound {Renew $clientid; Putfh $bfh; Lookup $tf; Getfh}]
  61 set cont [ckres "Renew" $status $expcode $res $FAIL]
  62 if {![string equal $cont "false"]} {
  63     # verify client is now able to do Open before lease_time
  64     set nlt [expr $leasetm - 10]
  65     if {$nlt < 0} {
  66         set nlt 1
  67     }
  68     exec sleep $nlt
  69     set nfh [basic_open $bfh $tf 0 "$clientid $owner" osid oseqid status 1 1]
  70     # open should return a good filehandle
  71     if {($nfh < 0) && ($status != "OK")} {
  72         putmsg stderr 0 "\tTest FAIL: basic_open failed, got status=($status)"
  73         putmsg stderr 0 "\t           expected status=(OK), nfh=($nfh)"
  74     } else {
  75         set fh2 [lindex [lindex $res 3] 2]
  76         fh_equal $nfh $fh2 $cont $PASS
  77     }
  78 }
  79 
  80 
  81 # b: Renew before lease expired then Open, expect OK
  82 set expcode "OK"
  83 set ASSERTION "Renew before lease expired then Open, expect $expcode"
  84 set tag "$TNAME{b}"
  85 putmsg stdout 0 "$tag: $ASSERTION"
  86 set res [compound {Renew $clientid}]
  87 if {[ckres "Renew" $status $expcode $res $FAIL] == "true"} {
  88     # wait before lease expired, then RENEW
  89     exec sleep [expr $leasetm - 1]
  90     set res [compound {Renew $clientid; Putfh $bfh; Lookup $tf; Getfh}]
  91     if {[ckres "Renew" $status $expcode $res $FAIL] == "true"} {
  92         # make sure to pass the original lease time
  93         exec sleep 5
  94         set nfh \
  95         [basic_open $bfh $tf 0 "$clientid $owner-b" osid oseqid status 2 1]
  96         if {($nfh < 0) && ($status != "OK")} {
  97             putmsg stderr 0 \
  98                 "\tTest FAIL: basic_open failed, got status=($status)"
  99             putmsg stderr 0 "\t           expected status=(OK), nfh=($nfh)"
 100         } else {
 101             set fh2 [lindex [lindex $res 3] 2]
 102             fh_equal $nfh $fh2 $cont $PASS
 103         }
 104     }
 105 }
 106 
 107 
 108 # --------------------------------------------------------------
 109 # disconnect and exit
 110 set tag "$TNAME.cleanup"
 111 Disconnect
 112 exit $PASS