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_inventory_006
  32 #
  33 # DESCRIPTION:
  34 #       Calling the 'inventory file' subcommand, with multiple 
  35 #       service bundles will return with a diagnostic message 
  36 #       displayed on stderr. The exit status will be 1.
  37 #
  38 # end __stf_assertion__
  39 ###############################################################################
  40 
  41 
  42 # First STF library
  43 . ${STF_TOOLS}/include/stf.kshlib
  44 
  45 # Load GL library
  46 . ${STF_SUITE}/include/gltest.kshlib
  47 
  48 readonly ME=$(whence -p ${0})
  49 readonly MYLOC=$(dirname ${ME})
  50 
  51 # Initialize test result 
  52 typeset -i RESULT=$STF_PASS
  53 
  54 function cleanup {
  55         
  56         rm -f $OUTFILE $ERRFILE 
  57 
  58         exit $RESULT
  59 }
  60 
  61 trap cleanup 0 1 2 15
  62 
  63 # make sure that the environment is sane - svc.configd  is up and running
  64 check_gl_env
  65 [[ $? -ne 0 ]] && {
  66         echo "--DIAG: 
  67                 Invalid test environment - svc.configd  not available"
  68 
  69         RESULT=$STF_UNRESOLVED
  70         exit $RESULT
  71 }
  72 
  73 assertion=svccfg_inventory_006
  74 
  75 # extract and print assertion information from this source script.
  76 extract_assertion_info $ME
  77 
  78 readonly xml_file=$MYLOC/inventory_001.xml
  79 
  80 svccfg inventory $xml_file $xml_file > $OUTFILE 2>$ERRFILE
  81 ret=$?
  82 [[ $ret -ne 1 ]] &&  {
  83         echo "--DIAG: [${assertion}]
  84         svccfg add expected to return 1, got $ret"
  85 
  86         RESULT=$STF_FAIL
  87 }
  88 
  89 # Verify that nothing in stdout - this is a non-fatal error
  90 [[ -s $OUTFILE ]] &&  {
  91         echo "--DIAG: [${assertion}]
  92         stdout not expected, but got $(cat $OUTFILE)"
  93 
  94         RESULT=$STF_FAIL
  95 }
  96 
  97 # Verify that a message is sent to stderr
  98 if ! egrep -s "$SYNTAX_ERRMSG" $ERRFILE
  99 then
 100         echo "--DIAG: [${assertion}]
 101         Expected error message \"$SYNTAX_ERRMSG\"
 102         but got \"$(cat $ERRFILE)\""
 103 
 104         RESULT=$STF_FAIL
 105 fi
 106 
 107 rm -f $ERRFILE $OUTFILE
 108 
 109 exit $RESULT
 110