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 # Test NFSv4 numbered attributes(UFS refers to Unix Filesystem): 
  27 # {a}: Test get attr FATTR4_TIME_BACKUP of last access to file not supported 
  28 #      on UFS, expect OK 
  29 # {b}: Test get attr FATTR4_TIME_CREATE for a file not supported on UFS, 
  30 #      expect OK 
  31 #
  32 # These attributes are NOT SUPPORTED on NFSv4 UFS.
  33 #
  34 
  35 # Get the TESTROOT directory; set to '.' if not defined
  36 set TESTROOT $env(TESTROOT)
  37 set delm $env(DELM)
  38 
  39 # include common code and init section
  40 source ${TESTROOT}${delm}tcl.init
  41 source ${TESTROOT}${delm}testproc
  42 
  43 # connect to the test server
  44 Connect
  45 
  46 # setting local variables
  47 set TNAME $argv0
  48 set bfh [get_fh "$BASEDIRS"]
  49 set expcode "OK"
  50 
  51 # Start testing 
  52 # -----------------------------------------------------------------
  53 # a: Test set/get attr FATTR4_TIME_BACKUP of last access to file, expect OK
  54 
  55 set ASSERTION "Test get attr FATTR4_TIME_BACKUP of last access to file, expect $expcode"
  56 putmsg stdout 0 "$TNAME{a}: $ASSERTION"
  57 
  58 # Get a list of the supported attributes
  59 set attr {supported_attrs}
  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 ckres "Getattr" $status $expcode $res $FAIL
  65 set fh [lindex [lindex $res 2] 2]
  66 # Create supported_attr list
  67 set alist [lindex [lindex $res 3] 2]
  68 foreach attrval $alist {
  69         set val [lindex $attrval 1]
  70         set list [split $val]
  71         putmsg stdout 1 "val on alist is $val"
  72         putmsg stdout 1 "split list is $list"
  73 }
  74 
  75 # Generate a compound request that
  76 # obtains the attributes for the path.
  77 set attr {time_backup}
  78 set res2 [compound { Putfh $bfh; Lookup $env(TEXTFILE); Getfh; Getattr $attr }]
  79 set cont [ckres "Getattr" $status $expcode $res2 $FAIL]
  80 
  81 if { ![string equal $cont "false"] } {
  82 # Verify attr not in supported_attr list
  83 if { [ lsearch -exact $list $attr ] < 0 } {
  84         putmsg stdout 0 "\tTest PASS: $attr not in supported attr list"
  85 } else {
  86         putmsg stdout 0 "\tTest FAIL: unexpected $attr in supported attr list"
  87 }
  88 }
  89 
  90 puts " "
  91 
  92 # -----------------------------------------------------------------
  93 # b: Test get attr FATTR4_TIME_CREATE for a file object, expect OK
  94 
  95 set ASSERTION "Test get attr FATTR4_TIME_CREATE for a file object, expect $expcode"
  96 putmsg stdout 0 "$TNAME{b}: $ASSERTION"
  97 
  98 # Get a list of the supported attributes
  99 set attr {supported_attrs}
 100 
 101 # Generate a compound request that
 102 # obtains the attributes for the path.
 103 set res [compound { Putfh $bfh; Lookup $env(TEXTFILE); Getfh; Getattr $attr }]
 104 set cont [ckres "Getattr" $status $expcode $res $FAIL]
 105 
 106 if { ![string equal $cont "false"] } { 
 107 
 108 set fh [lindex [lindex $res 2] 2]
 109 # Create supported_attr list
 110 set alist [lindex [lindex $res 3] 2]
 111 foreach attrval $alist {
 112         set val [lindex $attrval 1]
 113         set list [split $val]
 114         putmsg stdout 1 "val on alist is $val"
 115         putmsg stdout 1 "split list is $list"
 116 }
 117 
 118 
 119 # Setup testfile for attribute purposes
 120 set attr {time_create}
 121 
 122 # Attempt Getattr of unsupported time_create attr
 123 set res2 [compound { Putfh $bfh; Lookup $env(TEXTFILE); Getfh; Getattr $attr }]
 124 set cont2 [ckres "Getattr" $status $expcode $res2 $FAIL]
 125 
 126 if { ![string equal $cont2 "false"] } {
 127         # Verify attr not in supported_attr list
 128         if { [ lsearch -exact $list $attr ] < 0 } {
 129                 putmsg stdout 0 "\tTest PASS: $attr not in supported attr list"
 130         } else {
 131                 putmsg stdout 0 "\tTest FAIL: unexpected $attr in supported attr list"
 132         }
 133 }
 134 
 135 }
 136 
 137 puts ""
 138 
 139 Disconnect 
 140 exit $PASS