aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2019-05-24 12:45:25 +0300
committerSergey Poznyakoff <gray@gnu.org>2019-05-24 13:50:39 +0300
commit6dd0ec08db301984b8f8f9082f28006d5915c183 (patch)
treee916ad37fbd3cbcaf85103667f28e0d47f3c2e45 /tests
parent2a646ee7cbbcb6f4bbd8f38bb3c1e1418550f3fc (diff)
downloadpies-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')
-rw-r--r--tests/Makefile.am9
-rw-r--r--tests/atlocal.in2
-rwxr-xr-xtests/aux/mailer (renamed from tests/mailer)0
-rwxr-xr-xtests/aux/respawn (renamed from tests/respawn)0
-rwxr-xr-xtests/aux/retcode (renamed from tests/retcode)0
-rwxr-xr-xtests/aux/startup7
-rw-r--r--tests/redirect.at2
-rw-r--r--tests/respawn.at2
-rw-r--r--tests/ret-exec.at4
-rw-r--r--tests/ret-notify.at6
-rw-r--r--tests/startup.at84
-rw-r--r--tests/testsuite.at1
12 files changed, 108 insertions, 9 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 447104b..b2f2719 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -11,13 +11,19 @@
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details. 12# GNU General Public License for more details.
13# 13#
14# You should have received a copy of the GNU General Public License 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/>. 15# along with GNU Pies. If not, see <http://www.gnu.org/licenses/>.
16 16
17EXTRA_DIST = $(TESTSUITE_AT) testsuite package.m4 respawn retcode mailer 17AUXTOOLS = \
18 aux/respawn\
19 aux/retcode\
20 aux/mailer\
21 aux/startup
22
23EXTRA_DIST = $(TESTSUITE_AT) testsuite package.m4 $(AUXTOOLS)
18DISTCLEANFILES = atconfig $(check_SCRIPTS) 24DISTCLEANFILES = atconfig $(check_SCRIPTS)
19MAINTAINERCLEANFILES = Makefile.in $(TESTSUITE) 25MAINTAINERCLEANFILES = Makefile.in $(TESTSUITE)
20 26
21## ------------ ## 27## ------------ ##
22## package.m4. ## 28## package.m4. ##
23## ------------ ## 29## ------------ ##
@@ -43,12 +49,13 @@ TESTSUITE_AT = \
43 control.at\ 49 control.at\
44 cyclic.at\ 50 cyclic.at\
45 respawn.at\ 51 respawn.at\
46 redirect.at\ 52 redirect.at\
47 ret-exec.at\ 53 ret-exec.at\
48 ret-notify.at\ 54 ret-notify.at\
55 startup.at\
49 version.at 56 version.at
50 57
51TESTSUITE = $(srcdir)/testsuite 58TESTSUITE = $(srcdir)/testsuite
52M4=m4 59M4=m4
53 60
54AUTOTEST = $(AUTOM4TE) --language=autotest 61AUTOTEST = $(AUTOM4TE) --language=autotest
diff --git a/tests/atlocal.in b/tests/atlocal.in
index 9069bbd..1992b80 100644
--- a/tests/atlocal.in
+++ b/tests/atlocal.in
@@ -1,10 +1,10 @@
1# @configure_input@ -*- shell-script -*- 1# @configure_input@ -*- shell-script -*-
2# Configurable variable values for GNU Pies test suite. 2# Configurable variable values for GNU Pies test suite.
3# Copyright (C) 2016-2019 Sergey Poznyakoff 3# Copyright (C) 2016-2019 Sergey Poznyakoff
4 4
5PATH=@abs_builddir@:@abs_top_builddir@/src:$srcdir:$PATH 5PATH=@abs_builddir@:@abs_top_builddir@/src:$srcdir:$PATH
6XFAILFILE=$abs_builddir/.badversion 6XFAILFILE=$abs_builddir/.badversion
7 7auxdir="$abs_srcdir/aux"
8trimws() { 8trimws() {
9 sed 's/[ ][ ]*$//' 9 sed 's/[ ][ ]*$//'
10} 10}
diff --git a/tests/mailer b/tests/aux/mailer
index f832ff5..f832ff5 100755
--- a/tests/mailer
+++ b/tests/aux/mailer
diff --git a/tests/respawn b/tests/aux/respawn
index 11d59f6..11d59f6 100755
--- a/tests/respawn
+++ b/tests/aux/respawn
diff --git a/tests/retcode b/tests/aux/retcode
index b827ba9..b827ba9 100755
--- a/tests/retcode
+++ b/tests/aux/retcode
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 @@
1#!/bin/sh
2dir=${1:?}
3time=${2:?}
4tag=${3:?}
5
6touch $dir/$tag
7sleep $time
diff --git a/tests/redirect.at b/tests/redirect.at
index 9e53ba2..3a8cca7 100644
--- a/tests/redirect.at
+++ b/tests/redirect.at
@@ -21,13 +21,13 @@ PIES_XFAIL_CHECK
21PIES_CONTROL_INIT 21PIES_CONTROL_INIT
22comp_pid_file=$PWD/comp.pid 22comp_pid_file=$PWD/comp.pid
23outfile=$PWD/out 23outfile=$PWD/out
24cat > pies.conf <<_EOT 24cat > pies.conf <<_EOT
25component test { 25component test {
26 mode respawn; 26 mode respawn;
27 command "$abs_srcdir/respawn -tag respawn -append -pid $comp_pid_file"; 27 command "$auxdir/respawn -tag respawn -append -pid $comp_pid_file";
28 stdout file "$outfile"; 28 stdout file "$outfile";
29} 29}
30_EOT 30_EOT
31 31
32pies --config-file control.conf --config-file pies.conf 32pies --config-file control.conf --config-file pies.conf
33 33
diff --git a/tests/respawn.at b/tests/respawn.at
index 8d72c40..4a8e3a7 100644
--- a/tests/respawn.at
+++ b/tests/respawn.at
@@ -20,13 +20,13 @@ AT_CHECK([
20PIES_XFAIL_CHECK 20PIES_XFAIL_CHECK
21PIES_CONTROL_INIT 21PIES_CONTROL_INIT
22comp_pid_file=$PWD/comp.pid 22comp_pid_file=$PWD/comp.pid
23cat > pies.conf <<_EOT 23cat > pies.conf <<_EOT
24component test { 24component test {
25 mode respawn; 25 mode respawn;
26 command "$abs_srcdir/respawn -append -pid $comp_pid_file"; 26 command "$auxdir/respawn -append -pid $comp_pid_file";
27} 27}
28_EOT 28_EOT
29 29
30pies --config-file control.conf --config-file pies.conf 30pies --config-file control.conf --config-file pies.conf
31 31
32n=0 32n=0
diff --git a/tests/ret-exec.at b/tests/ret-exec.at
index bf2c1a4..0b3d716 100644
--- a/tests/ret-exec.at
+++ b/tests/ret-exec.at
@@ -23,16 +23,16 @@ PIES_CONTROL_INIT
23comp_pid_file=$PWD/comp.pid 23comp_pid_file=$PWD/comp.pid
24report_file=$PWD/report 24report_file=$PWD/report
25cat > pies.conf <<_EOT 25cat > pies.conf <<_EOT
26component test { 26component test {
27 mode respawn; 27 mode respawn;
28 return-code 10 { 28 return-code 10 {
29 exec "$abs_srcdir/retcode $report_file"; 29 exec "$auxdir/retcode $report_file";
30 action disable; 30 action disable;
31 } 31 }
32 command "$abs_srcdir/respawn -sleep 2 -pid $comp_pid_file -exit 10"; 32 command "$auxdir/respawn -sleep 2 -pid $comp_pid_file -exit 10";
33} 33}
34_EOT 34_EOT
35 35
36>$report_file 36>$report_file
37 37
38pies --config-file control.conf --config-file pies.conf 38pies --config-file control.conf --config-file pies.conf
diff --git a/tests/ret-notify.at b/tests/ret-notify.at
index d1a7f39..a7768aa 100644
--- a/tests/ret-notify.at
+++ b/tests/ret-notify.at
@@ -19,21 +19,21 @@ AT_KEYWORDS([ret-notify])
19 19
20AT_CHECK([ 20AT_CHECK([
21PIES_XFAIL_CHECK 21PIES_XFAIL_CHECK
22PIES_CONTROL_INIT 22PIES_CONTROL_INIT
23report_file=$PWD/report 23report_file=$PWD/report
24cat > pies.conf <<_EOT 24cat > pies.conf <<_EOT
25mailer-program "$abs_srcdir/mailer"; 25mailer-program "$auxdir/mailer";
26mailer-command-line "$abs_srcdir/mailer $report_file"; 26mailer-command-line "$auxdir/mailer $report_file";
27component test { 27component test {
28 mode respawn; 28 mode respawn;
29 return-code 10 { 29 return-code 10 {
30 notify root; 30 notify root;
31 action disable; 31 action disable;
32 } 32 }
33 command "$abs_srcdir/respawn -sleep 2 -exit 10"; 33 command "$auxdir/respawn -sleep 2 -exit 10";
34} 34}
35_EOT 35_EOT
36 36
37>$report_file 37>$report_file
38 38
39pies --config-file control.conf --config-file pies.conf 39pies --config-file control.conf --config-file pies.conf
diff --git a/tests/startup.at b/tests/startup.at
new file mode 100644
index 0000000..72017ce
--- /dev/null
+++ b/tests/startup.at
@@ -0,0 +1,84 @@
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
17AT_SETUP([Startup components])
18
19AT_CHECK([
20PIES_XFAIL_CHECK
21PIES_CONTROL_INIT
22comp_pid_file=$PWD/comp.pid
23
24cat > pies.conf <<_EOT
25component b1 {
26 mode startup;
27 command "$auxdir/startup $PWD 1 b1";
28}
29
30component b2 {
31 mode startup;
32 command "$auxdir/startup $PWD 2 b2";
33}
34