1 #! /usr/bin/ksh -p
   2 #
   3 # CDDL HEADER START
   4 #
   5 # The contents of this file are subject to the terms of the
   6 # Common Development and Distribution License (the "License").
   7 # You may not use this file except in compliance with the License.
   8 #
   9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  10 # or http://www.opensolaris.org/os/licensing.
  11 # See the License for the specific language governing permissions
  12 # and limitations under the License.
  13 #
  14 # When distributing Covered Code, include this CDDL HEADER in each
  15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16 # If applicable, add the following below this CDDL HEADER, with the
  17 # fields enclosed by brackets "[]" replaced with your own identifying
  18 # information: Portions Copyright [yyyy] [name of copyright owner]
  19 #
  20 # CDDL HEADER END
  21 #
  22 
  23 #
  24 # Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  25 # Use is subject to license terms.
  26 #
  27 
  28 # the file is designed for "no OTW operation" tests. It is called
  29 # in the following way:
  30 #
  31 #    nonewop <testfile> <cmd1> <deleg_type1> <cmd2> <deleg_type2>
  32 #
  33 # the script will first create $testfile, and then execute $cmd1
  34 # to get expected $deleg_type1, and then execute $cmd2 to get
  35 # expected $deleg_type2. It verifies $cmd2 won't cause new OPEN
  36 # or CLOSE operations.
  37 
  38 . ${STF_SUITE}/include/nfsgen.kshlib
  39 . ${STF_SUITE}/tests/delegation/include/delegation.kshlib
  40 
  41 NAME=$(basename $0)
  42 
  43 [[ :$_NFS_STF_DEBUG: = *:${NAME}:* \
  44         || :${_NFS_STF_DEBUG}: = *:all:* ]] && set -x
  45 
  46 function cleanup {
  47         retcode=$1
  48         rm -f $testfile $STF_TMPDIR/local.out.*
  49         exit $retcode
  50 }
  51 
  52 testfile=$1
  53 cmd1=$2
  54 dtype1=$3
  55 cmd2=$4
  56 dtype2=$5
  57 
  58 # create test file
  59 RUN_CHECK create_file_nodeleg $testfile || cleanup $STF_UNRESOLVED
  60 
  61 # run command 1, check delegation type
  62 eval $cmd1 > $STF_TMPDIR/local.out.$$ 2>&1
  63 deleg_type=$(grep "return_delegation_type" $STF_TMPDIR/local.out.$$ \
  64         | nawk -F\= '{print $2'})
  65 if [[ $deleg_type -ne $dtype1 ]]; then
  66         print -u2 "unexpected delegation type($deleg_type)"
  67         cat $STF_TMPDIR/local.out.$$
  68         cleanup $STF_FAIL
  69 fi
  70 
  71 # save current open and close statistic
  72 prev_open=$(save_rfsreqcntv4 open) || cleanup $STF_UNRESOLVED
  73 prev_close=$(save_rfsreqcntv4 close) || cleanup $STF_UNRESOLVED
  74 
  75 # run command 2, check delegation type
  76 i=0
  77 while ((i < 6)); do
  78         eval $cmd2 > $STF_TMPDIR/local.out.$$ 2>&1
  79         deleg_type=$(grep "return_delegation_type" $STF_TMPDIR/local.out.$$ \
  80             | nawk -F\= '{print $2'})
  81         if [[ $deleg_type -ne $dtype2 ]]; then
  82                 print -u2 "unexpected delegation type($deleg_type)" 
  83                 cat $STF_TMPDIR/local.out.$$
  84                 cleanup $STF_FAIL
  85         fi
  86         i=$((i + 1))
  87 done
  88 
  89 # check open and close op statistic
  90 RUN_CHECK check_rfsreqcntv4_equal open $prev_open || cleanup $STF_FAIL
  91 RUN_CHECK check_rfsreqcntv4_equal close $prev_close || cleanup $STF_FAIL
  92 
  93 # clean up 
  94 cleanup $STF_PASS