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 # - testing successful creation of other file types, such SOCK and FIFO
  28 
  29 # include all test enironment
  30 source CREATE.env
  31 
  32 # connect to the test server
  33 Connect
  34 
  35 
  36 # setting local variables
  37 set TNAME $argv0
  38 set bfh [get_fh $BASEDIRS]
  39 
  40 # Start testing
  41 # --------------------------------------------------------------
  42 # a: create a new sock file, expect OK
  43 set expcode "OK"
  44 set nsock "newsock.[pid]"
  45 set ASSERTION "Create a new sock file, expect $expcode"
  46 set tag $TNAME{a}
  47 putmsg stdout 0 "$tag: $ASSERTION"
  48 set res [compound {Putfh $bfh; Create $nsock {{mode 0666}} s;
  49         Getfh; Getattr type}]
  50 set cont [ckres "Create" $status $expcode $res $FAIL]
  51 # verify filehandle from CREATE should be good
  52 set cont [verf_fh [lindex [lindex $res 2] 2] $cont $FAIL]
  53 if {! [string equal $cont "false"]} {
  54     # check new type must be a sock
  55     set ntype [lindex [lindex [lindex [lindex $res 3] 2] 0] 1]
  56     if { "$ntype" != "sock" } {
  57         putmsg stderr 0 "\t Test FAIL: got unexpected type ($ntype)."
  58         putmsg stderr 0 "\t              expected type is (sock)."
  59         putmsg stderr 1 "\t   res=($res)"
  60         putmsg stderr 1 "  "
  61     } else {
  62         logres PASS
  63     }
  64 }
  65 
  66 
  67 # b: create a new fifo file, expect OK
  68 set expcode "OK"
  69 set nfifo "newfifo.[pid]"
  70 set ASSERTION "Create a new fifo file, expect $expcode"
  71 set tag $TNAME{b}
  72 putmsg stdout 0 "$tag: $ASSERTION"
  73 set res [compound {Putfh $bfh; Create $nfifo {{mode 0666}} f; 
  74         Getfh; Getattr type}]
  75 set cont [ckres "Create" $status $expcode $res $FAIL]
  76 # Now verify - filehandle from CREATE should be good
  77 set cont [verf_fh [lindex [lindex $res 2] 2] $cont $FAIL]
  78 if {! [string equal $cont "false"]} {
  79     # check new type must be a fifo
  80     set ntype [lindex [lindex [lindex [lindex $res 3] 2] 0] 1]
  81     if { "$ntype" != "fifo" } {
  82         putmsg stderr 0 "\t Test FAIL: got unexpected type ($ntype)."
  83         putmsg stderr 0 "\t              expected type is (fifo)."
  84         putmsg stderr 1 "\t   res=($res)"
  85         putmsg stderr 1 "  "
  86     } else {
  87         logres PASS
  88     }
  89 }
  90 
  91 
  92 # --------------------------------------------------------------
  93 # Final cleanup
  94 # cleanup remove the created dir
  95 set res [compound {Putfh $bfh; Remove $nsock; Remove $nfifo; }]
  96 if { "$status" != "OK" } {
  97         putmsg stderr 0 "\t WARNING: cleanup to remove created dir failed"
  98         putmsg stderr 0 "\t          status=$status; please cleanup manually."
  99         putmsg stderr 1 "\t   res=($res)"
 100         putmsg stderr 1 "  "
 101 }
 102 
 103 # disconnect and exit
 104 Disconnect
 105 exit $PASS