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 2008 Sun Microsystems, Inc.  All rights reserved.
  24 # Use is subject to license terms.
  25 #
  26 # NFSv4 unsharell test using nfsv4shell
  27 #
  28 
  29 # include all test enironment
  30 source RECOV_proc
  31 
  32 set TNAME $argv0
  33 
  34 # connect to the test server
  35 Connect
  36 
  37 # First check this test is not started before previous tests
  38 # grace period ends.
  39 set ckgrace [file join $MNTPTR wait_for_grace]
  40 exec echo "wait_for_grace tmp file" > $ckgrace
  41 exec rm -f $ckgrace
  42 
  43 # Start the assertions here
  44 # --------------------------------------------------------------
  45 # a: Putrootfh after server unshareall, expect SERVERFAULT
  46 set expcode "SERVERFAULT"
  47 set ASSERTION "Putrootfh after server unshareall, expect $expcode"
  48 set tag "$TNAME{a}"
  49 putmsg stdout 0 "$tag: $ASSERTION"
  50 
  51 # First a compound to check we can READDIR at root
  52 set res [compound {Putrootfh; Readdir 0 0 1024 8192 {type filehandle}; Getfh}]
  53 if {$status != "OK"} {
  54         putmsg stderr 0 "\t Test UNRESOLVED: First readdir got status=($status)"
  55         putmsg stderr 0 "\t                  expected=(OK)"
  56         putmsg stderr 1 "\t   res=($res)"
  57 } else {
  58     set nfh [lindex [lindex $res 2] 2]
  59 
  60     # Now run a program to have $SERVER unshareall
  61     putmsg stderr 1 "  exec $SRVPROG unshare"
  62     set TmpFile [file join $env(TMPDIR) $TNAME.tmp.[pid]]
  63     if {[catch {exec $SRVPROG "unshare" 2> $TmpFile} out]} {
  64         putmsg stderr 0 "\t Test UNRESOLVED: failed to unshareall at $SERVER"
  65         putmsg stderr 0 "\t   out=($out)"
  66         if { $DEBUG > 1 } {
  67                 if {[catch {open $TmpFile} fd]} {
  68                         putmsg stderr 1 "  Cannot open $TmpFile: $fd"
  69                 } else {
  70                         read $fd
  71                         close $fd
  72                 }
  73         }
  74     } else {
  75         putmsg stderr 1 "  out=($out)"
  76         # Now the test of sending a Putrootfh compound
  77         set res [compound {Putrootfh; Readdir 0 0 1024 8192 {type filehandle}}]
  78         ckres "Putrootfh" $status $expcode $res $PASS
  79 
  80         # b: Putfh of an FH after server unshareall, expect STALE
  81         set expcode "STALE"
  82         set ASSERTION \
  83             "Putfh of an old FH after server unshareall, expect $expcode"
  84         set tag "$TNAME{b}"
  85         putmsg stdout 0 "$tag: $ASSERTION"
  86 
  87         set res [compound {Putfh $nfh; Readdir 0 0 1024 8192 {mode}}]
  88         ckres "Putfh" $status $expcode $res $PASS
  89     }
  90 }
  91 
  92 # Finally reshareall from $SERVER 
  93 putmsg stderr 1 "  exec $SRVPROG share"
  94 if {[catch {exec $SRVPROG "share" 2> $TmpFile} out]} {
  95         putmsg stderr 0 "\t WARNING: failed to shareall again at $SERVER"
  96         putmsg stderr 0 "\t          next test maybe affected."
  97         putmsg stderr 1 "  out=($out)"
  98         if { $DEBUG > 1 } {
  99                 if {[catch {open $TmpFile} fd]} {
 100                         putmsg stderr 1 "  Cannot open $TmpFile: $fd"
 101                 } else {
 102                         read $fd
 103                         close $fd
 104                 }
 105         }
 106 } else {
 107         putmsg stderr 1 "  out=($out)"
 108 }
 109 
 110 # --------------------------------------------------------------
 111 # cleanup, disconnect and exit
 112 file delete $TmpFile
 113 set tag ""
 114 Disconnect
 115 exit $PASS