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 
  28 ###############################################################################
  29 # start __stf_assertion__
  30 #
  31 # ASSERTION: svccfg_exit_002
  32 #
  33 # DESCRIPTION:
  34 #       The subcommand "exit" expects no arguments.  If an argument
  35 #       is passed an exit status of 1 is returned and a diagnostic
  36 #       message is sent to stderr.
  37 #
  38 # STRATEGY:
  39 #       Write a simple svccfg script which calls exit and then does
  40 #       a list subcommand.  Make sure that the list subcommand isn't
  41 #       executed.
  42 #
  43 # end __stf_assertion__
  44 ###############################################################################
  45 
  46 # First STF library
  47 . ${STF_TOOLS}/include/stf.kshlib
  48 
  49 # Load GL library
  50 . ${STF_SUITE}/include/gltest.kshlib
  51 
  52 
  53 readonly ME=$(whence -p ${0})
  54 readonly MYLOC=$(dirname ${ME})
  55 
  56 # Initialize test result 
  57 typeset -i RESULT=$STF_PASS
  58 
  59 
  60 function cleanup {
  61         
  62         rm -f $OUTFILE $ERRFILE $CMDFILE
  63 
  64         exit $RESULT
  65 }
  66 
  67 trap cleanup 0 1 2 15
  68 
  69 # make sure that the environment is sane - svc.configd is up and running
  70 check_gl_env
  71 [[ $? -ne 0 ]] && {
  72         echo "--DIAG: 
  73         Invalid test environment -svc.configd not available"
  74 
  75         RESULT=$STF_UNRESOLVED 
  76         exit $RESULT
  77 }
  78 
  79 # extract and print assertion information from this source script.
  80 extract_assertion_info $ME
  81 
  82 assertion=svccfg_exit_002
  83 
  84 
  85 svccfg  exit extra_option> $OUTFILE 2>$ERRFILE
  86 ret=$?
  87 
  88 # Verify that the return value is as expected - non-fatal error
  89 [[ $ret -ne 1 ]] &&  {
  90         echo "--DIAG: [${assertion}, test 1]
  91         svccfg expected to return 1, got $ret"
  92 
  93         RESULT=$STF_FAIL
  94 }
  95 
  96 # Verify that nothing in stdout - non-fatal error
  97 [[ -s $OUTFILE ]] &&  {
  98         echo "--DIAG: [${assertion}, test 1]
  99         stdout not expected, but got $(cat $OUTFILE)"
 100 
 101         RESULT=$STF_FAIL
 102 }
 103  
 104 # Verify that message in stderr - non-fatal error
 105 if ! egrep -s "$SYNTAX_ERRMSG" $ERRFILE
 106 then
 107         echo "--DIAG: [${assertion}, test 1]
 108         Expected error message \"$SYNTAX_ERRMSG\"
 109         but got \"$(cat $ERRFILE)\""
 110 
 111         RESULT=$STF_FAIL
 112 fi
 113 
 114 
 115 
 116         
 117 rm -f $ERRFILE $OUTFILE $CMDFILE
 118 
 119 print_result $RESULT
 120