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_delpg_003
32 #
33 # DESCRIPTION:
34 # If an invalid name is given to the 'delpg' subcommand then
35 # a diagnostic message sent to stderr and an exit status of 1.
36 #
37 # end __stf_assertion__
38 ###############################################################################
39
40
41 # First STF library
42 . ${STF_TOOLS}/include/stf.kshlib
43
44 # Load GL library
45 . ${STF_SUITE}/include/gltest.kshlib
46
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
55 function cleanup {
56
57 # Note that $TEST_SERVICE may or may not exist so don't check
58 # results. Just make sure the service is gone.
59 service_delete $TEST_SERVICE > /dev/null 2>&1
60
61 service_exists ${TEST_SERVICE}
62 [[ $? -eq 0 ]] && {
63 echo "--DIAG: [${assertion}, cleanup]
64 service ${TEST_SERVICE} should not exist in
65 repository after being deleted, but does"
66
67 RESULT=$(update_result $STF_UNRESOLVED $RESULT)
68 }
69
70 rm -f $OUTFILE $ERRFILE $CMDFILE
71
72 exit $RESULT
73 }
74
75 trap cleanup 0 1 2 15
76
77 # make sure that the environment is sane - svc.configd is up and running
78 check_gl_env
79 [[ $? -ne 0 ]] && {
80 echo "--DIAG:
81 Invalid test environment - svc.configd is not available"
82
83 RESULT=$STF_UNRESOLVED
84 exit $RESULT
85 }
86
87 # extract and print assertion information from this source script.
88 extract_assertion_info $ME
89
90 assertion=svccfg_delpg_003
91
92 # Before starting make sure that the test service doesn't already exist.
93 # If it does then consider it a fatal error.
94 service_exists $TEST_SERVICE
95 [[ $? -eq 0 ]] && {
96 echo "--DIAG: [${assertion}]
97 service $TEST_SERVICE should not exist in
98 repository but does"
99
100 RESULT=$(update_result $STF_UNRESOLVED $RESULT)
101 exit $RESULT
102 }
103
104
105 #
106 # Add the service. If this fails consider it a fatal error
107 #
108 svccfg add $TEST_SERVICE > $OUTFILE 2>$ERRFILE
109 ret=$?
110 [[ $ret -ne 0 ]] && {
111 echo "--DIAG: [${assertion}]
112 error adding service $TEST_SERVICE needed for test
113 error output is $(cat $ERRFILE)"
114
115 RESULT=$(update_result $STF_UNRESOLVED $RESULT)
116 exit $RESULT
117 }
118
119 # Make sure the service is there
120 service_exists $TEST_SERVICE
121 [[ $? -ne 0 ]] && {
122 echo "--DIAG: [${assertion}]
123 service $TEST_SERVICE should exist in
124 repository after being added, but does not"
125
126 RESULT=$(update_result $STF_UNRESOLVED $RESULT)
127 exit $RESULT
128 }
129
130
131 #
132 # Attempt to delete an invalid property group to the service
133 #
134 cat <<EOF>$CMDFILE
135 select ${TEST_SERVICE}
136 delpg ${INVALID_NAME}
137 EOF
138
139 svccfg -f $CMDFILE > $OUTFILE 2>$ERRFILE
140 ret=$?
141
142 # Verify that the return value is as expected - non-fatal error
143 [[ $ret -ne 1 ]] && {
144 echo "--DIAG: [${assertion}]
145 svccfg expected to return 1, got $ret"
146 RESULT=$STF_FAIL
147 }
148
149 # Verify that nothing in stdout - non-fatal error
150 [[ -s $OUTFILE ]] && {
151 echo "--DIAG: [${assertion}]
152 stdout not expected, but got $(cat $OUTFILE)"
153
154 RESULT=$STF_FAIL
155 }
156
157 # Verify message to stderr - non-fatal error
158 if ! egrep -s "$INVALID_PROPGRP_ERRMSG" $ERRFILE
159 then
160 echo "--DIAG: [${assertion}]
161 Expected error message \"$INVALID_PROPGRP_ERRMSG\"
162 but got \"$(cat $ERRFILE)\""
163
164 RESULT=$STF_FAIL
165 fi
166
167 rm -f $ERRFILE $OUTFILE $CMDFILE
168
169 exit $RESULT