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_TIME_ACCESS to get a time of a file, expect OK
  29 # b: Test get attr FATTR4_TIME_DELTA of a file, expect OK
  30 # c: Test get attr FATTR4_TIME_METADATA of a file, expect OK
  31 # d: Test get attr FATTR4_TIME_MODIFY of a file, expect OK
  32 #
  33 
  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 
  48 set bfh [get_fh "$BASEDIRS"]
  49 
  50 # Start testing
  51 # ---------------------------------------------------------------
  52 # a:Test get attr FATTR4_TIME_ACCESS of a file, expect OK
  53 
  54 set ASSERTION "Test get attr FATTR4_TIME_ACCESS of a file, expect OK"
  55 putmsg stdout 0 "$TNAME{a}: $ASSERTION"
  56 
  57 # Get expected last time access of a file  
  58 file stat $MNTPTR${delm}$env(TEXTFILE) stat1
  59 set expval [expr $stat1(atime)]
  60 
  61 # Setup testfile for attribute purposes
  62 set attr {time_access}
  63 
  64 #Get the filehandle of the test file 
  65 set res [compound {
  66         Putfh $bfh;
  67         Lookup $env(TEXTFILE);
  68         Getfh;
  69         Getattr $attr
  70 }]
  71 set cont [ckres "Getattr" $status $expcode $res $FAIL]
  72 
  73 if { ![string equal $cont "false"] } {
  74 
  75 set fh [lindex [lindex $res 2] 2]
  76 set attrval [ extract_attr [lindex [lindex $res 3] 2] $attr ]
  77 set timeaccess [lindex $attrval 0]
  78 
  79 if {[string equal $timeaccess $expval]} { 
  80         prn_attrs [lindex [lindex $res 3] 2]
  81         putmsg stdout 0 "\t Test PASS" 
  82 } else {
  83         prn_attrs [lindex [lindex $res 3] 2]
  84         putmsg stderr 0 "\t Test FAIL"
  85 }
  86 
  87 }
  88 
  89 # ---------------------------------------------------------------
  90 # b:Test get attr FATTR4_TIME_DELTA of a file, expect OK
  91 
  92 set ASSERTION "Test get attr FATTR4_TIME_DELTA of a file, expect OK"
  93 putmsg stdout 0 "$TNAME{b}: $ASSERTION"
  94 
  95 # Setup testfile for attribute purposes
  96 set attr {time_delta}
  97 
  98 #Get the filehandle of the test file
  99 set res [compound {
 100         Putfh $bfh;
 101         Lookup $env(TEXTFILE);
 102         Getfh;
 103         Getattr $attr
 104 }]
 105 set fh [lindex [lindex $res 2] 2]
 106 prn_attrs [lindex [lindex $res 3] 2]
 107 set fh_attr [ extract_attr [lindex [lindex $res 3] 2] $attr ]
 108 ckres "Getattr" $status $expcode $res $PASS
 109 
 110 # ---------------------------------------------------------------
 111 # c:Test get attr FATTR4_TIME_METADATA of a file, expect OK
 112 
 113 set ASSERTION "Test get attr FATTR4_TIME_METADATA of a file, expect OK"
 114 putmsg stdout 0 "$TNAME{c}: $ASSERTION"
 115 
 116 # Get expected last time access of a file
 117 file stat $MNTPTR${delm}$env(TEXTFILE) stat1
 118 set expval [expr $stat1(ctime)]
 119 
 120 # Setup testfile for attribute purposes
 121 set attr {time_metadata}
 122 
 123 #Get the filehandle of the test file
 124 set res [compound {
 125         Putfh $bfh;
 126         Lookup $env(TEXTFILE);
 127         Getfh;
 128         Getattr $attr
 129 }]
 130 set cont [ckres "Getattr" $status $expcode $res $FAIL]
 131 
 132 if { ![string equal $cont "false"] } {
 133 set fh [lindex [lindex $res 2] 2]
 134 set attrval [ extract_attr [lindex [lindex $res 3] 2] $attr ]
 135 set metadata [lindex $attrval 0]
 136 
 137 if {[string equal $metadata $expval]} {
 138         prn_attrs [lindex [lindex $res 3] 2]
 139         putmsg stdout 0 "\t Test PASS"
 140 } else {
 141         prn_attrs [lindex [lindex $res 3] 2]
 142         putmsg stderr 0 "\t Test FAIL"
 143 }
 144 }
 145 
 146 
 147 # ---------------------------------------------------------------
 148 # d:Test get attr FATTR4_TIME_MODIFY of a file, expect OK
 149 
 150 set ASSERTION "Test get attr FATTR4_TIME_MODIFY of a file, expect OK"
 151 putmsg stdout 0 "$TNAME{d}: $ASSERTION"
 152 
 153 # Get expected last time access of a file
 154 file stat $MNTPTR${delm}$env(TEXTFILE) stat1
 155 set expval [expr $stat1(mtime)]
 156 
 157 # Setup testfile for attribute purposes
 158 set attr {time_modify}
 159 
 160 #Get the filehandle of the test file
 161 set res [compound {
 162         Putfh $bfh;
 163         Lookup $env(TEXTFILE);
 164         Getfh;
 165         Getattr $attr
 166 }]
 167 set cont [ckres "Getattr" $status $expcode $res $FAIL]
 168 
 169 if { ![string equal $cont "false"] } {
 170 set fh [lindex [lindex $res 2] 2]
 171 set attrval [ extract_attr [lindex [lindex $res 3] 2] $attr ]
 172 set modify_time [lindex $attrval 0]
 173 
 174 if {[string equal $modify_time $expval]} {
 175         prn_attrs [lindex [lindex $res 3] 2]
 176         putmsg stdout 0 "\t Test PASS"
 177 } else {
 178         prn_attrs [lindex [lindex $res 3] 2]
 179         putmsg stderr 0 "\t Test FAIL"
 180 }
 181 }
 182 
 183 
 184 Disconnect 
 185 exit $PASS