2 # Common test suite definitions, declarations, and functions
9 : ${insserv:=${PWD}/insserv}
10 : ${tmpdir:=${PWD}/root}
11 : ${initddir:=${tmpdir}/etc/init.d}
12 : ${insconf:=${tmpdir}/etc/insserv.conf}
13 : ${overridedir:=${tmpdir}/etc/insserv/override}
18 declare -i checkfailed=0
19 declare -i testcount=0
20 declare -i testfailed=0
23 if test 0 -ne $retval ; then
24 echo "error: $testcount test executed, $checkfailed fatal tests failed, $testfailed nonfatal test failed."
26 echo "success: $testcount test executed, $testfailed nonfatal tests failed."
31 trap 'finish_test' EXIT
35 if test -n "${issuse}" ; then
39 level=(${level[@]/%s/S})
40 level=(${level[@]/#/rc})
41 level=(${level[@]/rc[bB]*/boot})
42 printf "${initddir}/%s.d\n" ${level[@]}
46 pushd $initddir/ &> /dev/null
51 cat <<-'EOF' > $insconf
52 $local_fs boot.localfs +boot.crypto
54 $named +named +dnsmasq +lwresd $network
55 $remote_fs $local_fs +nfs +smbfs
59 <interactive> boot.crypto boot.clock boot.localfs boot.rootfsck apache apache2 kdump ntp
64 printf "${initddir}/../rc%s.d\n" ${1+"$@"}
68 pushd $initddir/../ &> /dev/null
72 cat <<-'EOF' > $insconf
73 $local_fs +mountall +umountfs
74 $network +networking +ifupdown
75 $named +named +dnsmasq +lwresd +bind9 $network
76 $remote_fs $local_fs +mountnfs +mountnfs-bootclean +umountnfs +sendsigs
77 $syslog +syslog +sysklogd
80 <interactive> udev mountdevsubfs checkroot checkfs console-screen
83 chmod u+w,a+r $insconf
87 script=$(printf "${initddir}/%s\n" ${1+"$@"})
88 $insserv $debug -c $insconf -p $initddir -o $overridedir $script
93 script=$(printf "${initddir}/%s\n" ${1+"$@"})
94 $insserv $debug -c $insconf -p $initddir -o $overridedir -r $script
108 eval orgwords=(${1// /\\\\ }) ; shift
109 eval locwords=(${1// /\\\\ }) ; shift
115 for l in "${locwords[@]}" ; do
116 if test "$l" = ".." ; then
119 elif test $deep -gt 0 ; then
120 while ((deep-- > 0)) ; do
121 unset locwords[$((relp+deep))]
122 (((relp-1)-deep < 0)) || unset locwords[$(((relp-1)-deep))]
128 locwords=(${locwords[@]})
132 for p in "${orgwords[@]}" ; do
133 if test "$p" = ".." ; then
136 elif test $deep -gt 0 ; then
137 while ((deep-- > 0)) ; do
138 unset orgwords[$((relp+deep))]
139 (((relp-1)-deep < 0)) || unset orgwords[$(((relp-1)-deep))]
145 orgwords=(${orgwords[@]})
149 for p in "${orgwords[@]}" ; do
150 eval l="\${locwords[$((deep++))]}"
151 if test "$l" != "$p" -o $relp -ne 0 ; then
154 test -n "$l" || continue
155 if test $relp -eq 1 ; then
164 if test $deep -lt ${#locwords[@]} ; then
166 while test $relp -lt $deep; do
167 unset locwords[$((relp++))]
169 while test ${#locwords[@]} -gt 0 ; do
171 unset locwords[$((relp++))]
180 testcount=$(expr $testcount + 1)
186 checkfailed=$(expr $checkfailed + 1)
193 testfailed=$(expr $testfailed + 1)
199 local script=${initddir}/$scriptname
201 chmod u+w,a+rx $script
207 addscript $scriptname
208 insserv_reg $scriptname
213 local rcdpath=$(runlevel_path $1); shift
214 local script=$1; shift
216 test -L ${rcdpath}/[KS][0-9][0-9]$script || ret=1
221 check_script_present ()
223 local runlevel=$1; shift
224 local script=$1; shift
225 present_ok $runlevel $script && return 0
226 error "script $script not present in runlevel $runlevel"
229 test_script_present ()
231 local runlevel=$1; shift
232 local script=$1; shift
233 present_ok $runlevel $script && return 0
234 warning "script $script not present in runlevel $runlevel"
237 check_script_not_present ()
239 local runlevel=$1; shift
240 local script=$1; shift
241 if present_ok $runlevel $script ; then
242 error "script $script present in runlevel $runlevel"
247 test_script_not_present ()
249 local runlevel=$1; shift
250 local script=$1; shift
251 if present_ok $runlevel $script ; then
252 warning "script $script present in runlevel $runlevel"
259 local rcdpath=$(runlevel_path $1); shift
260 local script1=$1; shift
261 local script2=$1; shift
262 local ret=0 scr order=""
263 pushd $rcdpath &> /dev/null
264 if test -n "${issuse}" ; then
265 for scr in S[0-9][0-9]* ; do
266 test -e "${scr}" || continue
267 test -L "${scr}" || continue
268 case "${scr#S[0-9][0-9]}" in
269 ${script1}) order="${order:+$order }${script1}" ;;
270 ${script2}) order="${order:+$order }${script2}" ;;
274 for scr in [SK][0-9][0-9]* ; do
275 test -e "${scr}" || continue
276 test -L "${scr}" || continue
277 case "${scr#[SK][0-9][0-9]}" in
278 ${script1}) order="${order:+$order }${script1}" ;;
279 ${script2}) order="${order:+$order }${script2}" ;;
284 test "$order" = "$script1 $script2" || ret=1
295 order_ok ${1+"$@"} || error "incorrect $runlevel sequence $script1 not before $script2" || true
304 order_ok ${1+"$@"} || warning "incorrect $runlevel sequence $script1 not before $script2" || true