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 set/get attr FATTR4_CHANGE of changed file data, expect OK    
  29 # b: Test set/get attr FATTR4_CHANGE of changed file attrs, expect OK
  30 #
  31 
  32 set TESTROOT $env(TESTROOT)
  33 set delm $env(DELM)
  34 
  35 # include common code and init section
  36 source ${TESTROOT}${delm}tcl.init
  37 source ${TESTROOT}${delm}testproc
  38 
  39 # connect to the test server
  40 Connect
  41 
  42 # setting local variables
  43 set TNAME $argv0
  44 set expcode "OK"
  45 
  46 # Start testing
  47 # -------------------------------------------------------------------
  48 
  49 # Create a new file for testing purposes
  50 set filename "newfile.[pid]"
  51 set bfh [get_fh "$BASEDIRS"]
  52 set tfile "[creatv4_file "$BASEDIR/$filename"]"
  53 
  54 set sid {0 0} 
  55 
  56 # -------------------------------------------------------------------
  57 # a: Test set/get attr FATTR4_CHANGE of changed file data, expect OK
  58 #
  59 # Setup testfile for attribute purposes
  60 set attr {change}
  61 
  62 set ASSERTION "Test set/get attr FATTR4_CHANGE of changed file data, $expcode"
  63 putmsg stdout 0 "$TNAME{a}: $ASSERTION"
  64 
  65 #Get the change attr of the new file 
  66 set res [compound { Putfh $bfh; Lookup $filename; Getfh; Getattr $attr }]
  67 set cont [ckres "Getattr" $status $expcode $res $FAIL]
  68 
  69 if { ![string equal $cont "false"] } {
  70 
  71 set chgattr1 [ extract_attr [lindex [lindex $res 3] 2] "change" ]
  72 set addtofile "[write_ascii $tfile $sid "This is just a test"]" 
  73 
  74 #Get the change attr of the after a write to the new file
  75 set res2 [compound { Putfh $bfh; Lookup $filename; Getfh; Getattr $attr }]
  76 set cont [ckres "Getattr" $status $expcode $res2 $FAIL]
  77 
  78 if { ![string equal $cont "false"] } {
  79 
  80 set chgattr2 [ extract_attr [lindex [lindex $res2 3] 2] "change" ]
  81 if {[string compare $chgattr1 $chgattr2] == 0} {
  82         putmsg stderr 1 "\t chgattr1 is $chgattr1"
  83         putmsg stderr 1 "\t   res=($res)"
  84         putmsg stderr 1 "\t chgattr2 is $chgattr2"
  85         putmsg stderr 1 "\t   res2=($res2)"
  86         putmsg stdout 0 "\t Test FAIL"
  87 } else {
  88         putmsg stdout 0 "\t Test PASS"
  89 }
  90 
  91 }
  92 
  93 }
  94 
  95 #--------------------------------------------------------------------
  96 # b: Test set/get attr FATTR4_CHANGE of changed file attrs, expect OK
  97 
  98 set ASSERTION "Test set/get attr FATTR4_CHANGE of file object, expect $expcode"
  99 putmsg stdout 0 "$TNAME{b}: $ASSERTION"
 100 
 101 set attrs {size mode owner time_access time_modify change}
 102 
 103 set sid {0 0}
 104 set chgmode 444
 105 set nta "[clock seconds] 0"
 106 set tmod 0
 107 
 108 # Generate a compound request to change the attributes
 109 set res3 [compound { Putfh $tfile;
 110         Setattr $sid { {mode {$chgmode}}
 111         {time_access_set {$nta}} {time_modify_set {$tmod}} };
 112         Getattr $attrs;
 113 }]
 114 set cont [ckres "Getattr" $status $expcode $res3 $FAIL]
 115 
 116 if { ![string equal $cont "false"] } {
 117 
 118 set chgattr3 [ extract_attr [lindex [lindex $res3 3] 2] "change" ]
 119 
 120 if {[string compare $chgattr2 $chgattr3] == 0} {
 121         putmsg stderr 1 "\t chgattr2 is $chgattr1"
 122         putmsg stderr 1 "\t   res2=($res2)"
 123         putmsg stderr 1 "\t chgattr3 is $chgattr3"
 124         putmsg stderr 1 "\t   res3=($res3)"
 125         putmsg stdout 0 "\t Test FAIL"
 126 } else {
 127         putmsg stdout 0 "\t Test PASS"
 128 }
 129 
 130 }
 131 puts ""
 132 
 133 set res [compound {Putfh $bfh; Remove $filename}]
 134 if {$status != "OK"} {
 135     puts "ERROR, compound1{} return status=$status"
 136     exit 1
 137 }
 138 
 139 Disconnect 
 140 exit 0