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 named attributes:
  27 #
  28 # a: Test OPENATTR access of attr directory, expect OK
  29 # b: Test LOOKUPP of attribute directory, expect OK
  30 # c: Test READDIR of attribute directory, expect OK
  31 #
  32 
  33 set TESTROOT $env(TESTROOT)
  34 set delm $env(DELM)
  35 
  36 # include common code and init section
  37 source ${TESTROOT}${delm}tcl.init
  38 source ${TESTROOT}${delm}testproc
  39 
  40 # connect to the test server
  41 Connect
  42 
  43 # setting local variables
  44 set TNAME $argv0
  45 set bfh [get_fh "$BASEDIRS"]
  46 set expcode "OK"
  47 
  48 # Create a new file for testing purposes
  49 set filename "newfile.[pid]"
  50 set tfile "[creatv4_file "$BASEDIR${delm}$filename" 777]"
  51 if { [string equal $tfile ""] } {
  52         set ASSERTION "Test setup, expect OK"
  53         putmsg stdout 0 "$TNAME{all}: $ASSERTION"
  54         putmsg stdout 0 "\tTest FAIL: failed to create file $BASEDIR${delm}$filename on server"
  55         exit $UNINITIATED
  56 }
  57 
  58 # Start testing
  59 # ----------------------------------------------------------
  60 # a: Test OPENATTR access of attr directory, expect OK
  61 
  62 set ASSERTION "Test OPENATTR access of attr directory, expect OK"
  63 putmsg stdout 0 "$TNAME{a}: $ASSERTION"
  64 
  65 set res [compound {Putfh $bfh; Lookup $filename; Getfh}]
  66 set cont [ckres "Lookup" $status $expcode $res $FAIL]
  67 
  68 if { ![string equal $cont "false"] } {
  69 set createdir "T"
  70 # Create the named attr of newfile  
  71 set res2 [compound { Putfh $bfh; Lookup $filename; Getfh; Openattr $createdir }]
  72 set fh [lindex [lindex $res2 2] 2]
  73 ckres "Openattr" $status $expcode $res2 $PASS
  74 
  75 }
  76 
  77 # ----------------------------------------------------------
  78 # b: Test LOOKUPP of attribute directory, expect OK
  79 
  80 set ASSERTION "Test LOOKUPP of attribute directory, expect OK"
  81 putmsg stdout 0 "$TNAME{b}: $ASSERTION"
  82 
  83 set res [compound {Putfh $bfh; Lookup $filename; Getfh}]
  84 set cont [ckres "Lookup" $status $expcode $res $FAIL]
  85 
  86 if { ![string equal $cont "false"] } {
  87 set createdir "T"
  88 # Create the named attr of newfile
  89 set res2 [compound { Putfh $bfh; Lookup $filename; Openattr $createdir; Lookupp; Getfh }]
  90 set cont [ckres "Lookupp" $status $expcode $res2 $FAIL]
  91 # verify filehandle from LOOKUPP is the correct one
  92 set nfh [lindex [lindex $res2 4] 2]
  93 set cont [verf_fh [lindex [lindex $res2 4] 2] $cont $PASS]
  94 
  95 }
  96 
  97 # ----------------------------------------------------------------
  98 # c: Test READDIR of attribute directory, expect OK
  99 
 100 set ASSERTION "Test READDIR of attribute directory, expect OK"
 101 putmsg stdout 0 "$TNAME{c}: $ASSERTION"
 102 
 103 set cookie 0
 104 
 105 set res2 [compound { 
 106         Putfh $bfh
 107         Lookup $filename
 108         Openattr $createdir
 109         Getfh
 110         Readdir $cookie 0 1024 1024 { size type time_modify}
 111         Getfh } ]
 112 set cont [ckres "Readdir" $status $expcode $res2 $FAIL]
 113 
 114 # verify FH is not changed after successful Readdir after Openattr 
 115 set fh1 [lindex [lindex $res 3] 2]
 116 set fh2 [lindex [lindex $res 5] 2]
 117 fh_equal $fh1 $fh2 $cont $PASS
 118 
 119 # --------------------------------------------------------------
 120 # Cleanup the temp file:
 121 set res [compound {Putfh $bfh; Remove $filename}]
 122 if { "$status" != "OK" } {
 123         putmsg stderr 0 "\t WARNING: cleanup to remove $filename failed"
 124         putmsg stderr 0 "\t          status=$status; please cleanup manually."
 125         putmsg stderr 1 "\t   res=($res)"
 126         putmsg stderr 1 "  "
 127         exit $WARNING
 128 }
 129 
 130 Disconnect 
 131 exit 0