summaryrefslogtreecommitdiffabout
path: root/tests/builtin.at
Side-by-side diff
Diffstat (limited to 'tests/builtin.at') (more/less context) (ignore whitespace changes)
-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
--- a/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.