summaryrefslogtreecommitdiffstats
path: root/tests/functions.sh
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/functions.sh
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/functions.sh')
-rw-r--r--tests/functions.sh42
1 files changed, 42 insertions, 0 deletions
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
+}
+