diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2019-05-24 12:45:25 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2019-05-24 13:50:39 +0300 |
commit | 6dd0ec08db301984b8f8f9082f28006d5915c183 (patch) | |
tree | e916ad37fbd3cbcaf85103667f28e0d47f3c2e45 /tests/aux | |
parent | 2a646ee7cbbcb6f4bbd8f38bb3c1e1418550f3fc (diff) | |
download | pies-6dd0ec08db301984b8f8f9082f28006d5915c183.tar.gz pies-6dd0ec08db301984b8f8f9082f28006d5915c183.tar.bz2 |
Initial implementation of "startup" components.
These are components that are run at program startup. Starting
other components is delayed until all startup components terminate.
This is similar to SysV "bootwait" components.
Upon termination, startup components are removed from the configuration.
They are not renewed upon configuratuion reload.
* src/comp.c (comp_array_remove): Remove from the depmap as well.
(component_ref_decr): Use comp_array_remove for active components
and plain component_free for inactive ones.
(component_build_depmap): Use comp_array_remove.
(component_config_commit): Special handling for pies_comp_startup
components.
* src/pies.c (modetab): New component modes: "startup" and "shutdown".
(main): Run program_init_startup.
* src/pies.h (pies_comp_mode): New modes: pies_comp_startup and
pies_comp_shutdown.
(program_init_startup): New proto.
* src/progman.c (progman_waiting_p): Return 1 if a startup component
is still running.
(program_init_startup): New function.
(progman_cleanup): Handle pies_comp_startup termination.
* src/socket.c (switch_eids): Avoid unnecessary calls to setegid
and seteuid.
* tests/atlocal.in (auxdir): New variable.
* tests/mailer: Move to tests/aux/
* tests/respawn: Move to tests/aux/
* tests/retcode: Move to tests/aux/
* tests/aux/startup: New auxiliary program.
* tests/redirect.at: Start components from $auxdir.
* tests/respawn.at: Likewise.
* tests/ret-exec.at: Likewise.
* tests/ret-notify.at: Likewise.
* tests/startup.at: New file.
* tests/testsuite.at: Include startup.at
* tests/Makefile.am: Add new tests.
Diffstat (limited to 'tests/aux')
-rwxr-xr-x | tests/aux/mailer | 7 | ||||
-rwxr-xr-x | tests/aux/respawn | 63 | ||||
-rwxr-xr-x | tests/aux/retcode | 9 | ||||
-rwxr-xr-x | tests/aux/startup | 7 |
4 files changed, 86 insertions, 0 deletions
diff --git a/tests/aux/mailer b/tests/aux/mailer new file mode 100755 index 0000000..f832ff5 --- /dev/null +++ b/tests/aux/mailer @@ -0,0 +1,7 @@ +#! /bin/sh + +exec >${1:?} +shift +echo $* +cat - + diff --git a/tests/aux/respawn b/tests/aux/respawn new file mode 100755 index 0000000..11d59f6 --- /dev/null +++ b/tests/aux/respawn @@ -0,0 +1,63 @@ +#! /bin/sh + +# usage: respawn [-append] [-stderr FILE] [-stdout FILE] [-sleep TIME] +# [-pid FILE] [-tag STRING] [-exit CODE] + +append=0 +unset name +time=10 +tag=$0 +code=0 + +while [ $# -ne 0 ] +do + arg=$1 + shift + case $arg in + -append) + append=1;; + -stderr) + name=${1:?missing argument for -stderr} + shift + if [ $append -eq 1 ]; then + exec 2>>$name + append=0 + else + exec 2>$name + fi;; + -stdout) + name=${1:?missing argument for -stdout} + shift + if [ $append -eq 1 ]; then + exec >>$name + append=0 + else + exec >$name + fi;; + -sleep) + time=${1:?missing argument for -sleep} + shift;; + -pid) + name=${1:?missing argument for -pid} + shift + if [ $append -eq 1 ]; then + echo $$ >>$name + append=0 + else + echo $$ >$name + fi;; + -tag) + tag=${1:?missing argument for -tag} + shift;; + -exit) + code=${1:?missing argument for -exit} + shift;; + *) echo >&2 "$tag: invalid argument: $arg" + exit 1 + esac +done + +echo "$tag: start" +sleep $time +echo "$tag: stop" +exit $code diff --git a/tests/aux/retcode b/tests/aux/retcode new file mode 100755 index 0000000..b827ba9 --- /dev/null +++ b/tests/aux/retcode @@ -0,0 +1,9 @@ +#! /bin/sh + +exec >${1:?} + +echo $PIES_VERSION +echo $PIES_COMPONENT +echo $PIES_PID +echo $PIES_STATUS +echo ${PIES_SIGNAL:-No signal} diff --git a/tests/aux/startup b/tests/aux/startup new file mode 100755 index 0000000..b9d92a3 --- /dev/null +++ b/tests/aux/startup @@ -0,0 +1,7 @@ +#!/bin/sh +dir=${1:?} +time=${2:?} +tag=${3:?} + +touch $dir/$tag +sleep $time |