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_apply_007
  32 #
  33 # DESCRIPTION:
  34 #       Calling the 'apply' subcommand where the file is a invalid
  35 #       service profile will result in a diagnostic message
  36 #       displayed on stderr.  The exit status will be 1.
  37 # 
  38 # STRATEGY:
  39 #       This is a simple test passing to import a .xml file with an
  40 #       error (i.e. an invalid service profile).  
  41 #
  42 # end __stf_assertion__
  43 ###############################################################################
  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 # Load svc.startd library for manifest_generate
  53 . ${STF_SUITE}/include/svc.startd_config.kshlib
  54 
  55 readonly ME=$(whence -p ${0})
  56 readonly MYLOC=$(dirname ${ME})
  57 
  58 # Initialize test result 
  59 typeset -i RESULT=$STF_PASS
  60 
  61 function cleanup {
  62         
  63         rm -f $OUTFILE $ERRFILE 
  64 
  65         exit $RESULT
  66 }
  67 
  68 trap cleanup 0 1 2 15
  69 
  70 # make sure that the environment is sane - svc.configd  is up and running
  71 check_gl_env
  72 [[ $? -ne 0 ]] && {
  73         echo "--DIAG: 
  74                 Invalid test environment - svc.configd  not available"
  75 
  76         RESULT=$STF_UNRESOLVED
  77         exit $RESULT
  78 }
  79 
  80 assertion=svccfg_apply_007
  81 readonly registration_file=$MYLOC/apply_007_profile.xml
  82 
  83 # extract and print assertion information from this source script.
  84 extract_assertion_info $ME
  85 
  86 svccfg import $registration_file > $OUTFILE 2>$ERRFILE
  87 ret=$?
  88 [[ $ret -ne 1 ]] &&  {
  89         echo "--DIAG: [${assertion}]
  90         svccfg import expected to return 1, got $ret"
  91 
  92         RESULT=$STF_FAIL
  93 }
  94 
  95 # Verify that nothing in stdout - this is a non-fatal error
  96 [[ -s $OUTFILE ]] &&  {
  97         echo "--DIAG: [${assertion}]
  98         stdout not expected, but got $(cat $OUTFILE)"
  99 
 100         RESULT=$STF_FAIL
 101 }
 102 
 103 # Verify that a message is sent to stderr
 104 if ! egrep -s "$UNPARSEABLE_ERRMSG" $ERRFILE
 105 then
 106         echo "--DIAG: [${assertion}]
 107         Expected error message \"$UNPARSEABLE_ERRMSG\"
 108         but got \"$(cat $ERRFILE)\""
 109 
 110         RESULT=$STF_FAIL
 111 fi
 112 
 113 
 114 rm -f $ERRFILE $OUTFILE
 115 
 116 exit $RESULT
 117