1 #! /usr/bin/ksh
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 # DESCRIPTION :
30 # Generate a list of manifests and services that a validation
31 # can be run against to check for errors, and warnings.
32 # Any warning or failure from manifests on the system will
33 # need to be noted.
34 # While not really a testable noting of services without
35 # manifests and vice versa will be made as well as the
36 # counts of service/manifests. This will be so that stored
37 # test logs can be reviewed against newer test logs for
38 # changes.
39 #
40 # STRATEGY :
41 # A manifest must be un-modified from the base install of
42 # that manifest.
43 #
44 # - Get a list of all the services on the system
45 # - Get a list of all the manifests in the MANIFESTPATH
46 # - Associate each manifest with a service and add to the
47 # test list in the form of :
48 # manifest:service
49 # - For each service left over add to the test list in the
50 # form of :
51 # :service
52 # - For each manifest left over add to the test list in the
53 # form of :
54 # manifest:
55 #
56 # - for each entry in the test list validate each of the
57 # entries and report anomolies, in the manifest
58 # and/or the service.
59 #
60 # - for the single manifest or service entries make note
61 # of these for additional reference.
62 #
63
64 SERVICELIST=/var/tmp/scftest_servicelist.$$
65
66 #
67 # Get the list of services
68 #
69 cnt=1
70 rm -f $SERVICELIST
71 /bin/svcs -aH | grep -v legacy_run | grep -v refresh | awk '{print $3}' > $SERVICELIST 2>/dev/null
72
73 #
74 # Get the list of manifesets and associate them with a known
75 # service, removing the service from the service list, and
76 # adding the manfiest:service to the test list
77 #
78 # For any manifest that doesn't map to a know service just add
79 # the manifest to the test list for just manifest validation.
80 #
81 for MANIFESTDIR in `echo $MANIFESTPATH | sed -e 's/:/ /'`
82 do
83 for MANIFESTFILE in `find $MANIFESTDIR -type f`
84 do
85 MYFMRI=`svccfg inventory $MANIFESTFILE`
86 if [ $? -eq 0 ]; then
87 TESTARGS="$MANIFESTFILE"
88 MYFMRI=`echo $MYFMRI | \
89 awk '{for (i = 1; i < NF; i++) print $i}'`
90 for INST in $MYFMRI
91 do
92 grep -w $INST $SERVICELIST > /dev/null 2>&1
93 if [ $? -eq 0 ]; then
94 TESTARGS="$TESTARGS $INST"
95 grep -vw $INST $SERVICELIST > \
96 ${SERVICELIST}.tmp
97 mv ${SERVICELIST}.tmp $SERVICELIST
98 fi
99 done
100 eval stf_addassert -u root -t 'test_${cnt}' \
101 -c 'runtest $TESTARGS'
102 fi
103 (( cnt = $cnt + 1 ))
104 done
105 done
106
107
108 #
109 # Add a test for each of the services that do not have a
110 # known maniftest location.
111 #
112 exec 3<${SERVICELIST}
113 while read -u3 line
114 do
115 eval stf_addassert -u root -t 'test_${cnt}' -c 'runtest $line'
116 (( cnt = $cnt + 1 ))
117 done
118
119 rm -f $SERVICELIST