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 2007 Sun Microsystems, Inc.  All rights reserved.
  24 # Use is subject to license terms.
  25 #
  26 # NFSv4 PUTPUBFH operation test - positive tests
  27 
  28 # include all test enironment
  29 source PUTPUBFH.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 # For the PUTPUBFH positive tests, the SERVER must export a 
  39 # PUBLIC filesystem.  So verify it here.
  40 set res [compound {Putpubfh; Getfh}]
  41 if { "$status" != "OK" } {
  42         putmsg stderr 0 "$TNAME: Test NOTINUSE"
  43         putmsg stderr 0 "\t SERVER=\[$SERVER\] does not seem to have public FS"
  44         putmsg stderr 1 "\t   res=($res)"
  45         exit $NOTINUSE
  46 }
  47 
  48 # Start testing
  49 # --------------------------------------------------------------
  50 # a: basic putpubfh - make sure gets a cfh, expect OK
  51 set expcode "OK"
  52 set ASSERTION "Putpubfh to set cfh, expect $expcode"
  53 putmsg stdout 0 "$TNAME{a}: $ASSERTION"
  54 set res [compound {Putpubfh; Getfh; Readdir 0 0 1024 1240 type}]
  55 set cont [ckres "Putpubfh" $status $expcode $res $FAIL]
  56 # verify filehandle from PUTROOTFH should be good
  57 set fh1 [lindex [lindex $res 1] 2]
  58 set fh2 [get_fh [path2comp $env(PUBTDIR) $DELM]]
  59 fh_equal $fh1 $fh2 $cont $PASS
  60 
  61 
  62 # b: use putpubfh to go back to public root, expect OK
  63 set expcode "OK"
  64 set ASSERTION "Putpubfh to go back to public root, expect $expcode"
  65 putmsg stdout 0 "$TNAME{b}: $ASSERTION"
  66 set res [compound {Putfh $bfh; Lookup $env(DIR0777); Getfh;
  67         Putpubfh; Lookup $env(DIR0777); Getfh}]
  68 set cont [ckres "Putpubfh" $status $expcode $res $FAIL]
  69 if {[string equal $cont "false"]} {
  70     # verify filehandle from PUTROOTFH are not the same as from PUTPUBFH
  71     set fh1 [lindex [lindex $res 2] 2]
  72     set fh2 [lindex [lindex $res 5] 2]
  73     set cont [fh_equal $fh1 $fh2 $cont $FAIL]
  74     if {[string equal $cont "false"]} {
  75         logres PASS
  76     } else {
  77         logres FAIL
  78         putmsg stderr 0 "\t    pub-fh is same as basedir-fh"
  79     }
  80 } else {
  81         logres PASS
  82 }
  83 
  84 
  85 # c: putpubfh as cfh to later go back
  86 set expcode "OK"
  87 set ASSERTION "Putpubfh as cfh to later go back, expect $expcode"
  88 putmsg stdout 0 "$TNAME{c}: $ASSERTION"
  89 set tpath "[path2comp $env(LONGDIR) $DELM]"
  90 set res [compound {Putpubfh; Getfh}]
  91 set cont [ckres "Putpubfh" $status $expcode $res $FAIL]
  92 if {! [string equal $cont "false"]} {
  93     set fh1 [lindex [lindex $res 1] 2]
  94     set res [compound {Putpubfh; foreach c $tpath {Lookup $c}; 
  95                 Putfh $fh1; Getfh}]
  96     set fh2 [lindex [lindex $res end] 2]
  97     fh_equal $fh1 $fh2 $cont $PASS
  98 }
  99 
 100 
 101 # --------------------------------------------------------------
 102 # disconnect and exit
 103 Disconnect
 104 exit $PASS