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 2008 Sun Microsystems, Inc.  All rights reserved.
  25 # Use is subject to license terms.
  26 #
  27 # NFSv4 client name space test - positive tests
  28 #
  29 
  30 [ -n "$DEBUG" ] && [ "$DEBUG" != "0" ] && set -x
  31 
  32 NAME=`basename $0`
  33 CDIR=`pwd`
  34 
  35 # Source for common functions
  36 . $TESTROOT/testsh
  37 
  38 # check for root to run 
  39 is_root $NAME "NFSv4 name space tests (mount root)."
  40 
  41 TMPmnt=/$NAME.$$
  42 mkdir -m 0777 $TMPmnt
  43 
  44 
  45 # Start test assertions here
  46 # ----------------------------------------------------------------------
  47 # a: Verify client can mount '/', expect successful
  48 function assertion_a
  49 {
  50     [ -n "$DEBUG" ] && [ "$DEBUG" != "0" ] && set -x
  51     ASSERTION="Verify client can mount '/', expect successful"
  52     echo "$NAME{a}: $ASSERTION"
  53 
  54     # try to mount on the $SERVER '/'
  55     SRVPATH="/"
  56     mount -o vers=4,rw $SERVER:$SRVPATH $TMPmnt > $TMPDIR/$NAME.mnt.$$ 2>&1
  57     ckreturn $? "mount root did not succeed" $TMPDIR/$NAME.mnt.$$
  58     [ $? -ne 0 ] && return $FAIL
  59 
  60     # verify the mount point is access'ble
  61     ls -lt $TMPmnt > $TMPDIR/$NAME.ck.$$ 2>&1
  62     ckreturn $? "unable to access the mnt-point" $TMPDIR/$NAME.ck.$$
  63     [ $? -ne 0 ] && return $FAIL
  64 
  65     # should at least see the first node of $BASEDIR
  66     EXP=`echo "$BASEDIR" | nawk -F\/ '{print $2}'`
  67     grep "$EXP" $TMPDIR/$NAME.ck.$$ > /dev/null 2>&1
  68     if [ $? -ne 0 ]; then 
  69         echo "\tTest FAIL: did not see the first node" 
  70         cat $TMPDIR/$NAME.ck.$$
  71         return $FAIL
  72     fi
  73 
  74     # Finally umount and done
  75     umount $TMPmnt > $TMPDIR/$NAME.umnt.$$ 2>&1
  76     ckreturn $? "umount failed" $TMPDIR/$NAME.umnt.$$
  77     [ $? -ne 0 ] && return $FAIL
  78 
  79     echo "\t Test PASS"
  80 }
  81 
  82 # b: Verify client can mount '/' with public, expect successful
  83 function assertion_b
  84 {
  85     [ -n "$DEBUG" ] && [ "$DEBUG" != "0" ] && set -x
  86     ASSERTION="Verify client can mount '/' with public, expect successful"
  87     echo "$NAME{b}: $ASSERTION"
  88 
  89     # try to mount on the $SERVER '/' w/public option
  90     SRVPATH="/"
  91     mount -o vers=4,public $SERVER:$SRVPATH $TMPmnt > $TMPDIR/$NAME.mnt.$$ 2>&1
  92     ckreturn $? "mount root did not succeed" $TMPDIR/$NAME.mnt.$$
  93     [ $? -ne 0 ] && return $FAIL
  94 
  95     # verify the mount point is access'ble
  96     ls -lt $TMPmnt > $TMPDIR/$NAME.ck.$$ 2>&1
  97     ckreturn $? "unable to access the mnt-point" $TMPDIR/$NAME.ck.$$
  98     [ $? -ne 0 ] && return $FAIL
  99     (cd $TMPmnt/$DIR0777; pwd; cd $CDIR) > $TMPDIR/$NAME.ck2.$$ 2>&1
 100     ckreturn $? "unable to cd into mountptr" $TMPDIR/$NAME.ck2.$$
 101     [ $? -ne 0 ] && return $FAIL
 102 
 103     # and check on an existing file under the mount ptr
 104     grep "$BLKFILE" $TMPDIR/$NAME.ck.$$ > /dev/null 2>&1
 105     if [ $? -ne 0 ]; then 
 106         echo "\tTest FAIL: did not see <$BLKFILE> inside mnt point"
 107         cat $TMPDIR/$NAME.ck.$$
 108         return $FAIL
 109     fi
 110 
 111     # Finally umount and done
 112     umount $TMPmnt > $TMPDIR/$NAME.umnt.$$ 2>&1
 113     ckreturn $? "umount failed" $TMPDIR/$NAME.umnt.$$
 114     [ $? -ne 0 ] && return $FAIL
 115 
 116     echo "\t Test PASS"
 117 }
 118 
 119 # Start main program here:
 120 # ----------------------------------------------------------------------
 121 
 122 assertion_a
 123 [ $? -ne 0 ] && umount -f $TMPmnt > /dev/null 2>&1
 124 assertion_b
 125 [ $? -ne 0 ] && umount -f $TMPmnt > /dev/null 2>&1
 126 
 127 # cleanup tmp files
 128 rmdir $TMPmnt
 129 rm -f $TMPDIR/$NAME.*.$$
 130 
 131 exit 0