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 NVERIFY operation test - positive tests
  27 #       verify nverify with supported_attrs
  28 
  29 # include all test enironment
  30 source NVERIFY.env
  31 
  32 # connect to the test server
  33 Connect
  34 
  35 # setting local variables
  36 set TNAME $argv0
  37 set bfh [get_fh "$BASEDIRS"]
  38 set req_attrs "type fh_expire_type change size link_support
  39     symlink_support named_attr fsid unique_handles lease_time"
  40 
  41 # Start testing
  42 # --------------------------------------------------------------
  43 # a: Nverify of a file w/attr=dir, expect OK
  44 set expcode "OK"
  45 set ASSERTION "Nverify of a file w/attr=dir, expect $expcode"
  46 set tag "$TNAME{a}"
  47 putmsg stdout 0 "$tag: $ASSERTION"
  48 set res [compound {Putfh $bfh; Lookup $env(RWFILE); Getfh;
  49         Nverify {{type dir}}; Getfh}]
  50 set cont [ckres "Nverify" $status $expcode $res $FAIL]
  51 # verify FH is not changed after successful Nverify op
  52   set fh1 [lindex [lindex $res 2] 2]
  53   set fh2 [lindex [lindex $res 4] 2]
  54   fh_equal $fh1 $fh2 $cont $PASS
  55 
  56 
  57 # b: Nverify a file w/list of attrs, but one not match, expect OK
  58 set expcode "OK"
  59 set ASSERTION "Nverify a file w/attr list, but one not match, expect $expcode"
  60 set tag "$TNAME{b}"
  61 putmsg stdout 0 "$tag: $ASSERTION"
  62 set res [compound {Putfh $bfh; Lookup $env(ROFILE); Getattr "$req_attrs"}]
  63 set cont [ckres "Getattr" $status $expcode $res $FAIL]
  64 # Nverify all attr returned from Getattr
  65   if {! [string equal $cont "false"]} {
  66         set attrl [lindex [lindex $res 2] 2]
  67         # Let's change the "size"
  68         set si [lsearch -regexp $attrl "size .*"]
  69         set nal [lreplace $attrl $si $si {size 0}]
  70         # Then do a nverify
  71         set res [compound {Putfh $bfh; Lookup $env(ROFILE); Getfh;
  72                 Nverify {$nal}; Getfh}]
  73         set cont [ckres "Nverify" $status $expcode $res $FAIL]
  74   }
  75 # verify FH is not changed after successful Nverify op
  76   set fh1 [lindex [lindex $res 2] 2]
  77   set fh2 [lindex [lindex $res 4] 2]
  78   fh_equal $fh1 $fh2 $cont $PASS
  79 
  80 
  81 # c: Nverify a dir w/list of attrs, but one not match, expect OK
  82 set expcode "OK"
  83 set ASSERTION "Nverify a dir w/attr list, but one not match, expect $expcode"
  84 set tag "$TNAME{c}"
  85 putmsg stdout 0 "$tag: $ASSERTION"
  86 set res [compound {Putfh $bfh; Lookup $env(DIR0777); Getattr "$req_attrs"}]
  87 set cont [ckres "Getattr" $status $expcode $res $FAIL]
  88 # Nverify all attr returned from Getattr
  89   if {! [string equal $cont "false"]} {
  90         set attrl [lindex [lindex $res 2] 2]
  91         # Let's change the "mode"
  92         set si [lsearch -regexp $attrl "mode .*"]
  93         set nal [lreplace $attrl $si $si {mode 751}]
  94         # Then do a nverify
  95         set res [compound {Putfh $bfh; Lookup $env(DIR0777); Getfh;
  96                 Nverify {$nal}; Getfh}]
  97         set cont [ckres "Nverify" $status $expcode $res $FAIL]
  98   }
  99 # verify FH is not changed after successful Nverify op
 100   set fh1 [lindex [lindex $res 2] 2]
 101   set fh2 [lindex [lindex $res 4] 2]
 102   fh_equal $fh1 $fh2 $cont $PASS
 103 
 104 
 105 # --------------------------------------------------------------
 106 # disconnect and exit
 107 Disconnect
 108 exit $PASS