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_degraded_003
33 #
34 # DESCRIPTION:
35 # svcadm mark degraded <invalid-fmri> should fail with exit 1
36 # svcadm mark degraded <invalid name> should fail with exit 1
37 # svcadm -v mark degraded <invalid-fmri> should fail with exit 1
38 # svcadm -v mark degraded <invalid-name> should fail with exit 1
39 # STRATEGY:
40 # - Call svcadm mark degraded <invalid-fmri> and make sure it
41 # fails with exit 1.
42 # - Call svcadm -v mark degraded <invalid-fmri> and make sure
43 # should fail with exit 1.
44 # - call svcadm [-v] mark degraded <invalid-name> and make sure it
45 # fails 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_degraded_003
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 RESULT=$(update_result $STF_UNRESOLVED $RESULT)
79 echo "--DIAG: [$assertion]
80 This test must be run from root."
81 print_result $RESULT
82 exit $RESULT
83 fi
84
85
86 # Execute environmental sanity checks.
87 check_gl_env
88 tmp_rc=$?
89 if [[ $tmp_rc -ne 0 ]]
90 then
91 echo "--DIAG: [$assertion]
92 Invalid smf environment, quitting."
93 print_result $RESULT
94 exit $RESULT
95 fi
96
97 echo "--INFO: [${assertion}]
98 Call svcadm mark degraded $invalid_fmri"
99
100 svcadm mark degraded $invalid_fmri >/dev/null 2>&1
101 ret=$?
102 if [ $ret -ne 1 ]; then
103 RESULT=$(update_result $STF_FAIL $RESULT)
104 echo "--DIAG: [$assertion]
105 EXPECTED: svcadm mark degraded $invalid_fmri should exit 1
106 ACTUAL: svcadm mark degraded $invalid_fmri exits with status $ret"
107 print_result $RESULT
108 exit $RESULT
109 fi
110
111 echo "--INFO: [${assertion}]
112 Call svcadm -v mark degraded $invalid_fmri"
113
114 svcadm -v mark degraded $invalid_fmri >/dev/null 2>&1
115 ret=$?
116 if [ $ret -ne 1 ]; then
117 RESULT=$(update_result $STF_FAIL $RESULT)
118 echo "--DIAG: [$assertion]
119 EXPECTED: svcadm -v mark degraded $invalid_fmri should exit 1
120 ACTUAL: svcadm -v mark degraded $invalid_fmri exits with status $ret"
121 print_result $RESULT
122 exit $RESULT
123 fi
124
125 echo "--INFO: [${assertion}]
126 Call svcadm -v mark degraded $invalid_name"
127
128 svcadm -v mark degraded $invalid_name >/dev/null 2>&1
129 ret=$?
130 if [ $ret -ne 1 ]; then
131 RESULT=$(update_result $STF_FAIL $RESULT)
132 echo "--DIAG: [$assertion]
133 EXPECTED: svcadm -v mark degraded $invalid_name should exit 1
134 ACTUAL: svcadm -v mark degraded $invalid_name exits with status $ret"
135 print_result $RESULT
136 exit $RESULT
137 fi
138
139 echo "--INFO: [${assertion}]
140 Call svcadm mark degraded $invalid_name"
141
142 svcadm mark degraded $invalid_name >/dev/null 2>&1
143 ret=$?
144 if [ $ret -ne 1 ]; then
145 RESULT=$(update_result $STF_FAIL $RESULT)
146 echo "--DIAG: [$assertion]
147 EXPECTED: svcadm mark degraded $invalid_name should exit 1
148 ACTUAL: svcadm mark degraded $invalid_name exits with status $ret"
149 print_result $RESULT
150 exit $RESULT
151 fi
152
153 RESULT=$STF_PASS
154 print_result $RESULT
155 exit $RESULT