File: regtest.sh

package info (click to toggle)
cronutils 1.10-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 244 kB
  • sloc: ansic: 664; sh: 89; makefile: 35
file content (34 lines) | stat: -rwxr-xr-x 746 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/sh

SRCDIR=$(cd -P -- $(dirname -- "$0") && pwd -P)
TESTDIR=$SRCDIR/tests
TEMPDIR=$(mktemp -t -d cronutils.regtest-XXXXXX)
trap "cd $SRCDIR; rm -rf $TEMPDIR" 0 INT QUIT ABRT PIPE TERM

cd $TEMPDIR

export PATH=$SRCDIR:$PATH

for s in $TESTDIR/*.sh; do
	test=$(basename $s .sh)	
	mkdir $TEMPDIR/$test
	cd $TEMPDIR/$test
	$s > $TEMPDIR/$test.out 2>$TEMPDIR/$test.err
	r=$?
	if [ $r -ne 0 ]; then
	  echo $test: FAIL - exit code $r
	  echo stdout
	  cat $TEMPDIR/$test.out
	  echo stderr
	  cat $TEMPDIR/$test.err
	  exit 1
        fi
	diff $TESTDIR/$test.out $TEMPDIR/$test.out > $TEMPDIR/$test.diff
	if [ $? -ne 0 ]; then
	  echo $test: FAIL - output match:
	  cat $TEMPDIR/$test.diff
	  exit 1
        fi
	echo $test: OK
	cd $TEMPDIR
done