# 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 . 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]) # IT_TCPMUX([KW],[ID],[INPUT],[OUTPUT]) m4_define([IT_TCPMUX], [AT_SETUP([tcpmux: $1]) AT_KEYWORDS([inetd builtin internal tcpmux $1]) AT_CHECK([ PIES_XFAIL_CHECK PIES_CONTROL_INIT : ${PIES_TEST_INET_SOCKET:=unix://$PWD/in.sock} m4_if([$3],[],[],[AT_DATA([input],[$3])]) cat > pies.conf <<_EOT component master { socket "$PIES_TEST_INET_SOCKET"; service tcpmux; flags internal; } component one { service one; flags (tcpmuxplus); tcpmux-master master; command "$auxdir/in.test $PWD/one.log"; stderr file "$PWD/one.err"; } component two { service two; flags (tcpmuxplus); tcpmux-master master; command "$auxdir/in.test $PWD/two.log"; stderr file "$PWD/two.err"; } component test { command "nt -t [$2]m4_if([$3],[],,[ -i $PWD/input]) -o $PWD/test.out '$PIES_TEST_INET_SOCKET'"; stderr file "$PWD/test.err"; return-code * { action disable; exec "piesctl --no-netrc --url=$PIES_CTLSOCK shutdown"; } } _EOT set -e to 10 \ pies --foreground --stderr \ --config-file control.conf --config-file pies.conf --debug 1 2>errlog for err in one.err two.err test.err do if test -s $err; then echo "$err:" cat $err fi done >&2 if test -f test.out; then cat test.out | tr -d '\r' fi ], [0], [$4]) AT_CLEANUP ]) IT_TCPMUX([help],[help],[], [one two ]) IT_TCPMUX([service],[one], [Test one quit ], [OK Test one ]) m4_popdef([IT_TCPMUX])