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_listprop_006
32 #
33 # DESCRIPTION:
34 # The 'listprop' subcommand expects at most one argument,
35 # a glob pattern. If more than one argument is provided
36 # to 'listprop' than a diagnostic message will be sent to
37 # stderr and the exit status of 1 is returned.
38 #
39 # end __stf_assertion__
40 ###############################################################################
41
42
43 # First STF library
44 . ${STF_TOOLS}/include/stf.kshlib
45
46 # Load GL library
47 . ${STF_SUITE}/include/gltest.kshlib
48
49
50 readonly ME=$(whence -p ${0})
51 readonly MYLOC=$(dirname ${ME})
52
53 # Initialize test result
54 typeset -i RESULT=$STF_PASS
55
56
57 function cleanup {
58
59 # Note that $TEST_SERVICE may or may not exist so don't check
60 # results. Just make sure the service is gone.
61 service_delete $TEST_SERVICE
62
63 service_exists ${TEST_SERVICE}
64 [[ $? -eq 0 ]] && {
65 echo "--DIAG: [${assertion}, cleanup]
66 service ${TEST_SERVICE} should not exist in
67 repository after being deleted, but does"
68
69 RESULT=$(update_result $STF_UNRESOLVED $RESULT)
70 }
71
72 rm -f $OUTFILE $ERRFILE $CMDFILE
73
74 exit $RESULT
75 }
76
77 trap cleanup 0 1 2 15
78
79 # make sure that the environment is sane - svc.configd is up and running
80 check_gl_env
81 [[ $? -ne 0 ]] && {
82 echo "--DIAG:
83 Invalid test environment - svc.configd not available"
84
85 RESULT=$STF_UNRESOLVED
86 exit $RESULT
87 }
88
89 # extract and print assertion information from this source script.
90 extract_assertion_info $ME
91
92 assertion=svccfg_listprop_006
93
94 cat << EOF >$CMDFILE
95 add $TEST_SERVICE
96 select $TEST_SERVICE
97 addpg ${TEST_PROPERTY} framework
98 EOF
99
100 svccfg -f $CMDFILE > $OUTFILE 2>$ERRFILE
101 ret=$?
102 [[ $ret -ne 0 ]] && {
103 echo "--DIAG: [${assertion}]
104 svccfg expected to return 0, got $ret
105 error output is $(cat $ERRFILE)"
106
107 RESULT=$(update_result $STF_UNRESOLVED $RESULT)
108 exit $RESULT
109 }
110
111 cat << EOF >$CMDFILE
112 select $TEST_SERVICE
113 listprop * extraoption_1 extraoption_2 extraoption_3
114 EOF
115
116 svccfg -f $CMDFILE > $OUTFILE 2>$ERRFILE
117 ret=$?
118
119 # Verify that the return value is as expected - non-fatal error
120 [[ $ret -ne 1 ]] && {
121 echo "--DIAG: [${assertion}]
122 svccfg add expected to return 1, got $ret"
123
124 RESULT=$STF_FAIL
125 }
126
127 # Verify that nothing in stdout - non-fatal error
128 [[ -s $OUTFILE ]] && {
129 echo "--DIAG: [${assertion}]
130 stdout not expected, but got $(cat $OUTFILE)"
131
132 RESULT=$STF_FAIL
133 }
134
135
136 # Verify that message in stderr - non-fatal error
137 if ! egrep -s "$SYNTAX_ERRMSG" $ERRFILE
138 then
139 echo "--DIAG: [${assertion}]
140 Expected error message \"$SYNTAX_ERRMSG\"
141 but got \"$(cat $ERRFILE)\""
142
143 RESULT=$STF_FAIL
144 fi
145
146 rm -f $ERRFILE $OUTFILE $CMDFILE
147
148 print_result $RESULT
149
150 exit $RESULT