aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/pies.c10
-rw-r--r--tests/.gitignore2
-rw-r--r--tests/Makefile.am6
-rwxr-xr-xtests/aux/respawn75
-rwxr-xr-xtests/aux/sleepexit8
-rwxr-xr-xtests/aux/startcheck22
-rwxr-xr-xtests/aux/touchfile10
-rw-r--r--tests/env.at7
-rw-r--r--tests/lines.c31
-rw-r--r--tests/redirect.at12
-rw-r--r--tests/respawn.at38
-rw-r--r--tests/ret-exec.at2
-rw-r--r--tests/ret-notify.at2
-rw-r--r--tests/shell.at48
-rw-r--r--tests/shutdown.at48
-rw-r--r--tests/startup.at67
-rw-r--r--tests/to.c74
17 files changed, 265 insertions, 197 deletions
diff --git a/src/pies.c b/src/pies.c
index 39467a2..2387cef 100644
--- a/src/pies.c
+++ b/src/pies.c
@@ -928,14 +928,14 @@ _cb_redir (enum grecs_callback_command cmd,
928 { 928 {
929 grecs_error (locus, 0, _("unknown syslog priority %s"), 929 grecs_error (locus, 0, _("unknown syslog priority %s"),
930 value->v.string); 930 value->v.string);
931 return 0; 931 return 1;
932 } 932 }
933 break; 933 break;
934 934
935 case GRECS_TYPE_ARRAY: 935 case GRECS_TYPE_ARRAY:
936 if (assert_grecs_value_type (locus, value->v.arg.v[0], 936 if (assert_grecs_value_type (locus, value->v.arg.v[0],
937 GRECS_TYPE_STRING)) 937 GRECS_TYPE_STRING))
938 return 0; 938 return 1;
939 if (strtotok (redirtab, value->v.arg.v[0]->v.string, &res)) 939 if (strtotok (redirtab, value->v.arg.v[0]->v.string, &res))
940 grecs_error (locus, 0, _("%s: unrecognised redirector type"), 940 grecs_error (locus, 0, _("%s: unrecognised redirector type"),
941 value->v.arg.v[0]->v.string); 941 value->v.arg.v[0]->v.string);
@@ -946,11 +946,11 @@ _cb_redir (enum grecs_callback_command cmd,
946 if (value->v.arg.c != 2) 946 if (value->v.arg.c != 2)
947 { 947 {
948 grecs_error (locus, 0, _("wrong number of arguments")); 948 grecs_error (locus, 0, _("wrong number of arguments"));
949 return 0; 949 return 1;
950 } 950 }
951 if (assert_grecs_value_type (locus, value->v.arg.v[1], 951 if (assert_grecs_value_type (locus, value->v.arg.v[1],
952 GRECS_TYPE_STRING)) 952 GRECS_TYPE_STRING))
953 return 0; 953 return 1;
954 954
955 switch (res) 955 switch (res)
956 { 956 {
@@ -964,7 +964,7 @@ _cb_redir (enum grecs_callback_command cmd,
964 grecs_error (locus, 0, 964 grecs_error (locus, 0,
965 _("unknown syslog priority %s"), 965 _("unknown syslog priority %s"),
966 value->v.arg.v[1]->v.string); 966 value->v.arg.v[1]->v.string);
967 return 0; 967 return 1;
968 } 968 }
969 break; 969 break;
970 970
diff --git a/tests/.gitignore b/tests/.gitignore
index 276645a..459fa44 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -1,7 +1,9 @@
1atconfig 1atconfig
2atlocal 2atlocal
3envtest 3envtest
4lines
4package.m4 5package.m4
5testsuite 6testsuite
6testsuite.dir 7testsuite.dir
7testsuite.log 8testsuite.log
9to
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 419818b..14f5b4f 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -18,7 +18,9 @@ AUXTOOLS = \
18 aux/respawn\ 18 aux/respawn\
19 aux/retcode\ 19 aux/retcode\
20 aux/mailer\ 20 aux/mailer\
21 aux/touchfile 21 aux/touchfile\
22 aux/sleepexit\
23 aux/startcheck
22 24
23EXTRA_DIST = $(TESTSUITE_AT) testsuite package.m4 $(AUXTOOLS) 25EXTRA_DIST = $(TESTSUITE_AT) testsuite package.m4 $(AUXTOOLS)
24DISTCLEANFILES = atconfig $(check_SCRIPTS) 26DISTCLEANFILES = atconfig $(check_SCRIPTS)
@@ -62,7 +64,7 @@ TESTSUITE_AT = \
62TESTSUITE = $(srcdir)/testsuite 64TESTSUITE = $(srcdir)/testsuite
63M4=m4 65M4=m4
64 66
65noinst_PROGRAMS = envtest 67noinst_PROGRAMS = envtest to lines
66AM_CPPFLAGS = \ 68AM_CPPFLAGS = \
67 -I$(top_srcdir)/lib\ 69 -I$(top_srcdir)/lib\
68 @GRECS_INCLUDES@ 70 @GRECS_INCLUDES@
diff --git a/tests/aux/respawn b/tests/aux/respawn
index cd9687a..afed85b 100755
--- a/tests/aux/respawn
+++ b/tests/aux/respawn
@@ -1,63 +1,22 @@
1#! /bin/sh 1#! /bin/sh
2 2
3# usage: respawn [-append] [-stderr FILE] [-stdout FILE] [-sleep TIME] 3# usage: respawn FILE COUNT
4# [-pid FILE] [-tag STRING] [-exit CODE]
5 4
6append=0 5file=${1:?}
7unset name 6maxcount=${2:?}
8time=1
9tag=$0
10code=0
11 7
12while [ $# -ne 0 ] 8count=0
13do
14 arg=$1
15 shift
16 case $arg in
17 -append)
18 append=1;;
19 -stderr)
20 name=${1:?missing argument for -stderr}
21 shift
22 if [ $append -eq 1 ]; then
23 exec 2>>$name
24 append=0
25 else
26 exec 2>$name
27 fi;;
28 -stdout)
29 name=${1:?missing argument for -stdout}
30 shift
31 if [ $append -eq 1 ]; then
32 exec >>$name
33 append=0
34 else
35 exec >$name
36 fi;;
37 -sleep)
38 time=${1:?missing argument for -sleep}
39 shift;;
40 -pid)
41 name=${1:?missing argument for -pid}
42 shift
43 if [ $append -eq 1 ]; then
44 echo $$ >>$name
45 append=0
46 else
47 echo $$ >$name
48 fi;;
49 -tag)
50 tag=${1:?missing argument for -tag}
51 shift;;
52 -exit)
53 code=${1:?missing argument for -exit}
54 shift;;
55 *) echo >&2 "$tag: invalid argument: $arg"
56 exit 1
57 esac
58done
59 9
60echo "$tag: start" 10if [ -f $file ]; then
61sleep $time 11 count=`cat $file`
62echo "$tag: stop" 12 if test -n "$count" && test $count -ge $maxcount; then
63exit $code 13 exit 1
14 fi
15fi
16
17count=$(($count + 1))
18echo "$count" > $file
19
20exit 0
21
22
diff --git a/tests/aux/sleepexit b/tests/aux/sleepexit
new file mode 100755
index 0000000..25a9a5b
--- /dev/null
+++ b/tests/aux/sleepexit
@@ -0,0 +1,8 @@
1#! /bin/sh
2t=${1:?}
3c=${2:?}
4if test -n "$3"; then
5 echo $$ > $3
6fi
7sleep $t
8exit $c
diff --git a/tests/aux/startcheck b/tests/aux/startcheck
new file mode 100755
index 0000000..6e84959
--- /dev/null
+++ b/tests/aux/startcheck
@@ -0,0 +1,22 @@
1#!/bin/sh
2
3# usage: startcheck FILE...
4
5for file
6do
7 if [ -f $file ]; then
8 echo "# $file"
9 cat $file
10 else
11 echo >&2 "$0: $file does not exist"
12 exit 1
13 fi
14done
15
16exit 0
17
18
19
20
21
22
diff --git a/tests/aux/touchfile b/tests/aux/touchfile
index b9d92a3..a3a2668 100755
--- a/tests/aux/touchfile
+++ b/tests/aux/touchfile
@@ -1,7 +1,7 @@
1#!/bin/sh 1#!/bin/sh
2dir=${1:?} 2file=${1:?}
3time=${2:?} 3time=${2:-0}
4tag=${3:?} 4tag=${3:-$file}
5 5
6touch $dir/$tag 6echo $tag > $file
7sleep $time 7test $time -ne 0 && sleep $time
diff --git a/tests/env.at b/tests/env.at
index 26fe866..c293c65 100644
--- a/tests/env.at
+++ b/tests/env.at
@@ -20,7 +20,10 @@ component envtest {
20} 20}
21_EOT 21_EOT
22 22
23envtest -exec $abs_top_builddir/src/pies --foreground --stderr --config-file control.conf --config-file envtest.conf 2>errlog 23to 3 \