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 # In case the tester wants to see script output, allow them
  44 # to run in debug mode.
  45 #
  46 TESTNAME=`basename $0`
  47 if [ ! -z "${DEBUG}" ]
  48 then
  49     OUTFILE=/tmp/${TESTNAME}.$$
  50     echo "Output from test: ${TESTNAME}" >${OUTFILE}
  51     echo >>${OUTFILE}
  52     echo "debug output can be found at ${OUTFILE}"
  53 else
  54     OUTFILE=/dev/null
  55 fi
  56 
  57 #
  58 # Verify that the option is not already defined.
  59 #
  60 DATAFILE=/tmp/${TESTNAME}.data.$$
  61 /usr/sbin/dhtadm -r ${DHCPRSRC} -p ${DHCPPATH} -P >${DATAFILE} 2>>${OUTFILE}
  62 RET=$?
  63 if [ "${RET}" != "0" ]
  64 then
  65     rm ${DATAFILE}
  66     echo "Error displaying dhcptab = ${RET}"
  67     echo "${TESTNAME} - Test failed!"
  68     exit 1
  69 fi
  70 
  71 OPTION=`grep "^TestOpt" ${DATAFILE}`
  72 if [ ! -z "${OPTION}" ]
  73 then
  74     rm ${DATAFILE}
  75     echo "Option already exists in dhcptab"
  76     echo "${TESTNAME} - Test failed!"
  77     exit 1
  78 fi
  79 rm ${DATAFILE}
  80 
  81 #
  82 # Create the option.
  83 #
  84 /usr/sbin/dhtadm -r ${DHCPRSRC} -p ${DHCPPATH} -A -s TestOpt -d 'Vendor=the_test_class,11,ASCII,1,0'  >>${OUTFILE} 2>&1
  85 RET=$?
  86 if [ "${RET}" != "0" ]
  87 then
  88     echo "Error creating option = ${RET}"
  89     echo "${TESTNAME} - Test failed!"
  90     exit 1
  91 fi
  92 
  93 #
  94 # Verify that the option is defined in the dhcptab.
  95 #
  96 /usr/sbin/dhtadm -r ${DHCPRSRC} -p ${DHCPPATH} -P >${DATAFILE} 2>>${OUTFILE}
  97 RET=$?
  98 if [ "${RET}" != "0" ]
  99 then
 100     rm ${DATAFILE}
 101     echo "Error displaying dhcptab = ${RET}"
 102     echo "${TESTNAME} - Test failed!"
 103     exit 1
 104 fi
 105 
 106 OPTION=`grep "^TestOpt" ${DATAFILE}`
 107 if [ -z "${OPTION}" ]
 108 then
 109     rm ${DATAFILE}
 110     echo "Option not added to dhcptab."
 111     echo "${TESTNAME} - Test failed!"
 112     exit 1
 113 fi
 114 rm ${DATAFILE}
 115 
 116 #
 117 # Verify that the defintion was defined correctly
 118 #
 119 OPTION_DEFINITION=$(get_value ${OPTION})
 120 if [ "${OPTION_DEFINITION}" != "Vendor=the_test_class,11,ASCII,1,0" ]
 121 then
 122     echo "Option definition is not valid: *${OPTION_DEFINITION}*"
 123     echo "${TESTNAME} - Test failed!"
 124     exit 1
 125 fi
 126 
 127 echo "${TESTNAME} - Test passed."
 128 exit 0