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 REMOVE operation test - positive tests
  27 
  28 # include all test enironment
  29 source REMOVE.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 # Start testing
  39 # --------------------------------------------------------------
  40 # a: Try to remove a file, expect OK
  41 set expcode "OK"
  42 set ASSERTION "Try to Remove a file, expect $expcode"
  43 putmsg stdout 0 "$TNAME{a}: $ASSERTION"
  44 # first create a temp file to be removed:
  45 set tmpf "RemF.[pid]"
  46 set ffh [creatv4_file [file join $BASEDIR $tmpf]]
  47 if { $ffh != $NULL } {
  48     # now the remove test:
  49     set res [compound {Putfh $bfh; Remove $tmpf; Getfh}]
  50     set cont [ckres "Remove" $status $expcode $res $FAIL]
  51     set fh1 [lindex [lindex $res 2] 2]
  52 } else {
  53     putmsg stderr 0 "\t Test UNINITIATED: unable to create temp file."
  54     putmsg stderr 1 "\t   res=($res)"
  55     set cont "false"
  56 }
  57 # verify file is removed:
  58   if {! [string equal $cont "false"]} {
  59       set res [compound {Putfh $bfh; Lookup $tmpf}]
  60       if { $status != "NOENT" } {
  61           putmsg stderr 0 "\t Test FAIL: file exists after Remove."
  62           putmsg stderr 1 "\t   res=($res)"
  63           set cont false
  64       }
  65   }
  66 # verify FH is not changed after successful Readdir op
  67   fh_equal $fh1 $bfh $cont $PASS
  68 
  69 
  70 # b: Try to remove a dir that is empty, expect OK
  71 set expcode "OK"
  72 set ASSERTION "Remove a dir that is empty, expect $expcode"
  73 putmsg stdout 0 "$TNAME{b}: $ASSERTION"
  74 # first create a temp dir to be removed:
  75 set tmpd "RemD.[pid]"
  76 set res [compound {Putfh $bfh; Create $tmpd {{mode 0777}} d; Getfh}]
  77 if { $status != "OK" } {
  78     putmsg stderr 0 "\t Test UNINITIATED: unable to create temp dir."
  79     putmsg stderr 1 "\t   res=($res)"
  80     set cont false
  81 }
  82 # now remove it:
  83 if {! [string equal $cont "false"]} {
  84     set res [compound {Putfh $bfh; Remove $tmpd; Getfh}]
  85     set cont [ckres "Remove" $status $expcode $res $FAIL]
  86     set fh1 [lindex [lindex $res 2] 2]
  87 }
  88 # verify file is removed:
  89   if {! [string equal $cont "false"]} {
  90       set res [compound {Putfh $bfh; Lookup $tmpd}]
  91       if { $status != "NOENT" } {
  92           putmsg stderr 0 "\t Test FAIL: dir exists after Remove."
  93           putmsg stderr 1 "\t   res=($res)"
  94           set cont false
  95       }
  96   }
  97 # verify FH is not changed after successful Readdir op
  98   fh_equal $fh1 $bfh $cont $PASS
  99 
 100 
 101 # c: Try to remove an entry of other file type w/mode=0 , expect OK
 102 set expcode "OK"
 103 set ASSERTION "Remove a Socket file w/mode=0, expect $expcode"
 104 putmsg stdout 0 "$TNAME{c}: $ASSERTION"
 105 # first create a temp socket file to be removed:
 106 set tmps "RemS.[pid]"
 107 set res [compound {Putfh $bfh; Create $tmps {{mode 0777}} s;
 108         Getfh; Setattr {0 0} {{mode 0}}}]
 109 if { $status != "OK" } {
 110     putmsg stderr 0 "\t Test UNINITIATED: unable to create temp sock."
 111     putmsg stderr 1 "\t   res=($res)"
 112     set cont false
 113 }
 114 # now remove it:
 115 if {! [string equal $cont "false"]} {
 116     set res [compound {Putfh $bfh; Remove $tmps; Getfh}]
 117     set cont [ckres "Remove" $status $expcode $res $FAIL]
 118     set fh1 [lindex [lindex $res 2] 2]
 119 }
 120 # verify file is removed:
 121   if {! [string equal $cont "false"]} {
 122       set res [compound {Putfh $bfh; Lookup $tmps}]
 123       if { $status != "NOENT" } {
 124           putmsg stderr 0 "\t Test FAIL: sock exists after Remove."
 125           putmsg stderr 1 "\t   res=($res)"
 126           set cont false
 127       }
 128   }
 129 # verify FH is not changed after successful Readdir op
 130   fh_equal $fh1 $bfh $cont $PASS
 131 
 132 
 133 # --------------------------------------------------------------
 134 # disconnect and exit
 135 Disconnect
 136 exit $PASS