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 #
25 # Copyright 2008 Sun Microsystems, Inc. All rights reserved.
26 # Use is subject to license terms.
27 #
28
29 ###############################################################################
30 # start __stf_assertion__
31 #
32 # ASSERTION: svcadm_disable_006
33 #
34 # DESCRIPTION:
35 # svcadm disable <invalid-fmri> should fail with exit 1
36 # svcadm disable <invalid name> should fail with exit 1
37 # svcadm -v disable <invalid-fmri> should fail with exit 1
38 # svcadm -v disable <invalid-name> should fail with exit 1
39 # STRATEGY:
40 # - Call svcadm disable <invalid-fmri> and make sure it fails with
41 # exit 1.
42 # - Call svcadm -v disable <invalid-fmri> and make sure should fail
43 # with exit 1.
44 # - call svcadm [-v] disable <invalid-name> and make sure it fails
45 # with exit 1.
46 #
47 # COMMANDS: svcadm(1)
48 #
49 # end __stf_assertion__
50 ################################################################################
51
52 # First load up definitions of STF result variables like STF_PASS etc.
53 . ${STF_TOOLS}/include/stf.kshlib
54
55 # Load up definitions of shell functionality common to all smf sub-suites.
56 . ${STF_SUITE}/include/gltest.kshlib
57
58 # Define Variables
59 readonly assertion=svcadm_disable_006
60 readonly invalid_fmri="foo$$"
61 readonly invalid_name=100
62 readonly ME=$(whence -p ${0})
63 readonly MYLOC=$(dirname ${ME})
64
65 # gltest.kshlib functions to extract and print assertion information
66 # from this source script.
67 extract_assertion_info $ME
68
69 # Initialize test result to pass.
70 typeset -i RESULT=${STF_UNRESOLVED}
71
72 # Exit code for individual commands.
73 typeset -i tmp_rc=0
74
75 # Make sure we run as root
76 if ! /usr/bin/id | grep "uid=0(root)" > /dev/null 2>&1
77 then
78 echo "--DIAG: [$assertion]
79 This test must be run from root."
80 print_result $RESULT
81 exit $RESULT
82 fi
83
84
85 # Execute environmental sanity checks.
86 check_gl_env
87 tmp_rc=$?
88 if [[ $tmp_rc -ne 0 ]]
89 then
90 echo "--DIAG: [$assertion]
91 Invalid smf environment, quitting."
92 print_result $RESULT
93 exit $RESULT
94 fi
95
96 echo "--INFO: [${assertion}]
97 Call svcadm disable $invalid_fmri"
98
99 svcadm disable $invalid_fmri >/dev/null 2>&1
100 ret=$?
101 if [ $ret -ne 1 ]; then
102 RESULT=$(update_result $STF_FAIL $RESULT)
103 echo "--DIAG: [$assertion]
104 EXPECTED: svcadm disable $invalid_fmri should exit 1
105 ACTUAL: svcadm disable $invalid_fmri exits with status $ret"
106 print_result $RESULT
107 exit $RESULT
108 fi
109
110 echo "--INFO: [${assertion}]
111 Call svcadm -v disable $invalid_fmri"
112
113 svcadm -v disable $invalid_fmri >/dev/null 2>&1
114 ret=$?
115 if [ $ret -ne 1 ]; then
116 RESULT=$(update_result $STF_FAIL $RESULT)
117 echo "--DIAG: [$assertion]
118 EXPECTED: svcadm -v disable $invalid_fmri should exit 1
119 ACTUAL: svcadm -v disable $invalid_fmri exits with status $ret"
120 print_result $RESULT
121 exit $RESULT
122 fi
123
124 echo "--INFO: [${assertion}]
125 Call svcadm -v disable $invalid_name"
126
127 svcadm -v disable $invalid_name >/dev/null 2>&1
128 ret=$?
129 if [ $ret -ne 1 ]; then
130 RESULT=$(update_result $STF_FAIL $RESULT)
131 echo "--DIAG: [$assertion]
132 EXPECTED: svcadm -v disable $invalid_name should exit 1
133 ACTUAL: svcadm -v disable $invalid_name exits with status $ret"
134 print_result $RESULT
135 exit $RESULT
136 fi
137
138 echo "--INFO: [${assertion}]
139 Call svcadm disable $invalid_name"
140
141 svcadm disable $invalid_name >/dev/null 2>&1
142 ret=$?
143 if [ $ret -ne 1 ]; then
144 RESULT=$(update_result $STF_FAIL $RESULT)
145 echo "--DIAG: [$assertion]
146 EXPECTED: svcadm disable $invalid_name should exit 1
147 ACTUAL: svcadm disable $invalid_name exits with status $ret"
148 print_result $RESULT
149 exit $RESULT
150 fi
151
152 RESULT=$STF_PASS
153 print_result $RESULT
154 exit $RESULT