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 # First STF library
29 . ${STF_TOOLS}/include/stf.kshlib
30
31 #
32 # run svccfg validate against the service or manifest and check for
33 # failure or any stderr output that would indicate a problem.
34 # If there are no problems report pass, otherwise journal the problem
35 # with the stderr and stdout.
36 #
37 function validate {
38 siorm=$1
39 item=$2
40
41 echo "--INFO : Validating the $siorm $item"
42 svccfg validate $item > $outfile 2> $errfile
43 if [ $? -ne 0 -o `wc -l $errfile | awk '{print $1}'` -gt 0 ]; then
44 result=$STF_FAIL
45
46 echo "--DIAG : The validation failed with the following output"
47 echo "--DIAG : -------- stderr "
48 cat $errfile
49 echo "--DIAG : -------- stdout "
50 cat $outfile
51 else
52 echo "--INFO : $item passed validation"
53 fi
54 }
55
56 #
57 # Dump the test information into the journal along with a list
58 # of the items to be tested.
59 #
60 echo "--INFO: Validating the following items with svccfg validate"
61 echo "--INFO: Any validation failures should be considered a bug"
62 echo "--INFO: against the manifest or service in question."
63 for i in $@
64 do
65 echo " $i"
66 done
67 echo "------------------------------------------------"
68
69
70 #
71 # Test the validity of each of the command line arguments, whether
72 # it's a manifest or service.
73 #
74 result=$STF_PASS
75 for i in $@
76 do
77 echo $i | grep "^/" > /dev/null 2>&1
78 if [ $? -eq 0 ]; then
79 validate manifest $i
80 else
81 validate service $i
82 fi
83 done
84
85 exit $result