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 numbered attributes:
  27 #
  28 # a: Test get attr FATTR4_TYPE of file object, expect OK
  29 # b: Test get attr FATTR4_TYPE of directory object, expect OK
  30 # c: Test  get attr FATTR4_TYPE of symlink object, expect OK
  31 # 
  32 
  33 # Get the TESTROOT directory; set to '.' if not defined
  34 set TESTROOT $env(TESTROOT)
  35 set delm $env(DELM)
  36 
  37 # include common code and init section
  38 source ${TESTROOT}${delm}tcl.init
  39 source ${TESTROOT}${delm}testproc
  40 
  41 # connect to the test server
  42 Connect
  43 
  44 # setting local variables
  45 set TNAME $argv0
  46 set expcode "OK"
  47 # Get testfile pathname
  48 set bfh [get_fh "$BASEDIRS"]
  49 set attr {type}
  50 
  51 # Start testing
  52 # ---------------------------------------------------------------
  53 # a: Test get attr FATTR4_TYPE of file object, expect OK 
  54 
  55 set ASSERTION "Test get attr FATTR4_TYPE of file object, expect $expcode"
  56 putmsg stdout 0 "$TNAME{a}: $ASSERTION"
  57 
  58 # Get the expected file type on filesystem using TCL commands for UNIX 
  59 set expval [file type "$MNTPTR${delm}$env(TEXTFILE)"] 
  60 
  61 # Generate a compound request that
  62 # obtains the attributes for the path.
  63 set res [compound { Putfh $bfh; Lookup $env(TEXTFILE); Getfh; Getattr $attr }]
  64 set cont [ckres "Getattr" $status $expcode $res $FAIL]
  65 set fh [lindex [lindex $res 2] 2]
  66 set attrcomp [ extract_attr [lindex [lindex $res 3] 2] "type" ]
  67 
  68 # Verify attr type value response from server
  69 if { ![string equal $cont "false"] } {
  70         if {[string equal $expval "file"] && [string equal $attrcomp "reg"]} {
  71                 prn_attrs [lindex [lindex $res 3] 2]
  72                 putmsg stdout 0 "\t Test PASS"
  73         } else {
  74                 putmsg stderr 1 "$BASEDIRS${delm}$env(TEXTFILE) is not a file"
  75                 putmsg stderr 0 "\t Test FAIL: wrong type attr"
  76         }
  77 }
  78         
  79 puts ""
  80 
  81 #--------------------------------------------------------------------
  82 # b: Test get attr FATTR4_TYPE of directory object, expect OK
  83 
  84 set ASSERTION "get attr FATTR4_TYPE of directory object, expect $expcode"
  85 putmsg stdout 0 "$TNAME{b}: $ASSERTION"
  86 
  87 # Get the expected file type on filesystem using TCL commands for UNIX 
  88 set expval [file type "$MNTPTR${delm}$env(DIR0777)"] 
  89 
  90 # Generate a compound request that
  91 # obtains the attributes for the path.
  92 set res [compound { Putfh $bfh; Lookup $env(DIR0777); Getfh; Getattr $attr }]
  93 set cont [ckres "Getattr" $status $expcode $res $FAIL]
  94 set fh [lindex [lindex $res 2] 2]
  95 
  96 set attrcomp [ extract_attr [lindex [lindex $res 3] 2] "type" ]
  97 
  98 # Verify attr type value response from server
  99 if { ![string equal $cont "false"] } {
 100         if {[string equal $expval "directory"] && [string equal $attrcomp "dir"]} {
 101                 prn_attrs [lindex [lindex $res 3] 2]
 102                 putmsg stdout 0 "\t Test PASS"
 103         } else {
 104                 putmsg stderr 1 "\t $BASEDIRS${delm}$env(DIR0777) is not a dir"
 105                 putmsg stderr 0 "\t Test FAIL: wrong type attr"
 106         }
 107 }
 108 
 109 puts ""
 110 
 111 #----------------------------------------------------------------
 112 # c: Test  get attr FATTR4_TYPE of symlink object, expect OK
 113 
 114 set ASSERTION "get attr FATTR4_TYPE of symlink object, expect $expcode"
 115 putmsg stdout 0 "$TNAME{c}: $ASSERTION"
 116 
 117 # Get the expected file type on filesystem using TCL commands for UNIX 
 118 set expval [file type "$MNTPTR${delm}$env(SYMLFILE)"] 
 119 
 120 # Generate a compound request that
 121 # obtains the attributes for the path.
 122 set res [compound { Putfh $bfh; Lookup $env(SYMLFILE); Getfh; Getattr $attr }]
 123 set cont [ckres "Getattr" $status $expcode $res $FAIL]
 124 set fh [lindex [lindex $res 2] 2]
 125 
 126 set attrcomp [ extract_attr [lindex [lindex $res 3] 2] "type" ]
 127 
 128 # Verify attr type value response from server
 129 if { ![string equal $cont "false"] } {
 130         if {[string equal $expval "link"] && [string equal $attrcomp "lnk"]} {
 131                 prn_attrs [lindex [lindex $res 3] 2]
 132                 putmsg stdout 0 "\t Test PASS"
 133         } else {
 134                 putmsg stderr 1 "\t $BASEDIRS${delm}$env(SYMLFILE) is not a symlink"
 135                 putmsg stderr 0 "\t Test FAIL: wrong type attr"
 136         }
 137 }
 138 
 139 puts ""
 140 
 141 Disconnect 
 142 exit $PASS