[Initscripts-ng-commits] r593 - in /trunk/src/insserv/debian: changelog run-testsuite testsuite-common

pere at users.alioth.debian.org pere at users.alioth.debian.org
Fri Feb 8 10:50:49 UTC 2008


Author: pere
Date: Fri Feb  8 10:50:49 2008
New Revision: 593

URL: http://svn.debian.org/wsvn/initscripts-ng/?sc=1&rev=593
Log:
  * Update test suite to the one provided by Werner Fink.

Modified:
    trunk/src/insserv/debian/changelog
    trunk/src/insserv/debian/run-testsuite
    trunk/src/insserv/debian/testsuite-common

Modified: trunk/src/insserv/debian/changelog
URL: http://svn.debian.org/wsvn/initscripts-ng/trunk/src/insserv/debian/changelog?rev=593&op=diff
==============================================================================
--- trunk/src/insserv/debian/changelog (original)
+++ trunk/src/insserv/debian/changelog Fri Feb  8 10:50:49 2008
@@ -5,8 +5,6 @@
   * Added script debian/seq-changes from Frans Pop installed in
     /usr/share/insserv/ to extract the sequence changes done by
     insserv.
-  * Fix testsuite test that would incorrectly detect script names
-    matching a substring of other scripts names.
   * New testsuite check to detect incorrectly inserted stop symlinks
     when scripts with incorrect headers are encountered.
   * Removed override file for snmptrapfmt, as the package now include
@@ -17,6 +15,7 @@
     build.  Obsoletes setting the same flags in debian/rules.
   * New patch 50_sign_warning getting rid of some signed/unsigned
     compare issues.
+  * Update test suite to the one provided by Werner Fink.
 
  -- Petter Reinholdtsen <pere at debian.org>  Fri,  1 Feb 2008 19:45:46 +0100
 

Modified: trunk/src/insserv/debian/run-testsuite
URL: http://svn.debian.org/wsvn/initscripts-ng/trunk/src/insserv/debian/run-testsuite?rev=593&op=diff
==============================================================================
--- trunk/src/insserv/debian/run-testsuite (original)
+++ trunk/src/insserv/debian/run-testsuite Fri Feb  8 10:50:49 2008
@@ -28,6 +28,7 @@
 echo "info: test normal boot sequence scripts, and their order"
 echo
 
+set +C
 cat <<'EOF' > $insconf
 $local_fs       +mountall +umountfs
 $network        +networking +ifupdown
@@ -38,6 +39,7 @@
 $time           hwclock
 <interactive>   udev mountdevsubfs checkroot checkfs console-screen
 EOF
+set -C
 
 insertscript mountkernfs.sh <<EOF
 ### BEGIN INIT INFO
@@ -90,18 +92,6 @@
 # Required-Stop:     $local_fs
 # Default-Start:     S
 # Default-Stop:      0 6
-### END INIT INFO
-EOF
-
-insertscript checkroot.sh <<'EOF'
-### BEGIN INIT INFO
-# Provides:          checkroot
-# Required-Start:    mountdevsubfs
-# Required-Stop:
-# Should-Start:      keymap hwclockfirst
-# Should-stop:
-# Default-Start:     S
-# Default-Stop:
 ### END INIT INFO
 EOF
 
