aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
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
@@ -9,3 +9,5 @@ testsuite.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
@@ -49,6 +49,8 @@ $(srcdir)/package.m4: $(top_srcdir)/configure.ac
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\
@@ -68,7 +70,7 @@ TESTSUITE_AT = \
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\
@@ -78,7 +80,8 @@ AM_CPPFLAGS = \
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)
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])
101AT_CLEANUP
102])
103
104# ##
105IT_BUILTIN([echo],
106[one
107two
108three
109],
110[one
111two
112three
113])
114
115IT_BUILTIN([discard],
116[one
117two
118three
119])
120
121IT_SPECIAL([time],[readtime])
122IT_SPECIAL([daytime],[readtime -H])
123IT_SPECIAL([chargen],[chargen])
124IT_BUILTIN([qotd],[],
125[A useful debugging and measurement tool is a quote of the day service.
126A quote of the day service simply sends a short message without regard
127to the input.
128])
129
130m4_popdef([IT_BUILTIN])
131m4_popdef([IT_SPECIAL])
diff --git a/tests/chargen.c b/tests/chargen.c
new file mode 100644
index 0000000..a3b3290
--- /dev/null
+++ b/tests/chargen.c
@@ -0,0 +1,109 @@
1/* This file is part of GNU Pies testsuite.
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