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 GETFH operation test - positive tests
  27 
  28 # include all test enironment
  29 source GETFH.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 getfh after Lookup, expect OK
  41 set expcode "OK"
  42 set ASSERTION "basic Getfh after Lookup, expect $expcode"
  43 putmsg stdout 0 "$TNAME{a}: $ASSERTION"
  44 set res [compound {Putfh $bfh; Lookup "$env(TEXTFILE)"; Getfh}]
  45 set cont [ckres "Getfh" $status $expcode $res $FAIL]
  46 # Now verify filehandle returned is new 
  47   set nfh [lindex [lindex $res 2] 2]
  48   if { [fh_equal $bfh $nfh $cont $FAIL] } {
  49         putmsg stderr 0 "\t Test FAIL: new FH was not changed."
  50         putmsg stderr 1 "\t   nfh=($nfh)"
  51         putmsg stderr 1 "\t   bfh=($bfh)"
  52         putmsg stderr 1 "  "
  53   } else {
  54         logres PASS
  55   }
  56 
  57 
  58 # b: basic getfh after Create, expect OK
  59 set expcode "OK"
  60 set tdir "getfh_tdir.[pid]"
  61 set ASSERTION "basic Getfh after Create, expect $expcode"
  62 putmsg stdout 0 "$TNAME{b}: $ASSERTION"
  63 set res [compound {Putfh $bfh; Create "$tdir" {{mode 0700}} d; Getfh}]
  64 set cont [ckres "Getfh" $status $expcode $res $FAIL]
  65 # Now verify filehandle returned is good
  66   verf_fh [lindex [lindex $res 2] 2] $cont $PASS
  67 
  68 
  69 # c: basic getfh after Putrootfh, expect OK
  70 set expcode "OK"
  71 set ASSERTION "basic Getfh after Putrootfh, expect $expcode"
  72 putmsg stdout 0 "$TNAME{c}: $ASSERTION"
  73 set res [compound {Putrootfh; Getfh}]
  74 set cont [ckres "Getfh" $status $expcode $res $FAIL]
  75 # Now verify filehandle returned is good
  76   verf_fh [lindex [lindex $res 1] 2] $cont $PASS
  77 
  78 
  79 # d: basic getfh after Putpubfh, expect OK
  80 # This test assume $SERVER have 'public' filesystem exported.
  81 set expcode "OK"
  82 set ASSERTION "basic Getfh after Putpubfh, expect $expcode"
  83 putmsg stdout 0 "$TNAME{d}: $ASSERTION"
  84 set res [compound {Putpubfh; Getfh}]
  85 set cont [ckres "Getfh" $status $expcode $res $FAIL]
  86 # Now verify filehandle returned is good
  87   verf_fh [lindex [lindex $res 1] 2] $cont $PASS
  88 
  89 
  90 # --------------------------------------------------------------
  91 # Final cleanup:
  92 #   remove the created temp dir $tdir
  93 set res [compound {Putfh $bfh; Remove $tdir}]
  94 if { "$status" != "OK" } {
  95         putmsg stderr 0 "\t WARNING: cleanup to remove created dir failed"
  96         putmsg stderr 0 "\t          status=$status; please cleanup manually."
  97         putmsg stderr 1 "\t   res=($res)"
  98         putmsg stderr 1 "  "
  99         exit $WARNING
 100 }
 101 
 102 # disconnect and exit
 103 Disconnect
 104 exit $PASS