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 OPENATTR operation test - positive tests
  27 
  28 # include all test enironment
  29 source OPENATTR.env
  30 
  31 # connect to the test server
  32 Connect
  33 
  34 # setting local variables
  35 set TNAME $argv0
  36 set bfh [get_fh "$BASEDIRS"]
  37 
  38 
  39 # Start testing
  40 # --------------------------------------------------------------
  41 # a: Readdir with <cfh> from OPENATTR(f) - expect OK
  42 set expcode "OK"
  43 set ASSERTION "Readdir with <cfh> from OPENATTR(f), expect $expcode"
  44 set tag "$TNAME{a}"
  45 putmsg stdout 0 "$tag: $ASSERTION"
  46 set res [compound {Putfh $bfh; Lookup $env(ATTRFILE); Openattr F;
  47         Readdir 0 0 1024 1024 type}]
  48 if {[ckres "Openattr/Readdir" $status $expcode $res $FAIL] == "true"} {
  49     # verify attribute returned in READDIR is namedattr
  50     set rdres [lindex [lindex $res 3] 3]
  51     set notmatch 0
  52     foreach de $rdres {
  53         set aval [extract_attr [lindex $de 2] "type"]
  54         if {$aval != "namedattr"} {
  55             incr notmatch
  56             putmsg stderr 0 \
  57             "\t Test FAIL: direntry($de) got type=($aval), expected=(namedattr)"
  58             putmsg stderr 1 "\t res=($res)"
  59         }
  60     }
  61     if {$notmatch == 0} {
  62         logres PASS
  63     }
  64 }
  65 
  66 
  67 # b: Try to create a new attr file under OPENATTR(f) - expect OK
  68 set expcode "OK"
  69 set ASSERTION "Try to create a new attr file under OPENATTR(f), expect $expcode"
  70 set tag "$TNAME{b}"
  71 putmsg stdout 0 "$tag: $ASSERTION"
  72 set owner "owner-attr"
  73 set cid [getclientid $owner]
  74 set oseqid 1
  75 set otype 1
  76 set tmpF "ATTR.tmp.[pid]"
  77 set res [compound {Putfh $bfh; Lookup $env(ATTRDIR); Openattr F; Getfh;
  78         Open $oseqid 3 0 {$cid $owner} {$otype 0 {{size 0}}} {0 $tmpF}; 
  79         Getfh; Getattr type}]
  80 if {[ckres "Openattr/Open" $status $expcode $res $FAIL] == "true"} {
  81     set open_sid [lindex [lindex $res 4] 2]
  82     set ofh [lindex [lindex $res 3] 2]
  83     set ffh [lindex [lindex $res 5] 2]
  84     set nat [extract_attr [lindex [lindex $res 6] 2] "type"]
  85     # verify attribute of newly created file is namedattr
  86     if {$nat != "namedattr"} {
  87         putmsg stderr 0 \
  88         "\t Test FAIL: new file($tmpF) got type=($nat), expected=(namedattr)"
  89         putmsg stderr 1 "\t res=($res)"
  90     } else {
  91             logres PASS
  92     }
  93     # finally cleanup
  94     incr oseqid
  95     compound {Putfh $ffh; Close $oseqid $open_sid; Putfh $ofh; Remove $tmpF}
  96 }
  97 
  98 
  99 # f: Lookupp of OPENATTR(f), verify filehandle - expect OK
 100 set expcode "OK"
 101 set ASSERTION "Lookupp of OPENATTR(f), verify filehandle, expect $expcode"
 102 set tag "$TNAME{f}"
 103 putmsg stdout 0 "$tag: $ASSERTION"
 104 set res [compound {Putfh $bfh; Lookup $env(ATTRFILE); Getfh; 
 105         Openattr F; Lookupp; Getfh}]
 106 set cont [ckres "Openattr/Lookupp" $status $expcode $res $FAIL]
 107 # verify filehandle are same as the file
 108 set afh [lindex [lindex $res 2] 2]
 109 set ofh [lindex [lindex $res 5] 2]
 110 fh_equal $afh $ofh $cont $PASS
 111 
 112 
 113 # g: Lookupp of OPENATTR(f), verify type - expect OK
 114 set expcode "OK"
 115 set ASSERTION "Lookupp of OPENATTR(f), verify type, expect $expcode"
 116 set tag "$TNAME{g}"
 117 putmsg stdout 0 "$tag: $ASSERTION"
 118 set res [compound {Putfh $bfh; Lookup $env(ATTRDIR); 
 119         Openattr F; Lookupp; Getattr type}]
 120 if {[ckres "Openattr/Lookupp" $status $expcode $res $FAIL] == "true"} {
 121     # verify type should match ATTRDIR
 122     set aval [extract_attr [lindex [lindex $res 4] 2] "type"]
 123     if {$aval != "dir"} {
 124             putmsg stderr 0 \
 125             "\t Test FAIL: after .., got type=($aval), expected=(dir)"
 126             putmsg stderr 1 "\t res=($res)"
 127     } else {
 128             logres PASS
 129     }
 130 }
 131 
 132 
 133 # --------------------------------------------------------------
 134 # disconnect and exit
 135 Disconnect
 136 exit $PASS