[Pkg-shadow-commits] r1686 - in debian/trunk/tests: . common

nekral-guest at alioth.debian.org nekral-guest at alioth.debian.org
Sun Jan 6 19:49:25 UTC 2008


Author: nekral-guest
Date: 2008-01-06 19:49:24 +0000 (Sun, 06 Jan 2008)
New Revision: 1686

Added:
   debian/trunk/tests/common/
   debian/trunk/tests/common/config.sh
   debian/trunk/tests/common/log.sh
Log:
Add helpers for an updated test infrastructure (handling of the chroot's
configuration).


Added: debian/trunk/tests/common/config.sh
===================================================================
--- debian/trunk/tests/common/config.sh	                        (rev 0)
+++ debian/trunk/tests/common/config.sh	2008-01-06 19:49:24 UTC (rev 1686)
@@ -0,0 +1,48 @@
+# Generic functions to save, change, and restore configuration files
+
+set -e
+
+
+# Save the configuration files in tmp.
+save_config ()
+{
+	[ ! -d tmp ] && mkdir tmp
+	find config -depth -type f | sed -e 's/config\///' |
+	while read file
+	do
+		mkdir -p "tmp/$(dirname "$file")"
+		[ -f "/$file" ] && cp -dp "/$file" "tmp/$file"
+	done
+}
+
+# Copy the config files from config to the system
+change_config ()
+{
+	find config -depth -type f | sed -e 's/config\///' |
+	while read file
+	do
+		cp -f "config/$file" "/$file"
+	done
+}
+
+# Restored the config files in the system.
+# The config files must be saved before with save_config ().
+restore_config ()
+{
+	find config -depth -type f | sed -e 's/config\///' |
+	while read file
+	do
+		[ -f "tmp/$file" ] && \
+			cp -dp "tmp/$file" "/$file" && \
+			rm "tmp/$file"
+		d="$(dirname "tmp/$file")"
+		while [ -n "$d" ] && [ "$d" != "." ]
+		do
+			rmdir "$d" 2>/dev/null || true
+			d="$(dirname "$d")"
+		done
+	done
+
+	rmdir tmp 2>/dev/null || true
+}
+

Added: debian/trunk/tests/common/log.sh
===================================================================
--- debian/trunk/tests/common/log.sh	                        (rev 0)
+++ debian/trunk/tests/common/log.sh	2008-01-06 19:49:24 UTC (rev 1686)
@@ -0,0 +1,46 @@
+# Helpers to log messages / status
+
+log_start ()
+{
+	test="$1"
+	rational="$2"
+	cat << EOF
+
+###############################################################################
+#
+# Test: $test
+#
+###############################################################################
+#
+# Rational: $rational
+#
+###############################################################################
+EOF
+}
+
+log_end ()
+{
+	test="$1"
+	cat << EOF
+###############################################################################
+#
+# End of test $test
+#
+###############################################################################
+
+EOF
+}
+
+log_status ()
+{
+	test="$1"
+	status="$2"
+	cat << EOF
+###############################################################################
+#
+# Status of test $test: $status
+#
+###############################################################################
+EOF
+}
+




More information about the Pkg-shadow-commits mailing list