diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/.gitignore | 2 | ||||
-rw-r--r-- | tests/Makefile.am | 7 | ||||
-rw-r--r-- | tests/accept.at | 54 | ||||
-rw-r--r-- | tests/builtin.at | 131 | ||||
-rw-r--r-- | tests/chargen.c | 109 | ||||
-rw-r--r-- | tests/lines.c | 17 | ||||
-rw-r--r-- | tests/nt.c | 4 | ||||
-rw-r--r-- | tests/passfd.at | 2 | ||||
-rw-r--r-- | tests/readtime.c | 161 | ||||
-rw-r--r-- | tests/recvfd.c | 55 | ||||
-rw-r--r-- | tests/testsuite.at | 2 | ||||
-rw-r--r-- | tests/to.c | 3 |
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 | |||
9 | to | 9 | to |
10 | nt | 10 | nt |
11 | recvfd | 11 | recvfd |
12 | readtime | ||
13 | chargen | ||
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 | ||
50 | TESTSUITE_AT = \ | 50 | TESTSUITE_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 = \ | |||
68 | TESTSUITE = $(srcdir)/testsuite | 70 | TESTSUITE = $(srcdir)/testsuite |
69 | M4=m4 | 71 | M4=m4 |
70 | 72 | ||
71 | noinst_PROGRAMS = envtest to lines nt recvfd | 73 | noinst_PROGRAMS = envtest to lines nt recvfd readtime chargen |
72 | nt_SOURCES = nt.c iobuf.h | 74 | nt_SOURCES = nt.c iobuf.h |
73 | AM_CPPFLAGS = \ | 75 | AM_CPPFLAGS = \ |
74 | -I$(top_srcdir)/lib\ | 76 | -I$(top_srcdir)/lib\ |
@@ -78,7 +80,8 @@ AM_CPPFLAGS = \ | |||
78 | 80 | ||
79 | LDADD = \ | 81 | LDADD = \ |
80 | ../lib/libpies.a\ | 82 | ../lib/libpies.a\ |
81 | @GRECS_LDADD@ | 83 | @GRECS_LDADD@\ |
84 | ../gnu/libgnu.a | ||
82 | 85 | ||
83 | AUTOTEST = $(AUTOM4TE) --language=autotest | 86 | AUTOTEST = $(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/>. | ||
16 | AT_SETUP([accept component]) | ||
17 | AT_CHECK([ | ||
18 | PIES_XFAIL_CHECK | ||
19 | PIES_CONTROL_INIT | ||
20 | |||
21 | AT_DATA([input], | ||
22 | [now is | ||
23 | the time | ||
24 | stop | ||
25 | ]) | ||
26 | |||
27 | : ${PIES_TEST_INET_SOCKET:=unix://$PWD/in.sock} | ||
28 | |||
29 | cat > pies.conf <<_EOT | ||
30 | component 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 | } | ||
36 | component controller { | ||
37 | command "nt $PIES_TEST_INET_SOCKET -i input"; | ||
38 | } | ||
39 | _EOT | ||
40 | |||
41 | set -e | ||
42 | to 10 \ | ||
43 | pies --foreground --stderr \ | ||
44 | --config-file control.conf --config-file pies.conf --debug 1 2>errlog | ||
45 | |||
46 | cat inlog | ||
47 | cat log.err >&2 | ||
48 | ], | ||
49 | [0], | ||
50 | [now is | ||
51 | the time | ||
52 | stop | ||
53 | ]) | ||
54 | AT_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/>. | ||
16 | AT_BANNER([inetd built-in services]) | ||
17 | |||
18 | # IT_BUILTIN([SERVICE],[INPUT],[OUTPUT]) | ||
19 | m4_define([IT_BUILTIN], | ||
20 | [AT_SETUP([$1]) | ||
21 | AT_KEYWORDS([inetd builtin internal $1]) | ||
22 | AT_CHECK([ | ||
23 | PIES_XFAIL_CHECK | ||
24 | PIES_CONTROL_INIT | ||
25 | AT_DATA([input], | ||
26 | [$2]) | ||
27 | m4_if([$1],[qotd],[AT_DATA([qotd],[$3])]) | ||
28 | : ${PIES_TEST_INET_SOCKET:=unix://$PWD/in.sock} | ||
29 | cat > pies.conf <<_EOT | ||
30 | m4_if([$1],[qotd],[qotd-file "$PWD/qotd"; | ||
31 | ]) | ||
32 | component in { | ||
33 | mode inetd; | ||
34 | socket "$PIES_TEST_INET_SOCKET"; | ||
35 | flags internal; | ||
36 | service $1; | ||
37 | stderr file "$PWD/log.err"; | ||
38 | } | ||
39 | component 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 | ||
47 | set -e | ||
48 | to 10 \ | ||
49 | pies --foreground --stderr \ | ||
50 | --config-file control.conf --config-file pies.conf --debug 1 2>errlog | ||
51 | |||
52 | cat output m4_if([$1],[qotd],[| tr -d '\r']) | ||
53 | cat log.err >&2 | ||
54 | ], | ||
55 | [0], | ||
56 | [$3]) | ||
57 | AT_CLEANUP | ||
58 | ]) | ||
59 | |||
60 | # IT_SPECIAL(SERVICE,COMMAND) | ||
61 | m4_define([IT_SPECIAL], | ||
62 | [AT_SETUP([$1]) | ||
63 | AT_KEYWORDS([inetd builtin internal $1]) | ||
64 | AT_CHECK([ | ||
65 | PIES_XFAIL_CHECK | ||
66 | PIES_CONTROL_INIT | ||
67 | : ${PIES_TEST_INET_SOCKET:=unix://$PWD/in.sock} | ||
68 | cat > pies.conf <<_EOT | ||
69 | component in { | ||
70 | mode inetd; | ||
71 | socket "$PIES_TEST_INET_SOCKET"; | ||
72 | flags internal; | ||
73 | service $1; | ||
74 | stderr file "$PWD/in.err"; | ||
75 | } | ||
76 | component 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 | ||
85 | set -e | ||
86 | to 10 \ | ||
87 | pies --foreground --stderr \ | ||
88 | --config-file control.conf --config-file pies.conf --debug 1 2>errlog | ||
89 | |||
90 | if test -s in.err; then | ||
91 | echo >&2 "in.err:" | ||
92 | cat controller.err >&2 | ||
93 | fi | ||
94 | if test -s controller.err; then | ||
95 | echo >&2 "controller.err:" | ||
96 | cat controller.err >&2 | ||
97 | fi | ||
98 | exit `cat status` | ||
99 | ], | ||
100 | [0]) | ||
101 | AT_CLEANUP | ||
102 | ]) | ||
103 | |||
104 | # ## | ||
105 | IT_BUILTIN([echo], | ||
106 | [one | ||
107 | two | ||
108 | three | ||
109 | ], | ||
110 | [one | ||
111 | two | ||
112 | three | ||
113 | ]) | ||
114 | |||
115 | IT_BUILTIN([discard], | ||
116 | [one | ||
117 | two | ||
118 | three | ||
119 | ]) | ||
120 | |||
121 | IT_SPECIAL([time],[readtime]) | ||
122 | IT_SPECIAL([daytime],[readtime -H]) | ||
123 | IT_SPECIAL([chargen],[chargen]) | ||
124 | IT_BUILTIN([qotd],[], | ||
125 | [A useful debugging and measurement tool is a quote of the day service. | ||
126 | A quote of the day service simply sends a short message without regard | ||
127 | to the input. | ||
128 | ]) | ||
129 | |||
130 | m4_popdef([IT_BUILTIN]) | ||
131 | m4_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 | ||