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 . ${STF_TOOLS}/include/stf.kshlib
29
30 typeset test_subdir=${STF_SUITE}/${STF_EXEC}/${1}
31 typeset service=${2}
32
33 typeset -i test_result=0
34
35 necho() {
36 /usr/ucb/echo -n "$@ "
37 }
38
39 props() {
40 $SVCCFG -v <<EOF
41 select $service
42 listprop
43 EOF
44 }
45
46 delete() {
47 $SVCCFG -v delete -f $service 2>&1
48 if [[ $? -ne 0 ]]; then
49 echo "Couldn't delete $service, do a make clean" >&2
50 exit 1
51 fi
52 }
53
54 check() {
55 props $service >$newpropout
56 [[ $? -ne 0 ]] && exit $STF_FAIL
57
58 diff -u $propout $newpropout >/dev/null 2>&1
59 if [[ $? -ne 0 ]]; then
60 echo "$SVCPROP of $service ($newpropout) differs from expected ($propout)"
61 diff -u $propout $newpropout
62 exit $STF_FAIL
63 fi
64
65 rm $newpropout
66 return 0
67 }
68
69 $SVCCFG -v import ${STF_SUITE}/${STF_EXEC}/standard.xml >/dev/null 2>&1
70
71 echo "$test_subdir/$service ["
72 xmlin="$test_subdir/$service.in.xml"
73 xmlout="$TMP_DIR/$service.out.xml"
74 newxmlout="$TMP_DIR/$service.out.xml"
75 propout="$TMP_DIR/$service.out.prop"
76 newpropout="$TMP_DIR/$service.out.prop"
77 SUBDIR=${test_subdir##*/}
78
79 $SVCCFG -v delete -f $service >/dev/null 2>&1
80
81 echo import
82 $SVCCFG -v import $xmlin 2>&1
83 ret=$?
84 if [[ $ret -ne 0 ]]; then
85 if [[ "$SUBDIR" = "invalid" ]]; then
86 if [[ $ret -eq 139 ]]; then
87 exit $STF_FAIL
88 else
89 exit $STF_PASS
90 fi
91 else
92 exit $STF_FAIL
93 fi
94 else
95 [[ "$SUBDIR" = "invalid" ]] && exit $STF_FAIL
96 fi
97
98 echo export
99 $SVCCFG -v export $service >$newxmlout
100 [[ $? -ne 0 ]] && exit $STF_FAIL
101
102 if [[ -n "$BUILD_EXP_OUTPUTS" ]]; then
103 mv $newxmlout $xmlout
104 exit $RESULT
105 fi
106
107 echo check
108 check
109 echo "check - done"
110
111 diff -u $xmlout $newxmlout >/dev/null 2>&1
112 if [[ $? -ne 0 ]]; then
113 echo "XML export of $service ($newxmlout) differs from expected ($xmlout)"
114 diff -u $xmlout $newxmlout
115 exit $STF_FAIL
116 fi
117
118 echo delete
119 delete
120
121 echo re-import
122 $SVCCFG -v import $newxmlout 2>&1
123 [[ $? -ne 0 ]] && exit $STF_FAIL || rm $newxmlout
124
125 echo re-check
126 check
127
128 echo delete
129 delete
130 exit $RESULT