1 #!/usr/bin/ksh
   2 
   3 #
   4 # This file and its contents are supplied under the terms of the
   5 # Common Development and Distribution License ("CDDL"), version 1.0.
   6 # You may only use this file in accordance with the terms of version
   7 # 1.0 of the CDDL.
   8 #
   9 # A full copy of the text of the CDDL should have accompanied this
  10 # source.  A copy of the CDDL is also available via the Internet at
  11 # http://www.illumos.org/license/CDDL.
  12 #
  13 
  14 #
  15 # Copyright 2016 Nexenta Systems, Inc.  All rights reserved.
  16 #
  17 
  18 #
  19 # Test wrapper for NFS v4 tests
  20 #
  21 # Define necessary environments and config variables here
  22 #
  23 export STF_SUITE=/opt/nfsv4-tests
  24 export TESTROOT=$STF_SUITE/bin
  25 export LANG=C
  26 
  27 ALL="-a -l -b -n -m -o -s -r"   # valid tests
  28 Tests="-a       all
  29         -l      acl tet.ksht
  30         -b      basic ops test
  31         -n      num_attrs test
  32         -m      named_attrs test
  33         -o      other tests
  34         -s      srv namespc test
  35         -r      recovery test
  36 "
  37 
  38 #
  39 # Option is passed to the actual run script
  40 #
  41 usage() {
  42         echo "Usage: $0 ip test"
  43         echo "Where"
  44         echo "   ip     nfs server IP address"
  45         echo "   test   has to be one of the following options:"
  46         echo
  47         echo "          $Tests"
  48         echo "          If not specified, run all"      
  49         exit 1
  50 }
  51 
  52 #
  53 # Must be run by root
  54 #
  55 if [ `id -u` -ne 0 ]; then
  56         echo Must run by root
  57         exit 1
  58 fi
  59 
  60 #
  61 # IP is a must and is $1
  62 #
  63 if [ $# -lt 1 ]; then
  64         usage
  65 fi
  66 
  67 SERVER=$1
  68 ping $SERVER 5
  69 if [ $? != 0 ]; then
  70         echo Invalid nfs server is specified
  71         exit 1
  72 fi
  73 export SERVER
  74 
  75 shift
  76 TEST=$@
  77 
  78 #
  79 # Bail out if an invalid test is specified
  80 # No test specified == run all
  81 #
  82 if [ -z "$TEST" ]; then
  83         TEST='-a'       # Run all tests
  84 elif [ "${ALL#*$TEST}" = "$ALL" ]; then
  85         usage
  86 fi
  87 
  88 #
  89 # Setup the server and client
  90 #
  91 ./go_setup
  92 
  93 #
  94 # Run the test, run all if TEST is -a
  95 #
  96 ./runtests $TEST
  97 
  98 #
  99 # Cleanup
 100 #
 101 ./go_cleanup