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