aboutsummaryrefslogtreecommitdiff
path: root/tests/builtin.at
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/builtin.at
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/builtin.at')
-rw-r--r--tests/builtin.at131
1 files changed, 131 insertions, 0 deletions
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 @@
+# This file is part of GNU pies testsuite. -*- Autotest -*-
+# Copyright (C) 2016-2019 Sergey Poznyakoff
+#
+# GNU pies is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU pies is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU pies. If not, see <http://www.gnu.org/licenses/>.
+AT_BANNER([inetd built-in services])
+
+# IT_BUILTIN([SERVICE],[INPUT],[OUTPUT])
+m4_define([IT_BUILTIN],
+[AT_SETUP([$1])
+AT_KEYWORDS([inetd builtin internal $1])
+AT_CHECK([
+PIES_XFAIL_CHECK
+PIES_CONTROL_INIT
+AT_DATA([input],
+[$2])
+m4_if([$1],[qotd],[AT_DATA([qotd],[$3])])
+: ${PIES_TEST_INET_SOCKET:=unix://$PWD/in.sock}
+cat > pies.conf <<_EOT
+m4_if([$1],[qotd],[qotd-file "$PWD/qotd";
+])
+component in {
+ mode inetd;
+ socket "$PIES_TEST_INET_SOCKET";
+ flags internal;
+ service $1;
+ stderr file "$PWD/log.err";
+}
+component controller {
+ command "nt $PIES_TEST_INET_SOCKET -i input -o output";
+ return-code * {
+ action disable;
+ exec "piesctl --url '$PIES_CTLSOCK' --no-netrc shutdown";
+ }
+}
+_EOT
+set -e
+to 10 \
+ pies --foreground --stderr \
+ --config-file control.conf --config-file pies.conf --debug 1 2>errlog
+
+cat output m4_if([$1],[qotd],[| tr -d '\r'])
+cat log.err >&2
+],
+[0],
+[$3])
+AT_CLEANUP
+])
+
+# IT_SPECIAL(SERVICE,COMMAND)
+m4_define([IT_SPECIAL],
+[AT_SETUP([$1])
+AT_KEYWORDS([inetd builtin internal $1])
+AT_CHECK([
+PIES_XFAIL_CHECK
+PIES_CONTROL_INIT
+: ${PIES_TEST_INET_SOCKET:=unix://$PWD/in.sock}
+cat > pies.conf <<_EOT
+component in {
+ mode inetd;
+ socket "$PIES_TEST_INET_SOCKET";
+ flags internal;
+ service $1;
+ stderr file "$PWD/in.err";
+}
+component controller {
+ command "$2 '$PIES_TEST_INET_SOCKET'";
+ stderr file "$PWD/controller.err";
+ return-code * {
+ action disable;
+ exec "echo \$PIES_STATUS > $PWD/status ; piesctl --url '$PIES_CTLSOCK' --no-netrc shutdown";
+ }
+}
+_EOT
+set -e
+to 10 \
+ pies --foreground --stderr \
+ --config-file control.conf --config-file pies.conf --debug 1 2>errlog
+
+if test -s in.err; then
+ echo >&2 "in.err:"
+ cat controller.err >&2
+fi
+if test -s controller.err; then
+ echo >&2 "controller.err:"
+ cat controller.err >&2
+fi
+exit `cat status`
+],
+[0])
+AT_CLEANUP
+])
+
+# ##
+IT_BUILTIN([echo],
+[one
+two
+three
+],
+[one
+two
+three
+])
+
+IT_BUILTIN([discard],
+[one
+two
+three
+])
+
+IT_SPECIAL([time],[readtime])
+IT_SPECIAL([daytime],[readtime -H])
+IT_SPECIAL([chargen],[chargen])
+IT_BUILTIN([qotd],[],
+[A useful debugging and measurement tool is a quote of the day service.
+A quote of the day service simply sends a short message without regard
+to the input.
+])
+
+m4_popdef([IT_BUILTIN])
+m4_popdef([IT_SPECIAL])

Return to:

Send suggestions and report system problems to the System administrator.