@@ -747,7 +737,8 @@
 rm -rf $initddir/*
 mkdir -p $initddir
 
-addscript script <<'EOF' || true
+list_rclinks
+insertscript script <<'EOF' || true
 ### BEGIN INIT INFO
 # Provides:          script
 # Required-Start:
@@ -756,31 +747,15 @@
 # Default-Stop:      0 1 6
 ### END INIT INFO
 EOF
-
-addscript nostopscript <<'EOF' || true
-### BEGIN INIT INFO
-# Provides:          nostopscript
-# Required-Start:
-# Required-Stop:
-# Default-Start:     2 3 4 5
-# Default-Stop:
-### END INIT INFO
-EOF
-
-# Problem is only triggered if there are start or stop symlinks for
-# the script present.
-for name in script nostopscript ; do
-    for runlevel in 2 3 4 5 ; do
-	mkdir -p $initddir/../rc$runlevel.d
-	ln -s ../init.d/script $initddir/../rc$runlevel.d/S02$name
-    done
-done
+list_rclinks
 
 check_script_present 2 script
 check_script_present 5 script
 check_script_not_present S script
-check_script_not_present 1 script
-check_script_not_present 1 nostopscript
+check_script_present 1 script
+
+rm $initddir/../rc0.d/K??script
+rm $initddir/../rc1.d/K??script
 
 # Update symlinks, see if it add stop symlinks
 insserv_reg .
@@ -790,6 +765,7 @@
 check_script_present 2 script
 check_script_present 5 script
 check_script_not_present S script
+${severity}_script_not_present 0 script
 ${severity}_script_not_present 1 script
 check_script_not_present 1 nostopscript
 

Modified: trunk/src/insserv/debian/testsuite-common
URL: http://svn.debian.org/wsvn/initscripts-ng/trunk/src/insserv/debian/testsuite-common?rev=593&op=diff
==============================================================================
--- trunk/src/insserv/debian/testsuite-common (original)
+++ trunk/src/insserv/debian/testsuite-common Fri Feb  8 10:50:49 2008
@@ -1,131 +1,193 @@
-#!/bin/sh
+#
+# Common test suite definitions, declarations, and functions
+#
+set -eC
 
-set -e
+: ${insserv:=${PWD}/insserv}
+: ${tmpdir:=${PWD}/root}
+: ${initddir:=${tmpdir}/etc/init.d}
+: ${insconf:=${tmpdir}/etc/insserv.conf}
+: ${overridedir:=${tmpdir}/etc/insserv/override}
+: ${issuse=""}
+: ${debug:=""}
 
-tmpdir=`pwd`/testdir
-initddir=$tmpdir/etc/init.d
+trap 'rm -rf ${tmpdir}' EXIT
+declare -i retval=0
 
-insserv=`pwd`/insserv
-# Relative to $tmpdir
-insconf=$tmpdir/etc/insserv.conf
-overridedir=$tmpdir/etc/insserv/override
+if test -n "${issuse}" ; then
+    runlevel_path ()
+    {
+	local rc=$1
+	case "$rc" in
+	[bB]*)	echo -n ${initddir}/boot.d/ ;;
+	*)	echo -n ${initddir}/rc${rc}.d/ ;;
+	esac
+    }
+    list_rclinks()
+    {
+	pushd $initddir/ &> /dev/null
+	echo ${initddir##*/}:
+	ls *
+	popd &> /dev/null
+    }
+else
+    runlevel_path ()
+    {
+	local runlevel=$1
+	echo -n ${initddir}/../rc${runlevel}.d/
+    }
+    list_rclinks()
+    {
+	pushd $initddir/../ &> /dev/null
+	ls *
+	popd &> /dev/null
+    }
+fi
 
-retval=0
+insserv_reg ()
+{
+    script=$(printf "${initddir}/%s\n" ${1+"$@"})
+    $insserv $debug -c $insconf -p $initddir -o $overridedir $script
+}
 
 mkdir -p $initddir
 
-#debug="-v"
+if test -n "${issuse}" ; then
+    cat <<-'EOF' > $insconf
+	$local_fs	boot.localfs +boot.crypto
+	$network	network
+	$named		+named +dnsmasq +lwresd $network
+	$remote_fs	$local_fs +nfs +smbfs
+	$syslog		syslog
+	$portmap	portmap
+	$time		boot.clock +ntp
+	<interactive>	boot.crypto boot.clock boot.localfs boot.rootfsck apache apache2 kdump ntp
+	EOF
+else
+    cat <<-'EOF' > $insconf
+	$local_fs	+mountall +umountfs
+	$network	+networking +ifupdown
+	$named		+named +dnsmasq +lwresd +bind9 $network
+	$remote_fs	$local_fs +mountnfs +mountnfs-bootclean +umountnfs +sendsigs
+	$syslog		+syslog +sysklogd
+	$portmap	portmap
+	$time		hwclock
+	<interactive>	udev mountdevsubfs checkroot checkfs console-screen
+	EOF
+fi
+chmod u+w,a+r $insconf
 
