aboutsummaryrefslogtreecommitdiff
path: root/t/testsuite
diff options
context:
space:
mode:
Diffstat (limited to 't/testsuite')
-rwxr-xr-xt/testsuite139
1 files changed, 0 insertions, 139 deletions
diff --git a/t/testsuite b/t/testsuite
deleted file mode 100755
index bd870ce..0000000
--- a/t/testsuite
+++ /dev/null
@@ -1,139 +0,0 @@
1#! /bin/sh
2# testsuite for runcap - run program and capture its output
3# Copyright (C) 2017 Sergey Poznyakoff
4#
5# Runcap is free software; you can redistribute it and/or modify it
6# under the terms of the GNU General Public License as published by the
7# Free Software Foundation; either version 3 of the License, or (at your
8# option) any later version.
9#
10# Runcap is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License along
16# with Runcap. If not, see <http://www.gnu.org/licenses/>.
17
18testdir=$(cd $(dirname $0); pwd)
19progname=$(basename $0)
20
21topworkdir=$(pwd)
22workdir=$topworkdir/testsuite.dir
23if [ ! -d $workdir ]; then
24 mkdir $workdir
25fi
26
27cd $testdir
28numfiles=$(ls -1 *.t 2>/dev/null| sed -n '$=')
29
30if [ ${numfiles:-0} -eq 0 ]; then
31 echo >&2 "$progname: no test files in $testdir"
32 exit 2
33fi
34
35printheader() {
36 awk -v P=$numfiles 'NR==1 { num=$1; next }
37 NR==2 { printf("%0d: %s", num, $1); next }
38 { if (NF!=0) printf(" - %s", $0);
39 printf(": "); }' <<EOF
40$1
41$2
42$3
43EOF
44}
45
46PATH=$topworkdir:$PATH
47echo $PATH
48TC_EXPECT() {
49 cat > exp$1
50}
51TC_TITLE() {
52 :
53}
54
55numtests=0
56numfail=0
57cd $testdir
58exec 3>$topworkdir/testsuite.log
59
60if [ $# -gt 0 ]; then
61 testlist=$(ls $*) || exit 1
62else
63 testlist=$(ls *.t)
64fi
65
66for tc in $testlist
67do
68 cd $testdir
69 tc=$(echo $tc|sed 's|\./||')
70 # Skip if invalid name
71 echo "$tc" | grep -q '[^a-zA-Z0-9._-]' && continue
72 # Skip if not executable
73 test -x $tc || continue
74
75 cd $workdir
76
77 dirname=${tc%%.t}
78 if [ -d $dirname ]; then
79 rm -rf $dirname/*
80 else
81 mkdir $dirname || continue
82 fi
83 cd $dirname
84
85 descr=$(sed -n '/TC_TITLE /s///p' $testdir/$tc)
86 printheader $numtests $tc "$descr"
87 ( . $testdir/$tc ) >out 2>err
88 retcode=$?
89 numtests=$(( $numtests + 1 ))
90 cd $workdir
91
92 exec 4>templog
93 if [ $retcode -eq 77 ]; then
94 echo "SKIP"
95 continue
96 fi
97 if [ $retcode -ne 0 ]; then
98 echo >&4 "# exit code: $retcode"
99 fi
100
101 test -r $dirname/expout || > $dirname/expout
102 if ! cmp $dirname/expout $dirname/out 2>/dev/null >&2; then
103 echo >&4 "# stdout diff"
104 diff -pu $dirname/expout $dirname/out >&4
105 fi
106 test -r $dirname/experr || > $dirname/experr
107 if ! cmp $dirname/experr $dirname/err 2>/dev/null >&2; then
108 echo >&4 "# stderr diff"
109 diff -pu $dirname/experr $dirname/err >&4
110 fi
111
112 if [ -s templog ]; then
113 echo "FAIL"
114 numfail=$(( $numfail + 1 ))
115 echo >&3 "# Testcase $tc FAILED"
116 cat >&3 templog
117 echo >&3 "# Content:"
118 cat >&3 $testdir/$tc
119 echo >&3 "# stdout:"
120 cat >&3 $dirname/out
121 echo >&3 "# stderr:"
122 cat >&3 $dirname/err
123 else
124 echo "OK"
125 rm -rf $dirname
126 fi
127 rm templog
128done
129
130cd $topworkdir
131
132if [ $numfail -ne 0 ]; then
133 echo >&2 "# $numfail out of $numtests tests failed"
134 echo >&2 "# See testsuite.log for more info"
135 exit 1
136else
137 rmdir $workdir 2>/dev/null
138 rm testsuite.log
139fi

Return to:

Send suggestions and report system problems to the System administrator.