-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | configure.ac | 5 | ||||
-rw-r--r-- | doc/pies.texi | 2 | ||||
-rw-r--r-- | src/progman.c | 2 | ||||
-rw-r--r-- | tests/.gitignore | 6 | ||||
-rw-r--r-- | tests/Makefile.am | 71 | ||||
-rw-r--r-- | tests/atlocal.in | 6 | ||||
-rw-r--r-- | tests/control.at | 55 | ||||
-rwxr-xr-x | tests/mailer | 7 | ||||
-rw-r--r-- | tests/redirect.at | 60 | ||||
-rwxr-xr-x | tests/respawn | 63 | ||||
-rw-r--r-- | tests/respawn.at | 52 | ||||
-rw-r--r-- | tests/ret-exec.at | 68 | ||||
-rw-r--r-- | tests/ret-notify.at | 68 | ||||
-rwxr-xr-x | tests/retcode | 9 | ||||
-rw-r--r-- | tests/testsuite.at | 65 | ||||
-rw-r--r-- | tests/version.at | 28 |
17 files changed, 566 insertions, 3 deletions
diff --git a/Makefile.am b/Makefile.am index 0358e8c..ff6f5db 100644 --- a/Makefile.am +++ b/Makefile.am | |||
@@ -16,7 +16,7 @@ | |||
16 | 16 | ||
17 | ACLOCAL_AMFLAGS = -I m4 -I am -I grecs/am -I imprimatur | 17 | ACLOCAL_AMFLAGS = -I m4 -I am -I grecs/am -I imprimatur |
18 | 18 | ||
19 | SUBDIRS=gnu grecs lib ident src imprimatur doc po | 19 | SUBDIRS=gnu grecs lib ident src tests imprimatur doc po |
20 | 20 | ||
21 | dist-hook: | 21 | dist-hook: |
22 | @PATCHLEV=`echo "$(PACKAGE_VERSION)" | \ | 22 | @PATCHLEV=`echo "$(PACKAGE_VERSION)" | \ |
diff --git a/configure.ac b/configure.ac index 78702b4..6ee1084 100644 --- a/configure.ac +++ b/configure.ac | |||
@@ -142,6 +142,11 @@ AC_ARG_VAR([EMERGENCY_SHELL],[Filename of the emergency shell]) | |||
142 | 142 | ||
143 | IMPRIMATUR_INIT | 143 | IMPRIMATUR_INIT |
144 | 144 | ||
145 | # Initialize the test suite. | ||
146 | AC_CONFIG_TESTDIR(tests) | ||
147 | AC_CONFIG_FILES([tests/Makefile tests/atlocal]) | ||
148 | AM_MISSING_PROG([AUTOM4TE], [autom4te]) | ||
149 | |||
145 | AC_CONFIG_FILES([Makefile | 150 | AC_CONFIG_FILES([Makefile |
146 | gnu/Makefile | 151 | gnu/Makefile |
147 | lib/Makefile | 152 | lib/Makefile |
diff --git a/doc/pies.texi b/doc/pies.texi index 15c37e1..0e8af70 100644 --- a/doc/pies.texi +++ b/doc/pies.texi | |||
@@ -1868,7 +1868,7 @@ The table below lists all available variables and their expansions: | |||
1868 | @headitem Variable @tab Expansion | 1868 | @headitem Variable @tab Expansion |
1869 | @item canonical_program_name @tab @samp{pies} | 1869 | @item canonical_program_name @tab @samp{pies} |
1870 | @item program_name @tab Program name of the @command{pies} binary. | 1870 | @item program_name @tab Program name of the @command{pies} binary. |
1871 | @item package @tab Package name (@samp{Pies}). | 1871 | @item package @tab Package name (@samp{GNU Pies}). |
1872 | @item instance @tab Instance name (@pxref{instances}). | 1872 | @item instance @tab Instance name (@pxref{instances}). |
1873 | @item version @tab Package version (@value{VERSION}). | 1873 | @item version @tab Package version (@value{VERSION}). |
1874 | @item component @tab Name of the terminated component. | 1874 | @item component @tab Name of the terminated component. |
diff --git a/src/progman.c b/src/progman.c index 5693011..fdb829a 100644 --- a/src/progman.c +++ b/src/progman.c | |||
@@ -2078,7 +2078,7 @@ notify (const char *tag, int status, struct action *act) | |||
2078 | #define INSTANCE_IDX 3 | 2078 | #define INSTANCE_IDX 3 |
2079 | "instance", NULL, | 2079 | "instance", NULL, |
2080 | "canonical_program_name", "pies", | 2080 | "canonical_program_name", "pies", |
2081 | "package", PACKAGE, | 2081 | "package", PACKAGE_NAME, |
2082 | "version", PACKAGE_VERSION, | 2082 | "version", PACKAGE_VERSION, |
2083 | NULL | 2083 | NULL |
2084 | }; | 2084 | }; |
diff --git a/tests/.gitignore b/tests/.gitignore new file mode 100644 index 0000000..93f8f46 --- a/dev/null +++ b/tests/.gitignore | |||
@@ -0,0 +1,6 @@ | |||
1 | atconfig | ||
2 | atlocal | ||
3 | package.m4 | ||
4 | testsuite | ||
5 | testsuite.dir | ||
6 | testsuite.log | ||
diff --git a/tests/Makefile.am b/tests/Makefile.am new file mode 100644 index 0000000..668fe5e --- a/dev/null +++ b/tests/Makefile.am | |||
@@ -0,0 +1,71 @@ | |||
1 | # This file is part of GNU Pies. | ||
2 | # Copyright (C) 2008-2016 Sergey Poznyakoff | ||
3 | # | ||
4 | # GNU Pies is free software; you can redistribute it and/or modify | ||
5 | # it under the terms of the GNU General Public License as published by | ||
6 | # the Free Software Foundation; either version 3, or (at your option) | ||
7 | # any later version. | ||
8 | # | ||
9 | # GNU Pies is distributed in the hope that it will be useful, | ||
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | # GNU General Public License for more details. | ||
13 | # | ||
14 | # You should have received a copy of the GNU General Public License | ||
15 | # along with GNU Pies. If not, see <http://www.gnu.org/licenses/>. | ||
16 | |||
17 | EXTRA_DIST = $(TESTSUITE_AT) testsuite package.m4 respawn retcode mailer | ||
18 | DISTCLEANFILES = atconfig $(check_SCRIPTS) | ||
19 | MAINTAINERCLEANFILES = Makefile.in $(TESTSUITE) | ||
20 | |||
21 | ## ------------ ## | ||
22 | ## package.m4. ## | ||
23 | ## ------------ ## | ||
24 | |||
25 | $(srcdir)/package.m4: $(top_srcdir)/configure.ac | ||
26 | { \ | ||
27 | echo '# Signature of the current package.'; \ | ||
28 | echo 'm4_define([AT_PACKAGE_NAME], [@PACKAGE_NAME@])'; \ | ||
29 | echo 'm4_define([AT_PACKAGE_TARNAME], [@PACKAGE_TARNAME@])'; \ | ||
30 | echo 'm4_define([AT_PACKAGE_VERSION], [@PACKAGE_VERSION@])'; \ | ||
31 | echo 'm4_define([AT_PACKAGE_STRING], [@PACKAGE_STRING@])'; \ | ||
32 | echo 'm4_define([AT_PACKAGE_BUGREPORT], [@PACKAGE_BUGREPORT@])'; \ | ||
33 | } >$(srcdir)/package.m4 | ||
34 | |||
35 | # | ||
36 | |||
37 | ## ------------ ## | ||
38 | ## Test suite. ## | ||
39 | ## ------------ ## | ||
40 | |||
41 | TESTSUITE_AT = \ | ||
42 | testsuite.at\ | ||
43 | control.at\ | ||
44 | respawn.at\ | ||
45 | redirect.at\ | ||
46 | ret-exec.at\ | ||
47 | ret-notify.at\ | ||
48 | version.at | ||
49 | |||
50 | TESTSUITE = $(srcdir)/testsuite | ||
51 | M4=m4 | ||
52 | |||
53 | AUTOTEST = $(AUTOM4TE) --language=autotest | ||
54 | $(TESTSUITE): package.m4 $(TESTSUITE_AT) | ||
55 | $(AM_V_GEN)$(AUTOTEST) -I $(srcdir) testsuite.at -o $@.tmp | ||
56 | $(AM_V_at)mv $@.tmp $@ | ||
57 | |||
58 | atconfig: $(top_builddir)/config.status | ||
59 | cd $(top_builddir) && ./config.status tests/$@ | ||
60 | |||
61 | clean-local: | ||
62 | @test ! -f $(TESTSUITE) || $(SHELL) $(TESTSUITE) --clean | ||
63 | |||
64 | check-local: atconfig atlocal $(TESTSUITE) | ||
65 | @$(SHELL) $(TESTSUITE) | ||
66 | |||
67 | # Run the test suite on the *installed* tree. | ||
68 | #installcheck-local: | ||
69 | #$(SHELL) $(TESTSUITE) AUTOTEST_PATH=$(exec_prefix)/bin | ||
70 | |||
71 | |||
diff --git a/tests/atlocal.in b/tests/atlocal.in new file mode 100644 index 0000000..6cb3c43 --- a/dev/null +++ b/tests/atlocal.in | |||
@@ -0,0 +1,6 @@ | |||
1 | # @configure_input@ -*- shell-script -*- | ||
2 | # Configurable variable values for GNU Pies test suite. | ||
3 | # Copyright (C) 2016 Sergey Poznyakoff | ||
4 | |||
5 | PATH=@abs_builddir@:@abs_top_builddir@/src:$srcdir:$PATH | ||
6 | XFAILFILE=$abs_builddir/.badversion | ||
diff --git a/tests/control.at b/tests/control.at new file mode 100644 index 0000000..95befdf --- a/dev/null +++ b/tests/control.at | |||
@@ -0,0 +1,55 @@ | |||
1 | # This file is part of GNU pies testsuite. -*- Autotest -*- | ||
2 | # Copyright (C) 2016 Sergey Poznyakoff | ||
3 | # | ||
4 | # GNU pies is free software; you can redistribute it and/or modify | ||
5 | # it under the terms of the GNU General Public License as published by | ||
6 | # the Free Software Foundation; either version 3, or (at your option) | ||
7 | # any later version. | ||
8 | # | ||
9 | # GNU pies is distributed in the hope that it will be useful, | ||
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | # GNU General Public License for more details. | ||
13 | # | ||
14 | # You should have received a copy of the GNU General Public License | ||
15 | # along with GNU pies. If not, see <http://www.gnu.org/licenses/>. | ||
16 | |||
17 | AT_SETUP([Control interface]) | ||
18 | |||
19 | AT_CHECK([ | ||
20 | PIES_XFAIL_CHECK | ||
21 | PIES_CONTROL_INIT | ||
22 | |||
23 | pies --config-file control.conf | ||
24 | |||
25 | sleep 1 | ||
26 | if test -f $pidfile; then | ||
27 | pid0=`head -1 $pidfile` | ||
28 | pid1=`piesctl --url "$ctlsock" id PID|sed 's/^PID: //'` | ||
29 | if test "$pid1" = "$pid0"; then | ||
30 | if piesctl --url "$ctlsock" shutdown; then | ||
31 | sleep 1 | ||
32 | if test -f $pidfile; then | ||
33 | PIES_XFAIL_MSG([pies does not respond to control commands]) | ||
34 | kill -9 $pid0 | ||
35 | exit 1 | ||
36 | else | ||
37 | exit 0 | ||
38 | fi | ||
39 | else | ||
40 | PIES_XFAIL_MSG([can't send control commands]) | ||
41 | kill -9 $pid0 | ||
42 | exit 1 | ||
43 | fi | ||
44 | else | ||
45 | PIES_XFAIL_MSG([Control interface non-functional]) | ||
46 | exit 1 | ||
47 | fi | ||
48 | else | ||
49 | PIES_XFAIL_MSG([pies failed to start]) | ||
50 | exit 1 | ||
51 | fi | ||
52 | ], | ||
53 | [0]) | ||
54 | |||
55 | AT_CLEANUP | ||
diff --git a/tests/mailer b/tests/mailer new file mode 100755 index 0000000..f832ff5 --- a/dev/null +++ b/tests/mailer | |||
@@ -0,0 +1,7 @@ | |||
1 | #! /bin/sh | ||
2 | |||
3 | exec >${1:?} | ||
4 | shift | ||
5 | echo $* | ||
6 | cat - | ||
7 | |||
diff --git a/tests/redirect.at b/tests/redirect.at new file mode 100644 index 0000000..e8d98d8 --- a/dev/null +++ b/tests/redirect.at | |||
@@ -0,0 +1,60 @@ | |||
1 | # This file is part of GNU pies testsuite. -*- Autotest -*- | ||
2 | # Copyright (C) 2016 Sergey Poznyakoff | ||
3 | # | ||
4 | # GNU pies is free software; you can redistribute it and/or modify | ||
5 | # it under the terms of the GNU General Public License as published by | ||
6 | # the Free Software Foundation; either version 3, or (at your option) | ||
7 | # any later version. | ||
8 | # | ||
9 | # GNU pies is distributed in the hope that it will be useful, | ||
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | # GNU General Public License for more details. | ||
13 | # | ||
14 | # You should have received a copy of the GNU General Public License | ||
15 | # along with GNU pies. If not, see <http://www.gnu.org/licenses/>. | ||
16 | |||
17 | AT_SETUP([stdout redirection]) | ||
18 | |||
19 | AT_CHECK([ | ||
20 | PIES_XFAIL_CHECK | ||
21 | PIES_CONTROL_INIT | ||
22 | comp_pid_file=$PWD/comp.pid | ||
23 | outfile=$PWD/out | ||
24 | cat > pies.conf <<_EOT | ||
25 | component test { | ||
26 | mode respawn; | ||
27 | command "$abs_srcdir/respawn -tag respawn -append -pid $comp_pid_file"; | ||
28 | stdout file "$outfile"; | ||
29 | } | ||
30 | _EOT | ||
31 | |||
32 | pies --config-file control.conf --config-file pies.conf | ||
33 | |||
34 | n=0 | ||
35 | while : | ||
36 | do | ||
37 | if test -f $comp_pid_file; then | ||
38 | lines=`wc -l $comp_pid_file | awk '{print $1}'` | ||
39 | if test "$lines" -ge 2 ; then | ||
40 | break | ||
41 | fi | ||
42 | fi | ||
43 | sleep 1 | ||
44 | n=$(($n + 1)) | ||
45 | if test $n -gt 25; then | ||
46 | echo >&2 "timed out" | ||
47 | break | ||
48 | fi | ||
49 | done | ||
50 | |||
51 | PIES_STOP | ||
52 | |||
53 | cat $outfile | ||
54 | ], | ||
55 | [0], | ||
56 | [respawn: start | ||
57 | respawn: stop | ||
58 | ]) | ||
59 | |||
60 | AT_CLEANUP | ||
diff --git a/tests/respawn b/tests/respawn new file mode 100755 index 0000000..11d59f6 --- a/dev/null +++ b/tests/respawn | |||
@@ -0,0 +1,63 @@ | |||
1 | #! /bin/sh | ||
2 | |||
3 | # usage: respawn [-append] [-stderr FILE] [-stdout FILE] [-sleep TIME] | ||
4 | # [-pid FILE] [-tag STRING] [-exit CODE] | ||
5 | |||
6 | append=0 | ||
7 | unset name | ||
8 | time=10 | ||
9 | tag=$0 | ||
10 | code=0 | ||
11 | |||
12 | while [ $# -ne 0 ] | ||
13 | do | ||
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 | ||
58 | done | ||
59 | |||
60 | echo "$tag: start" | ||
61 | sleep $time | ||
62 | echo "$tag: stop" | ||
63 | exit $code | ||
diff --git a/tests/respawn.at b/tests/respawn.at new file mode 100644 index 0000000..5b0082c --- a/dev/null +++ b/tests/respawn.at | |||
@@ -0,0 +1,52 @@ | |||
1 | # This file is part of GNU pies testsuite. -*- Autotest -*- | ||
2 | # Copyright (C) 2016 Sergey Poznyakoff | ||
3 | # | ||
4 | # GNU pies is free software; you can redistribute it and/or modify | ||
5 | # it under the terms of the GNU General Public License as published by | ||
6 | # the Free Software Foundation; either version 3, or (at your option) | ||
7 | # any later version. | ||
8 | # | ||
9 | # GNU pies is distributed in the hope that it will be useful, | ||
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | # GNU General Public License for more details. | ||
13 | # | ||
14 | # You should have received a copy of the GNU General Public License | ||
15 | # along with GNU pies. If not, see <http://www.gnu.org/licenses/>. | ||
16 | |||
17 | AT_SETUP([Respawn components]) | ||
18 | |||
19 | AT_CHECK([ | ||
20 | PIES_XFAIL_CHECK | ||
21 | PIES_CONTROL_INIT | ||
22 | comp_pid_file=$PWD/comp.pid | ||
23 | cat > pies.conf <<_EOT | ||
24 | component test { | ||
25 | mode respawn; | ||
26 | command "$abs_srcdir/respawn -append -pid $comp_pid_file"; | ||
27 | } | ||
28 | _EOT | ||
29 | |||
30 | pies --config-file control.conf --config-file pies.conf | ||
31 | |||
32 | n=0 | ||
33 | while : | ||
34 | do | ||
35 | if test -f $comp_pid_file; then | ||
36 | lines=`wc -l $comp_pid_file | awk '{print $1}'` | ||
37 | if test "$lines" -ge 3 ; then | ||
38 | break | ||
39 | fi | ||
40 | fi | ||
41 | sleep 1 | ||
42 | n=$(($n + 1)) | ||
43 | if test $n -gt 35; then | ||
44 | echo >&2 "timed out" | ||
45 | break | ||
46 | fi | ||
47 | done | ||
48 | |||
49 | PIES_STOP | ||
50 | ]) | ||
51 | |||
52 | AT_CLEANUP | ||
diff --git a/tests/ret-exec.at b/tests/ret-exec.at new file mode 100644 index 0000000..f674d84 --- a/dev/null +++ b/tests/ret-exec.at | |||
@@ -0,0 +1,68 @@ | |||
1 | # This file is part of GNU pies testsuite. -*- Autotest -*- | ||
2 | # Copyright (C) 2016 Sergey Poznyakoff | ||
3 | # | ||
4 | # GNU pies is free software; you can redistribute it and/or modify | ||
5 | # it under the terms of the GNU General Public License as published by | ||
6 | # the Free Software Foundation; either version 3, or (at your option) | ||
7 | # any later version. | ||
8 | # | ||
9 | # GNU pies is distributed in the hope that it will be useful, | ||
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | # GNU General Public License for more details. | ||
13 | # | ||
14 | # You should have received a copy of the GNU General Public License | ||
15 | # along with GNU pies. If not, see <http://www.gnu.org/licenses/>. | ||
16 | |||
17 | AT_SETUP([Exec on return code]) | ||
18 | AT_KEYWORDS([ret-exec]) | ||
19 | |||
20 | AT_CHECK([ | ||
21 | PIES_XFAIL_CHECK | ||
22 | PIES_CONTROL_INIT | ||
23 | comp_pid_file=$PWD/comp.pid | ||
24 | report_file=$PWD/report | ||
25 | cat > pies.conf <<_EOT | ||
26 | component test { | ||
27 | mode respawn; | ||
28 | return-code 10 { | ||
29 | exec "$abs_srcdir/retcode $report_file"; | ||
30 | action disable; | ||
31 | } | ||
32 | command "$abs_srcdir/respawn -sleep 2 -pid $comp_pid_file -exit 10"; | ||
33 | } | ||
34 | _EOT | ||
35 | |||
36 | >$report_file | ||
37 | |||
38 | pies --config-file control.conf --config-file pies.conf | ||
39 | |||
40 | n=0 | ||
41 | while test ! -s $report_file | ||
42 | do | ||
43 | sleep 1 | ||
44 | n=$(($n + 1)) | ||
45 | if test $n -gt 4; then | ||
46 | echo >&2 "timed out" | ||
47 | break | ||
48 | fi | ||
49 | done | ||
50 | |||
51 | PIES_STOP | ||
52 | |||
53 | if test -f $report_file; then | ||
54 | pid=`head $comp_pid_file` | ||
55 | sed "s/$pid/PID/" $report_file | ||
56 | else | ||
57 | echo >&2 "no report file" | ||
58 | fi | ||
59 | ], | ||
60 | [0], | ||
61 | [AT_PACKAGE_VERSION | ||
62 | test | ||
63 | PID | ||
64 | 10 | ||
65 | No signal | ||
66 | ]) | ||
67 | |||
68 | AT_CLEANUP | ||
diff --git a/tests/ret-notify.at b/tests/ret-notify.at new file mode 100644 index 0000000..2119ed5 --- a/dev/null +++ b/tests/ret-notify.at | |||
@@ -0,0 +1,68 @@ | |||
1 | # This file is part of GNU pies testsuite. -*- Autotest -*- | ||
2 | # Copyright (C) 2016 Sergey Poznyakoff | ||
3 | # | ||
4 | # GNU pies is free software; you can redistribute it and/or modify | ||
5 | # it under the terms of the GNU General Public License as published by | ||
6 | # the Free Software Foundation; either version 3, or (at your option) | ||
7 | # any later version. | ||
8 | # | ||
9 | # GNU pies is distributed in the hope that it will be useful, | ||
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | # GNU General Public License for more details. | ||
13 | # | ||
14 | # You should have received a copy of the GNU General Public License | ||
15 | # along with GNU pies. If not, see <http://www.gnu.org/licenses/>. | ||
16 | |||
17 | AT_SETUP([Notify on return code]) | ||
18 | AT_KEYWORDS([ret-notify]) | ||
19 | |||
20 | AT_CHECK([ | ||
21 | PIES_XFAIL_CHECK | ||
22 | PIES_CONTROL_INIT | ||
23 | report_file=$PWD/report | ||
24 | cat > pies.conf <<_EOT | ||
25 | mailer-program "$abs_srcdir/mailer"; | ||
26 | mailer-command-line "$abs_srcdir/mailer $report_file"; | ||
27 | component test { | ||
28 | mode respawn; | ||
29 | return-code 10 { | ||
30 | notify root; | ||
31 | action disable; | ||
32 | } | ||
33 | command "$abs_srcdir/respawn -sleep 2 -exit 10"; | ||
34 | } | ||
35 | _EOT | ||
36 | |||
37 | >$report_file | ||
38 | |||
39 | pies --config-file control.conf --config-file pies.conf | ||
40 | |||
41 | n=0 | ||
42 | while test ! -s $report_file | ||
43 | do | ||
44 | sleep 1 | ||
45 | n=$(($n + 1)) | ||
46 | if test $n -gt 4; then | ||
47 | echo >&2 "timed out" | ||
48 | break | ||
49 | fi | ||
50 | done | ||
51 | sleep 1 | ||
52 | PIES_STOP | ||
53 | |||
54 | if test -f $report_file; then | ||
55 | cat $report_file | ||
56 | else | ||
57 | echo >&2 "no report file" | ||
58 | fi | ||
59 | ], | ||
60 | [0], | ||
61 | [root | ||
62 | From: <> | ||
63 | X-Agent: pies (AT_PACKAGE_NAME AT_PACKAGE_VERSION) | ||
64 | Subject: Component test exited with code 10. | ||
65 | |||
66 | ]) | ||
67 | |||
68 | AT_CLEANUP | ||
diff --git a/tests/retcode b/tests/retcode new file mode 100755 index 0000000..b827ba9 --- a/dev/null +++ b/tests/retcode | |||
@@ -0,0 +1,9 @@ | |||
1 | #! /bin/sh | ||
2 | |||
3 | exec >${1:?} | ||
4 | |||
5 | echo $PIES_VERSION | ||
6 | echo $PIES_COMPONENT | ||
7 | echo $PIES_PID | ||
8 | echo $PIES_STATUS | ||
9 | echo ${PIES_SIGNAL:-No signal} | ||
diff --git a/tests/testsuite.at b/tests/testsuite.at new file mode 100644 index 0000000..fda54e0 --- a/dev/null +++ b/tests/testsuite.at | |||
@@ -0,0 +1,65 @@ | |||
1 | # This file is part of GNU pies testsuite. -*- Autotest -*- | ||
2 | # Copyright (C) 2016 Sergey Poznyakoff | ||
3 | # | ||
4 | # GNU pies is free software; you can redistribute it and/or modify | ||
5 | # it under the terms of the GNU General Public License as published by | ||
6 | # the Free Software Foundation; either version 3, or (at your option) | ||
7 | # any later version. | ||
8 | # | ||
9 | # GNU pies is distributed in the hope that it will be useful, | ||
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | # GNU General Public License for more details. | ||
13 | # | ||
14 | # You should have received a copy of the GNU General Public License | ||
15 | # along with GNU pies. If not, see <http://www.gnu.org/licenses/>. | ||
16 | |||
17 | m4_version_prereq([2.69]) | ||
18 | |||
19 | m4_define([PIES_SGN],[pies (AT_PACKAGE_NAME) AT_PACKAGE_VERSION]) | ||
20 | |||
21 | m4_define([PIES_XFAIL_MSG],[cat >$[]XFAILFILE <<'_EOT' | ||
22 | ============================================================== | ||
23 | $* | ||
24 | ============================================================== | ||
25 | _EOT | ||
26 | ]) | ||
27 | |||
28 | m4_define([PIES_XFAIL_CHECK],[AT_XFAIL_IF([test -f $[]XFAILFILE])]) | ||
29 | |||
30 | m4_define([PIES_CONTROL_INIT],[ | ||
31 | pidfile="$PWD/pies.pid" | ||
32 | ctlsock="unix://$PWD/pies.ctl"; | ||
33 | cat > control.conf <<_EOT | ||
34 | pidfile "$pidfile"; | ||
35 | control { | ||
36 | socket "$ctlsock"; | ||
37 | } | ||
38 | _EOT | ||
39 | ]) | ||
40 | |||
41 | m4_define([PIES_STOP],[ | ||
42 | piesctl --url "$ctlsock" shutdown | ||
43 | pies_stop_spinner=0 | ||
44 | while test -f $pidfile | ||
45 | do | ||
46 | sleep 1 | ||
47 | pies_stop_spinner=$(($pies_stop_spinner + 1)) | ||
48 | if test $pies_stop_spinner -gt 3; then | ||
49 | kill `cat $pidfile` | ||
50 | echo >&2 "timed out waiting for shutdown" | ||
51 | fi | ||
52 | done]) | ||
53 | |||
54 | AT_INIT | ||
55 | |||
56 | AT_TESTED([pies]) | ||
57 | |||
58 | AT_BANNER([Initial]) | ||
59 | m4_include([version.at]) | ||
60 | m4_include([control.at]) | ||
61 | AT_BANNER([Components]) | ||
62 | m4_include([respawn.at]) | ||
63 | m4_include([redirect.at]) | ||
64 | m4_include([ret-exec.at]) | ||
65 | m4_include([ret-notify.at]) | ||
diff --git a/tests/version.at b/tests/version.at new file mode 100644 index 0000000..31debce --- a/dev/null +++ b/tests/version.at | |||
@@ -0,0 +1,28 @@ | |||
1 | # This file is part of GNU pies testsuite. -*- Autotest -*- | ||
2 | # Copyright (C) 2016 Sergey Poznyakoff | ||
3 | # | ||
4 | # GNU pies is free software; you can redistribute it and/or modify | ||
5 | # it under the terms of the GNU General Public License as published by | ||
6 | # the Free Software Foundation; either version 3, or (at your option) | ||
7 | # any later version. | ||
8 | # | ||
9 | # GNU pies is distributed in the hope that it will be useful, | ||
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | # GNU General Public License for more details. | ||
13 | # | ||
14 | # You should have received a copy of the GNU General Public License | ||
15 | # along with GNU pies. If not, see <http://www.gnu.org/licenses/>. | ||
16 | |||
17 | AT_SETUP([GNU pies version]) | ||
18 | |||
19 | AT_CHECK([pies --version | sed '1{s/ *[\[.*\]]//;q}' ], | ||
20 | [0], | ||
21 | [pies (AT_PACKAGE_NAME) AT_PACKAGE_VERSION | ||
22 | ], | ||
23 | [], | ||
24 | [PIES_XFAIL_MSG([WARNING: Not using the proper version, *all* checks dubious...]) | ||
25 | ], | ||
26 | [rm -f $[]XFAILFILE]) | ||
27 | |||
28 | AT_CLEANUP | ||