-# The specific test suites need to define runlevel_path(),
-# list_rclinks() and insserv_reg().
-
-error() {
+error ()
+{
     echo error: $@
     retval=1
 }
 
-warning() {
+warning ()
+{
     echo warning: $@
 }
 
-addscript() {
-    scriptname=$1
-    script=$initddir/$scriptname
+addscript ()
+{
+    local scriptname=$1
+    local script=${initddir}/$scriptname
     cat > $script
-    chmod a+rx $script
+    chmod u+w,a+rx $script
 }
 
-insertscript() {
-    scriptname=$1
-    addscript $scriptname
+insertscript ()
+{
+    local scriptname=$1
+    addscript   $scriptname
     insserv_reg $scriptname
 }
 
-present_ok() {
-    runlevel=$1
-    script=$2
-    present="$(echo $(cd $(runlevel_path $runlevel); ls ???$script 2>/dev/null) )"
-    if [ "$present" ] ; then
-	return 0
-    fi
-    return 1
+present_ok ()
+{
+    local runlevel=$1; shift
+    local script=$1;   shift
+    local ret=0
+    test -L $(runlevel_path $runlevel)/[KS][0-9][0-9]$script || ret=1
+    return $ret
 }
 
-check_script_present() {
-    runlevel=$1
-    script=$2
+check_script_present ()
+{
+    local runlevel=$1; shift
+    local script=$1;   shift
+    present_ok $runlevel $script && return 0
+    error "script $script not present in runlevel $runlevel"
+}
+
+test_script_present ()
+{
+    local runlevel=$1; shift
+    local script=$1;   shift
+    present_ok $runlevel $script && return 0
+    warning "script $script not present in runlevel $runlevel"
+}
+
+check_script_not_present ()
+{
+    local runlevel=$1; shift
+    local script=$1;   shift
     if present_ok $runlevel $script ; then
-	return 0
+	error "script $script present in runlevel $runlevel"
     fi
-    error "script $script not present in runlevel $runlevel"
     return 0
 }
 
-test_script_present() {
-    runlevel=$1
-    script=$2
+test_script_not_present ()
+{
+    local runlevel=$1; shift
+    local script=$1;   shift
     if present_ok $runlevel $script ; then
-	return 0
+	warning "script $script present in runlevel $runlevel"
     fi
-    warning "script $script not present in runlevel $runlevel"
     return 0
 }
 
-check_script_not_present() {
-    runlevel=$1
-    script=$2
-    if present_ok $runlevel $script ; then
-	error "script $script present in runlevel $runlevel"
-	return 0
-    fi
-    return 0;
-}
-
-test_script_not_present() {
-    runlevel=$1
-    script=$2
-    if present_ok $runlevel $script ; then
-	warning "script $script present in runlevel $runlevel"
-	return 0
-    fi
-    return 0;
-}
-
-order_ok() {
-    runlevel=$1
-    script1=$2
-    script2=$3
-    order="$(echo $(cd $(runlevel_path $runlevel); ls *$script1 *$script2 2>/dev/null | sed 's/[SK]..//') )"
-    if [ "$order" != "$script1 $script2" ] ; then
-	return 0
-    fi
-    return 1;
+order_ok ()
+{
+    local rcdpath=$(runlevel_path $1); shift
+    local script1=$1;  shift
+    local script2=$1;  shift
+    local ret=0 scr order=""
+    pushd $rcdpath &> /dev/null
+    for scr in [SK][0-9][0-9]${script1} [SK][0-9][0-9]${script2}; do
+	test -L "${scr}" || continue
+	order="${order:+$order }${scr#[SK][0-9][0-9]}"
+    done
+    popd &> /dev/null
+    test "$order" = "$script1 $script2" || ret=1
+    return $ret
 }
 
 # Fatal check
-check_order() {
-    if order_ok $@ ; then
-	error "incorrect $runlevel sequence $script1 not before $script2"
-    fi
+check_order ()
+{
+    local runlevel=$1
+    local script1=$2
+    local script2=$3
+    order_ok ${1+"$@"} && error   "incorrect $runlevel sequence $script1 not before $script2" || true
 }
 
 # Non-fatal check
-test_order() {
-    if order_ok $@ ; then
-	warning "incorrect $runlevel sequence $script1 not before $script2"
-    fi
+test_order ()
+{
+    local runlevel=$1
+    local script1=$2
+    local script2=$3
+    order_ok ${1+"$@"} && warning "incorrect $runlevel sequence $script1 not before $script2" || true
 }
 
-finish_test() {
-    if [ 0 != $retval ] ; then
-	echo "error: one or more test failed."
+finish_test ()
+{
+    if test 0 -ne $retval ; then
+        echo "error: one or more test failed."
     else
-	echo "success: no test failed."
+        echo "success: no test failed."
     fi
     exit $retval
 }
-
-on_exit() {
-    rm -rf $tmpdir
-}
-trap on_exit EXIT # Enable cleanup handler




More information about the Initscripts-ng-commits mailing list