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>
po \
schedutils \
sys-utils \
- text-utils
+ text-utils \
+ tests
ACLOCAL_AMFLAGS = -I m4
schedutils/Makefile
sys-utils/Makefile
text-utils/Makefile
+tests/Makefile
+tests/commands.sh
])
AC_OUTPUT
--- /dev/null
+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
+
--- /dev/null
+
+ 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
+
--- /dev/null
+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"}
--- /dev/null
+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)"
--- /dev/null
+
+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
+}
+
--- /dev/null
+#!/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 "---------------------------------------------------------------------"
+
--- /dev/null
+#!/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
+