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_list_005
  32 #
  33 # DESCRIPTION:
  34 #       The 'list' subcommand expects at most one argument 
  35 #       (a pattern).  If more than one arguments is given then 
  36 #       a diagnostic message is sent to stderr and an exit status 
  37 #       of 1 is returned.
  38 
  39 #
  40 # end __stf_assertion__
  41 ###############################################################################
  42 
  43 # First STF library
  44 . ${STF_TOOLS}/include/stf.kshlib
  45 
  46 # Load GL library
  47 . ${STF_SUITE}/include/gltest.kshlib
  48 
  49 readonly ME=$(whence -p ${0})
  50 readonly MYLOC=$(dirname ${ME})
  51 
  52 
  53 # Initialize test result 
  54 typeset -i RESULT=$STF_PASS
  55 
  56 function cleanup {
  57         
  58         # Note that $TEST_SERVICE may or may not exist so don't check
  59         # results.  Just make sure the service is gone.
  60         service_delete $TEST_SERVICE
  61 
  62         service_exists ${TEST_SERVICE}
  63         [[ $? -eq 0 ]] && {
  64                 echo "--DIAG: [${assertion}, cleanup]
  65                 service ${TEST_SERVICE} should not exist in
  66                 repository after being deleted, but does"
  67 
  68                 RESULT=$(update_result $STF_UNRESOLVED $RESULT)
  69         }
  70 
  71 
  72         rm -f $OUTFILE $ERRFILE $CMDFILE $OUTFILE2
  73 
  74         exit $RESULT
  75 }
  76 
  77 trap cleanup 0 1 2 15
  78 
  79 # make sure that the environment is sane - svc.configd is up and running
  80 check_gl_env
  81 [[ $? -ne 0 ]] && {
  82         echo "--DIAG: 
  83         Invalid test environment - svc.configd is not available"
  84 
  85         RESULT=$STF_UNRESOLVED 
  86         exit $RESULT
  87 }
  88 
  89 # extract and print assertion information from this source script.
  90 extract_assertion_info $ME
  91 
  92 assertion=svccfg_list_005
  93 
  94 
  95 svccfg list * [a-z]* > $OUTFILE 2>$ERRFILE
  96 ret=$?
  97 
  98 # Verify that the return value is as expected - non-fatal error
  99 [[ $ret -ne 1 ]] &&  {
 100         echo "--DIAG: [${assertion}]
 101         svccfg expected to return 1, got $ret"
 102 
 103         RESULT=$STF_FAIL
 104 }
 105 
 106 # Verify that nothing in stdout - non-fatal error
 107 [[ -s $OUTFILE ]] &&  {
 108         echo "--DIAG: [${assertion}]
 109         stdout not expected, but got $(cat $OUTFILE)"
 110 
 111         RESULT=$STF_FAIL
 112 }
 113 
 114 # Verify that a message is sent to stderr
 115 if ! egrep -s "$SYNTAX_ERRMSG" $ERRFILE
 116 then
 117         echo "--DIAG: [${assertion}]
 118         Expected error message \"$SYNTAX_ERRMSG\"
 119         but got \"$(cat $ERRFILE)\""
 120 
 121         RESULT=$STF_FAIL
 122 fi
 123 
 124 rm -f $ERRFILE $OUTFILE $CMDFILE
 125 
 126 print_result $RESULT
 127 
 128 exit $RESULT
 129 
 130 
 131 
 132 
 133