aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2019-06-12 11:08:22 +0300
committerSergey Poznyakoff <gray@gnu.org>2019-06-12 11:15:51 +0300
commitf5c72b5e74ea7aaf1375f763f977e3249c6b7fc4 (patch)
tree22efbd43e8215666e7d7391193e4030d4354342e /tests
parent07e7ee3d732b60e0b7f5b242bbfb0cdec8e99e7f (diff)
downloadpies-f5c72b5e74ea7aaf1375f763f977e3249c6b7fc4.tar.gz
pies-f5c72b5e74ea7aaf1375f763f977e3249c6b7fc4.tar.bz2
Check accept components and inet built-in services.
* src/comp.c (component_verify,component_finish): Fix check for the presense of the "command" statement. * src/pies.c (component_keywords): Reorder some entries for the consistency of config-help output. * tests/.gitignore: Add new files. * tests/Makefile.am: Add new tests and noinst programs. * tests/accept.at: New test. * tests/builtin.at: New test. * tests/chargen.c: New file. * tests/readtime.c: New file. * tests/recvfd.c: Rewrite for testing both accept and pass-fd components. * tests/passfd.at: Pass -s option to recvfd * tests/testsuite.at: Add new tests. * tests/lines.c: Minor changes. * tests/nt.c: Minor changes. * tests/to.c: Minor changes.
Diffstat (limited to 'tests')
-rw-r--r--tests/.gitignore2
-rw-r--r--tests/Makefile.am7
-rw-r--r--tests/accept.at54
-rw-r--r--tests/builtin.at131
-rw-r--r--tests/chargen.c109
-rw-r--r--tests/lines.c17
-rw-r--r--tests/nt.c4
-rw-r--r--tests/passfd.at2
-rw-r--r--tests/readtime.c161
-rw-r--r--tests/recvfd.c55
-rw-r--r--tests/testsuite.at2
-rw-r--r--tests/to.c3
12 files changed, 526 insertions, 21 deletions
diff --git a/tests/.gitignore b/tests/.gitignore
index 7d2613a..43d3848 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -6,6 +6,8 @@ package.m4
6testsuite 6testsuite
7testsuite.dir 7testsuite.dir
8testsuite.log 8testsuite.log
9to 9to
10nt 10nt
11recvfd 11recvfd
12readtime
13chargen
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 1fe78dc..4631a2c 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -46,12 +46,14 @@ $(srcdir)/package.m4: $(top_srcdir)/configure.ac
46## ------------ ## 46## ------------ ##
47## Test suite. ## 47## Test suite. ##
48## ------------ ## 48## ------------ ##
49 49
50TESTSUITE_AT = \ 50TESTSUITE_AT = \
51 testsuite.at\ 51 testsuite.at\
52 accept.at\
53 builtin.at\
52 control.at\ 54 control.at\
53 cyclic.at\ 55 cyclic.at\
54 env.at\ 56 env.at\
55 envop.at\ 57 envop.at\
56 inet.at\ 58 inet.at\
57 maxinst.at\ 59 maxinst.at\
@@ -65,23 +67,24 @@ TESTSUITE_AT = \
65 shutdown.at\ 67 shutdown.at\
66 version.at 68 version.at
67 69
68TESTSUITE = $(srcdir)/testsuite 70TESTSUITE = $(srcdir)/testsuite
69M4=m4 71M4=m4
70 72
71noinst_PROGRAMS = envtest to lines nt recvfd 73noinst_PROGRAMS = envtest to lines nt recvfd readtime chargen
72nt_SOURCES = nt.c iobuf.h 74nt_SOURCES = nt.c iobuf.h
73AM_CPPFLAGS = \ 75AM_CPPFLAGS = \
74 -I$(top_srcdir)/lib\ 76 -I$(top_srcdir)/lib\
75 -I$(top_srcdir)/gnu\ 77 -I$(top_srcdir)/gnu\
76 -I$(top_builddir)/gnu\ 78 -I$(top_builddir)/gnu\
77 @GRECS_INCLUDES@ 79 @GRECS_INCLUDES@
78 80
79LDADD = \ 81LDADD = \
80 ../lib/libpies.a\ 82 ../lib/libpies.a\
81 @GRECS_LDADD@ 83 @GRECS_LDADD@\
84 ../gnu/libgnu.a
82 85
83AUTOTEST = $(AUTOM4TE) --language=autotest 86AUTOTEST = $(AUTOM4TE) --language=autotest
84$(TESTSUITE): package.m4 $(TESTSUITE_AT) 87$(TESTSUITE): package.m4 $(TESTSUITE_AT)
85 $(AM_V_GEN)$(AUTOTEST) -I $(srcdir) testsuite.at -o $@.tmp 88 $(AM_V_GEN)$(AUTOTEST) -I $(srcdir) testsuite.at -o $@.tmp
86 $(AM_V_at)mv $@.tmp $@ 89 $(AM_V_at)mv $@.tmp $@
87 90
diff --git a/tests/accept.at b/tests/accept.at
new file mode 100644
index 0000000..f76a05a
--- /dev/null
+++ b/tests/accept.at
@@ -0,0 +1,54 @@
1# This file is part of GNU pies testsuite. -*- Autotest -*-
2# Copyright (C) 2019 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/>.
16AT_SETUP([accept component])
17AT_CHECK([
18PIES_XFAIL_CHECK
19PIES_CONTROL_INIT
20
21AT_DATA([input],
22[now is
23the time
24stop
25])
26
27: ${PIES_TEST_INET_SOCKET:=unix://$PWD/in.sock}
28
29cat > pies.conf <<_EOT
30component pfd {
31 command "recvfd $auxdir/in.test $PWD/inlog";
32 mode accept;
33 socket "$PIES_TEST_INET_SOCKET";
34 stderr file "$PWD/log.err";
35}
36component controller {
37 command "nt $PIES_TEST_INET_SOCKET -i input";
38}
39_EOT
40
41set -e
42to 10 \
43 pies --foreground --stderr \
44 --config-file control.conf --config-file pies.conf --debug 1 2>errlog
45
46cat inlog
47cat log.err >&2
48],
49[0],
50[now is
51the time
52stop
53])
54AT_CLEANUP \ No newline at end of file
diff --git a/tests/builtin.at b/tests/builtin.at
new file mode 100644
index 0000000..40f65fa
--- /dev/null
+++ b/tests/builtin.at
@@ -0,0 +1,131 @@
1# This file is part of GNU pies testsuite. -*- Autotest -*-
2# Copyright (C) 2016-2019 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/>.
16AT_BANNER([inetd built-in services])
17
18# IT_BUILTIN([SERVICE],[INPUT],[OUTPUT])
19m4_define([IT_BUILTIN],
20[AT_SETUP([$1])
21AT_KEYWORDS([inetd builtin internal $1])
22AT_CHECK([
23PIES_XFAIL_CHECK
24PIES_CONTROL_INIT
25AT_DATA([input],
26[$2])
27m4_if([$1],[qotd],[AT_DATA([qotd],[$3])])
28: ${PIES_TEST_INET_SOCKET:=unix://$PWD/in.sock}
29cat > pies.conf <<_EOT
30m4_if([$1],[qotd],[qotd-file "$PWD/qotd";
31])
32component in {
33 mode inetd;
34 socket "$PIES_TEST_INET_SOCKET";
35 flags internal;
36 service $1;
37 stderr file "$PWD/log.err";
38}
39component controller {
40 command "nt $PIES_TEST_INET_SOCKET -i input -o output";
41 return-code * {
42 action disable;
43 exec "piesctl --url '$PIES_CTLSOCK' --no-netrc shutdown";
44 }
45}
46_EOT
47set -e
48to 10 \
49 pies --foreground --stderr \
50 --config-file control.conf --config-file pies.conf --debug 1 2>errlog
51
52cat output m4_if([$1],[qotd],[| tr -d '\r'])
53cat log.err >&2
54],
55[0],
56[$3])
57AT_CLEANUP
58])
59
60# IT_SPECIAL(SERVICE,COMMAND)
61m4_define([IT_SPECIAL],
62[AT_SETUP([$1])
63AT_KEYWORDS([inetd builtin internal $1])
64AT_CHECK([
65PIES_XFAIL_CHECK
66PIES_CONTROL_INIT
67: ${PIES_TEST_INET_SOCKET:=unix://$PWD/in.sock}
68cat > pies.conf <<_EOT
69component in {
70 mode inetd;
71 socket "$PIES_TEST_INET_SOCKET";
72 flags internal;
73 service $1;
74 stderr file "$PWD/in.err";
75}
76component controller {
77 command "$2 '$PIES_TEST_INET_SOCKET'";
78 stderr file "$PWD/controller.err";
79 return-code * {
80 action disable;
81 exec "echo \$PIES_STATUS > $PWD/status ; piesctl --url '$PIES_CTLSOCK' --no-netrc shutdown";
82 }
83}
84_EOT
85set -e
86to 10 \
87 pies --foreground --stderr \
88 --config-file control.conf --config-file pies.conf --debug 1 2>errlog
89
90if test -s in.err; then
91 echo >&2 "in.err:"
92 cat controller.err >&2
93fi
94if test -s controller.err; then
95 echo >&2 "controller.err:"
96 cat controller.err >&2
97fi
98exit `cat status`
99],
100[0])