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 CREATE operation test - positive tests
  27 
  28 # include all test enironment
  29 source CREATE.env
  30 source CREATE_proc
  31 
  32 # TESTROOT directory; must be set in the environment already
  33 set TESTROOT $env(TESTROOT)
  34 
  35 # ROOTDIR directory; must be set in the environment already
  36 set ROOTDIR $env(ROOTDIR)
  37 
  38 source [file join ${TESTROOT} lcltools]
  39 
  40 # setting local variables
  41 set TNAME $argv0
  42 
  43 if {[info exists env(DNS_SERVER)] == 1} {
  44         set domain [get_domain $env(SERVER) $env(DNS_SERVER)]
  45 } else {
  46         set domain [get_domain $env(SERVER)]
  47 }
  48 if {$domain == $NULL} {
  49         putmsg stderr 0 "$TNAME{all}:"
  50         putmsg stderr 0 "\tTest UNINITIATED: unable to determine the domain."
  51         putmsg stderr 0 "\tAssertions won't be executed."
  52         exit $UNINITIATED
  53 }
  54 
  55 # connect to the test server
  56 Connect
  57 
  58 set tag $TNAME.setup
  59 set ROOTDIRS [path2comp $ROOTDIR $::DELM]
  60 set fh [get_fh $ROOTDIRS]
  61 set status OK
  62 
  63 # Start testing
  64 # --------------------------------------------------------------
  65 
  66 
  67 # a: known mapable user id
  68 set tag $TNAME{a}
  69 set expct "OK"
  70 set ASSERTION "known mapable user id, expect $expct"
  71 putmsg stdout 0 "$tag: $ASSERTION"
  72 set filename $tag
  73 set TESTFILE [file join $ROOTDIR "$filename"]
  74 set owner 5
  75 set group ""
  76 set st [uid_creat $fh $filename owner group res "root@$domain" "" f]
  77 ckres "Create" $st $expct $res $PASS
  78 if {[get_fh "$ROOTDIRS $filename"] != ""} {
  79         set res [removev4 $TESTFILE]
  80         if {$status != "OK"} {
  81                 putmsg stdout 0 "Warning: Could not remove $TESTFILE."
  82                 putmsg stdout 0 "\tres=$res"
  83         }
  84 }
  85 
  86 
  87 # b: known mapable group id
  88 set tag $TNAME{b}
  89 set expct "OK"
  90 set ASSERTION "known mapable group id, expect $expct"
  91 putmsg stdout 0 "$tag: $ASSERTION"
  92 set filename $tag
  93 set TESTFILE [file join $ROOTDIR "$filename"]
  94 set owner ""
  95 set group 5
  96 set st [uid_creat $fh $filename owner group res "" "uucp@$domain" f]
  97 ckres "Create" $st $expct $res $PASS
  98 if {[get_fh "$ROOTDIRS $filename"] != ""} {
  99         set res [removev4 $TESTFILE]
 100         if {$status != "OK"} {
 101                 putmsg stdout 0 "Warning: Could not remove $TESTFILE."
 102                 putmsg stdout 0 "\tres=$res"
 103         }
 104 }
 105 
 106 
 107 # c: owner id 0
 108 set tag $TNAME{c}
 109 set expct "OK"
 110 set ASSERTION "owner id 0, expect $expct"
 111 putmsg stdout 0 "$tag: $ASSERTION"
 112 set filename $tag
 113 set TESTFILE [file join $ROOTDIR "$filename"]
 114 set owner 0
 115 set group ""
 116 set st [uid_creat $fh $filename owner group res "root@$domain" "" f]
 117 ckres "Create" $st $expct $res $PASS
 118 if {[get_fh "$ROOTDIRS $filename"] != ""} {
 119         set res [removev4 $TESTFILE]
 120         if {$status != "OK"} {
 121                 putmsg stdout 0 "Warning: Could not remove $TESTFILE."
 122                 putmsg stdout 0 "\tres=$res"
 123         }
 124 }
 125 
 126 
 127 # d: group id 0
 128 set tag $TNAME{d}
 129 set expct "OK"
 130 set ASSERTION "group id 0, expect $expct"
 131 putmsg stdout 0 "$tag: $ASSERTION"
 132 set filename $tag
 133 set TESTFILE [file join $ROOTDIR "$filename"]
 134 set owner ""
 135 set group 0
 136 set st [uid_creat $fh $filename owner group res "" "root@$domain" f]
 137 ckres "Create" $st $expct $res $PASS
 138 if {[get_fh "$ROOTDIRS $filename"] != ""} {
 139         set res [removev4 $TESTFILE]
 140         if {$status != "OK"} {
 141                 putmsg stdout 0 "Warning: Could not remove $TESTFILE."
 142                 putmsg stdout 0 "\tres=$res"
 143         }
 144 }
 145 
 146 
 147 # e: user id known only to server
 148 set tag $TNAME{e}
 149 set expct "OK"
 150 set ASSERTION "user id known only to server, expect $expct"
 151 putmsg stdout 0 "$tag: $ASSERTION"
 152 set filename $tag
 153 set TESTFILE [file join $ROOTDIR "$filename"]
 154 set owner "$::env(TUSERSID)"
 155 set group ""
 156 set st [uid_creat $fh $filename owner group res "root@$domain" "" f]
 157 ckres "Create" $st $expct $res $PASS
 158 if {[get_fh "$ROOTDIRS $filename"] != ""} {
 159         set res [removev4 $TESTFILE]
 160         if {$status != "OK"} {
 161                 putmsg stdout 0 "Warning: Could not remove $TESTFILE."
 162                 putmsg stdout 0 "\tres=$res"
 163         }
 164 }
 165 
 166 
 167 # --------------------------------------------------------------
 168 # disconnect and exit
 169 
 170 Disconnect
 171 exit $PASS