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: methods_001
32 # DESCRIPTION:
33 # If an enabled service with no dependencies is registered with the
34 # repository then it will be started up, and will reach the online
35 # state. Becasue it is registered as an enabled service it will go
36 # online without any user interaction once registered
37 # The test is considered to have passed if the service reached the
38 # online state.
39 #
40 # end __stf_assertion__
41 #
42
43 . ${STF_TOOLS}/include/stf.kshlib
44 . ${STF_SUITE}/include/gltest.kshlib
45 . ${STF_SUITE}/include/svc.startd_config.kshlib
46 . ${STF_SUITE}/tests/svc.startd/include/svc.startd_common.kshlib
47
48 typeset service_setup=0
49
50 function cleanup {
51 common_cleanup
52 return $?
53 }
54
55 trap cleanup 0 1 2 15
56
57 readonly ME=$(whence -p ${0})
58 readonly MYLOC=$(dirname ${ME})
59
60 DATA=$MYLOC
61
62 readonly registration_template=$DATA/service_001.xml
63
64 extract_assertion_info $ME
65
66 # make sure that the svc.startd is running
67 verify_daemon
68 if [ $? -ne 0 ]; then
69 print -- "--DIAG: $assertion: svc.startd is not executing. Cannot "
70 print -- " continue"
71 exit $STF_UNRESOLVED
72 fi
73
74 # Make sure the environment is clean - the test service isn't running
75 print -- "--INFO: Cleanup any old $test_FMRI state"
76 service_cleanup $test_service
77 if [ $? -ne 0 ]; then
78 print -- "--DIAG: $assertion: cleanup of a previous instance failed"
79 exit $STF_UNRESOLVED
80 fi
81
82 print -- "--INFO: generating manifest for importation into repository"
83 manifest_generate $registration_template \
84 TEST_SERVICE=$test_service \
85 TEST_INSTANCE=$test_instance \
86 SERVICE_APP=$service_app \
87 LOGFILE=$service_log \
88 STATEFILE=$service_state > $registration_file
89
90 print -- "--INFO: Importing service into repository"
91 manifest_purgemd5 $registration_file
92 svccfg -v import $registration_file >$svccfg_errfile 2>&1
93
94 if [ $? -ne 0 ]; then
95 print -- "--DIAG: $assertion: Unable to import the service $test_FMRI"
96 print -- " error messages from svccfg: \"$(cat $svccfg_errfile)\""
97 exit $STF_UNRESOLVED
98 fi
99 service_setup=1
100
101 print -- "--INFO: Wait for $test_FMRI to come online"
102 service_wait_state $test_FMRI online
103 if [ $? -ne 0 ]; then
104 print -- "--DIAG: $assertion: Service $test_FMRI did not go online"
105 exit $STF_FAIL
106 fi
107
108 print -- "--INFO: Cleaning up service"
109 cleanup
110
111 exit $STF_PASS