1 #!/usr/bin/ksh
   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, Version 1.0 only
   7 # (the "License").  You may not use this file except in compliance
   8 # with the License.
   9 #
  10 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  11 # or http://www.opensolaris.org/os/licensing.
  12 # See the License for the specific language governing permissions
  13 # and limitations under the License.
  14 #
  15 # When distributing Covered Code, include this CDDL HEADER in each
  16 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  17 # If applicable, add the following below this CDDL HEADER, with the
  18 # fields enclosed by brackets "[]" replaced with your own identifying
  19 # information: Portions Copyright [yyyy] [name of copyright owner]
  20 #
  21 # CDDL HEADER END
  22 #
  23 #
  24 #ident  "%Z%%M% %I%     %E% SMI"
  25 #
  26 # Copyright (c) 2001 by Sun Microsystems, Inc.
  27 # All rights reserved.
  28 #
  29 
  30 #
  31 # Source the utilities.
  32 #
  33 DIRNAME=`dirname $0`
  34 . ${DIRNAME}/utilities.san
  35 
  36 #
  37 # Process the input arguments.
  38 #
  39 VALIDOPTS=dr:p:
  40 process_args $@
  41 
  42 #
  43 # Set variables.
  44 #
  45 TESTNAME=`basename $0`
  46 if [ ! -z "${DEBUG}" ]
  47 then
  48     OUTFILE=/tmp/${TESTNAME}.$$
  49     echo "Output from test: ${TESTNAME}" >${OUTFILE}
  50     echo >>${OUTFILE}
  51     echo "debug output can be found at ${OUTFILE}"
  52 else
  53     OUTFILE=/dev/null
  54 fi
  55 
  56 #
  57 # Display the table.
  58 #
  59 DATAFILE=/tmp/${TESTNAME}.data.$$
  60 /usr/sbin/dhtadm -r ${DHCPRSRC} -p ${DHCPPATH} -P >${DATAFILE} 2>>${OUTFILE}
  61 RET=$?
  62 if [ "${RET}" != "0" ]
  63 then
  64     rm ${DATAFILE}
  65     echo "Error displaying dhcptab = ${RET}"
  66     echo "${TESTNAME} - Test failed!"
  67     exit 1
  68 fi
  69 
  70 #
  71 # Verify that the option is in the displayed output.
  72 #
  73 OPTION=`grep "^TestOpt" ${DATAFILE}`
  74 if [ -z "${OPTION}" ]
  75 then
  76     rm ${DATAFILE}
  77     echo "Option, TestOpt, not found in dhcptab"
  78     echo "${TESTNAME} - Test failed!"
  79     exit 1
  80 fi
  81 
  82 #
  83 # Verify that the defintion was defined correctly
  84 #
  85 OPTION_DEFINITION=$(get_value ${OPTION})
  86 if [ "${OPTION_DEFINITION}" != "Site,130,IP,1,0" ]
  87 then
  88     echo "Option definition is not valid: ${OPTION_DEFINITION}"
  89     echo "${TESTNAME} - Test failed!"
  90     exit 1
  91 fi
  92 
  93 #
  94 # Verify that the macro is in the displayed output.
  95 #
  96 MACRO=`grep "^TestMac" ${DATAFILE}`
  97 if [ -z "${MACRO}" ]
  98 then
  99     rm ${DATAFILE}
 100     echo "Macro, TestMac, not found in dhcptab"
 101     echo "${TESTNAME} - Test failed!"
 102     exit 1
 103 fi
 104 rm ${DATAFILE}
 105 
 106 #
 107 # Verify that the defintion was defined correctly
 108 #
 109 MACRO_DEFINITION=$(get_value ${MACRO})
 110 SRCH=":TestOpt=129.148.11.240:"
 111 macro_find_and_replace
 112 
 113 #
 114 # Verify that there was nothing else in the definition
 115 #
 116 if [ "${MACRO_DEFINITION}" != ":" ]
 117 then
 118     echo "Macro definition has invalid extra symbols: ${MACRO_DEFINITION}"
 119     echo "${TESTNAME} - Test failed!"
 120     exit 1
 121 fi
 122 
 123 echo "${TESTNAME} - Test passed."
 124 exit 0