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_import_006
32 #
33 # DESCRIPTION:
34 # Calling the 'import' subcommand where the file is a invalid
35 # service manifest 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 manifest file with an
40 # error (i.e. an invalid service manifest). For comprehensive
41 # testing of import's handling of invalid service manifests run
42 # the DTD tests.
43 #
44 # end __stf_assertion__
45 ###############################################################################
46
47
48 # First STF library
49 . ${STF_TOOLS}/include/stf.kshlib
50
51 # Load GL library
52 . ${STF_SUITE}/include/gltest.kshlib
53
54 readonly ME=$(whence -p ${0})
55 readonly MYLOC=$(dirname ${ME})
56
57 # Initialize test result
58 typeset -i RESULT=$STF_PASS
59
60 function cleanup {
61
62 rm -f $OUTFILE $ERRFILE
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 assertion=svccfg_import_006
80 readonly registration_file=$MYLOC/import_006.xml
81
82 # extract and print assertion information from this source script.
83 extract_assertion_info $ME
84
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