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 LINK operation test - negative tests
  27 
  28 # include all test enironment
  29 source LINK.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: Link without Putrootfh, expect NOFILEHANDLE
  41 set expcode "NOFILEHANDLE"
  42 set ASSERTION "Try to link with no Putrootfh, expect $expcode"
  43 putmsg stdout 0 "$TNAME{a}: $ASSERTION"
  44 set res [compound {Link newl}]
  45 ckres "Link" $status $expcode $res $PASS
  46 
  47 
  48 # b: Link without SaveFH, expect NOFILEHANDLE
  49 set expcode "NOFILEHANDLE"
  50 set ASSERTION "Try to link with no SaveFH, expect $expcode"
  51 putmsg stdout 0 "$TNAME{b}: $ASSERTION"
  52 set res [compound {Putfh $bfh; Link newl}]
  53 ckres "Link" $status $expcode $res $PASS
  54 
  55 
  56 # c: try to link w/name exist already, expect EXIST
  57 set expcode "EXIST"
  58 set ASSERTION "Try to link with name existed already, expect $expcode"
  59 putmsg stdout 0 "$TNAME{c}: $ASSERTION"
  60 set res [compound {Putfh $bfh; Lookup "$env(TEXTFILE)"; Savefh;
  61         Putfh $bfh; Link "$env(TEXTFILE)"}]
  62 ckres "Link" $status $expcode $res $PASS
  63 
  64 
  65 # d: try to link to a dir, expect ISDIR
  66 set expcode "ISDIR"
  67 set ASSERTION "Try to link to a directory, expect $expcode"
  68 putmsg stdout 0 "$TNAME{d}: $ASSERTION"
  69 set res [compound {Putfh $bfh; Getattr type; Savefh;
  70         Putfh $bfh; Lookup $env(DIR0777); Link newld}]
  71 ckres "Link" $status $expcode $res $PASS
  72 
  73 
  74 # e: Link with CURRENT_FH is a file, expect NOTDIR
  75 set expcode "NOTDIR"
  76 set ASSERTION "Try to link with CURRENT_FH is a file, expect $expcode"
  77 putmsg stdout 0 "$TNAME{e}: $ASSERTION"
  78 set res [compound {Putfh $bfh; Lookup $env(RWFILE); Savefh; Link newle}]
  79 ckres "Link" $status $expcode $res $PASS
  80 
  81 
  82 
  83 # h: Link with WrongSec, expect WRONGSEC
  84 set expcode "WRONGSEC"
  85 set ASSERTION "Link with WrongSec, expect $expcode"
  86 #putmsg stdout 0 "$TNAME{h}: $ASSERTION"
  87 #puts "\t Test UNTESTED: XXX need hooks to change SEC of FH in server.\n"
  88 
  89 
  90 # i: XXX how do we simulate some server errors:
  91 #       NFS4ERR_MOVE
  92 #       NFS4ERR_SERVERFAULT
  93 #       NFS4ERR_RESOURCE
  94 
  95 
  96 # m: try to Link of expired FH, expect FHEXPIRED
  97 set expcode "FHEXPIRED"
  98 set ASSERTION "Link an expired FH, expect $expcode"
  99 #putmsg stdout 0 "$TNAME{m}: $ASSERTION"
 100 #puts "\t Test UNTESTED: XXX need server hook for FH expired.\n"
 101 
 102 
 103 # t: try to link unlink'ble file, expect ACCESS
 104 # {Putrootfh OK} {Lookup OK} {Link ACCES}
 105 set expcode "ACCESS"
 106 set ASSERTION "try to link unlink'ble file, expect $expcode"
 107 #putmsg stdout 0 "$TNAME{t}: $ASSERTION"
 108 #puts "\t Test UNTESTED: XXX what is unlink'ble (/usr/bin/ls??) .\n"
 109 
 110 
 111 # u: try to link into noperm_dir, expect ACCESS
 112 set expcode "ACCESS"
 113 set ASSERTION "try to link into noperm_dir, expect $expcode"
 114 putmsg stdout 0 "$TNAME{u}: $ASSERTION"
 115 set res [compound {Putfh $bfh; Lookup "$env(TEXTFILE)"; Savefh;
 116         Putfh $bfh; Lookup $env(DNOPERM);  Link newl1u}]
 117 ckres "Link" $status $expcode $res $PASS
 118 
 119 
 120 
 121 # --------------------------------------------------------------
 122 # disconnect and exit
 123 Disconnect
 124 exit $PASS