summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorKarel Zak2007-01-04 14:23:48 +0100
committerKarel Zak2007-01-04 14:23:48 +0100
commite83446da1a3f626920d5e65d4f78651581765b61 (patch)
tree56880fa701f6f1e78bb65808f86f859f9bd93d84 /tests
parentmount: add simple (printf-like) debug routine and --debug option (diff)
downloadkernel-qcow2-util-linux-e83446da1a3f626920d5e65d4f78651581765b61.tar.gz
kernel-qcow2-util-linux-e83446da1a3f626920d5e65d4f78651581765b61.tar.xz
kernel-qcow2-util-linux-e83446da1a3f626920d5e65d4f78651581765b61.zip
tests: add basic infrastructure for regression tests
The patch adds tests/ directory with simple regression tests infrastructure. Also, it adds the "ts-mount-paths" test that testing if all defined paths (fstab, mtab, locks) are still same. Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am10
-rw-r--r--tests/README16
-rw-r--r--tests/commands.sh.in8
-rw-r--r--tests/expected/ts-mount-paths7
-rw-r--r--tests/functions.sh42
-rwxr-xr-xtests/run.sh25
-rwxr-xr-xtests/ts-mount-paths14
7 files changed, 122 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
new file mode 100644
index 000000000..65cd57a52
--- /dev/null
+++ b/tests/Makefile.am
@@ -0,0 +1,10 @@
+include $(top_srcdir)/config/include-Makefile.am
+
+EXTRA_DIST = commands.sh.in \
+ functions.sh \
+ ts-mount-paths \
+ expected/ts-mount-paths
+
+distclean-local:
+ rm -rf output diff
+
diff --git a/tests/README b/tests/README
new file mode 100644
index 000000000..bcade3d7a
--- /dev/null
+++ b/tests/README
@@ -0,0 +1,16 @@
+
+ util-linux regression tests
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ It's expected that for each invasive change or important bugfix you will
+ include a test to your patch.
+
+
+ Run all tests:
+
+ ./run.sh
+
+ Run one tests:
+
+ ./ts-<component_name>-<test_name>.sh
+
diff --git a/tests/commands.sh.in b/tests/commands.sh.in
new file mode 100644
index 000000000..ecdb9b948
--- /dev/null
+++ b/tests/commands.sh.in
@@ -0,0 +1,8 @@
+TOPDIR=@top_srcdir@
+TS_TOPDIR=$TOPDIR/tests
+
+# paths to commands
+TS_CMD_MOUNT=${TS_CMD_MOUNT:-"$TOPDIR/mount/mount"}
+TS_CMD_UMOUNT=${TS_CMD_MOUNT:-"$TOPDIR/mount/umount"}
+TS_CMD_SWAPON=${TS_CMD_MOUNT:-"$TOPDIR/mount/swapon"}
+TS_CMD_SWAPOFF=${TS_CMD_MOUNT:-"$TOPDIR/mount/swapoff"}
diff --git a/tests/expected/ts-mount-paths b/tests/expected/ts-mount-paths
new file mode 100644
index 000000000..d6f798aef
--- /dev/null
+++ b/tests/expected/ts-mount-paths
@@ -0,0 +1,7 @@
+DEBUG: fstab path: "/etc/fstab"
+DEBUG: lock path: "/etc/mtab~"
+DEBUG: temp path: "/etc/mtab.tmp"
+DEBUG: spec: "/dev/dummy"
+DEBUG: node: "/mnt"
+DEBUG: types: "(null)"
+DEBUG: opts: "(null)"
diff --git a/tests/functions.sh b/tests/functions.sh
new file mode 100644
index 000000000..64392e4d5
--- /dev/null
+++ b/tests/functions.sh
@@ -0,0 +1,42 @@
+
+TS_OUTDIR="$TS_TOPDIR/output"
+TS_DIFFDIR="$TS_TOPDIR/diff"
+TS_EXPECTEDDIR="$TS_TOPDIR/expected"
+
+function ts_init {
+ TS_NAME=$(basename $0)
+ if [ ! -d $TS_OUTDIR ]; then
+ mkdir -p $TS_OUTDIR
+ fi
+ if [ ! -d $TS_DIFFDIR ]; then
+ mkdir -p $TS_DIFFDIR
+ fi
+ TS_OUTPUT="$TS_OUTDIR/$TS_NAME"
+ TS_DIFF="$TS_DIFFDIR/$TS_NAME"
+ TS_EXPECTED="$TS_EXPECTEDDIR/$TS_NAME"
+
+ printf "%15s: %-25s ..." "$TS_COMPONENT" "$TS_DESC"
+}
+
+function ts_finalize {
+ local res=0
+
+ if [ -s $TS_EXPECTED ]; then
+ if [ -s $TS_OUTPUT ]; then
+ diff -u $TS_EXPECTED $TS_OUTPUT > $TS_DIFF
+ if [ -s $TS_DIFF ]; then
+ res=1
+ fi
+ else
+ res=0
+ fi
+ fi
+ if [ $res -eq 0 ]; then
+ echo " OK"
+ exit 0
+ else
+ echo " FAILED ($TS_NAME)"
+ exit 1
+ fi
+}
+
diff --git a/tests/run.sh b/tests/run.sh
new file mode 100755
index 000000000..b4ca51b57
--- /dev/null
+++ b/tests/run.sh
@@ -0,0 +1,25 @@
+#!/bin/bash
+
+. commands.sh
+
+echo
+echo "------------------ Utils-linux-ng regression tests ------------------"
+echo
+
+res=0
+count=0
+for ts in `ls ts-*`; do
+ $TS_TOPDIR/$ts
+ res=$(( $res + $? ))
+ count=$(( $count + 1 ))
+done
+
+echo
+echo "---------------------------------------------------------------------"
+if [ $res -eq 0 ]; then
+ echo " All $count tests PASSED"
+else
+ echo " $res tests of $count FAILED"
+fi
+echo "---------------------------------------------------------------------"
+
diff --git a/tests/ts-mount-paths b/tests/ts-mount-paths
new file mode 100755
index 000000000..137aade38
--- /dev/null
+++ b/tests/ts-mount-paths
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+. commands.sh
+. functions.sh
+
+TS_COMPONENT="mount"
+TS_DESC="basic paths"
+
+ts_init
+
+$TS_CMD_MOUNT -n -f --debug=2 /dev/dummy /mnt &> $TS_OUTPUT
+
+ts_finalize
+