summaryrefslogtreecommitdiffabout
path: root/tests
authorSergey Poznyakoff <gray@gnu.org>2019-05-24 14:07:22 (GMT)
committer Sergey Poznyakoff <gray@gnu.org>2019-05-24 14:10:34 (GMT)
commita8d45eff28e7e186d0749e3e9cf980a23d93231e (patch) (unidiff)
tree50eb85966b6d87f73128728dab876e36dcc67799 /tests
parent2ba31eb953d18bb818a87caddcbca80bc8a1d37d (diff)
downloadpies-a8d45eff28e7e186d0749e3e9cf980a23d93231e.tar.gz
pies-a8d45eff28e7e186d0749e3e9cf980a23d93231e.tar.bz2
Implement shutdown components
* src/pies.h: Update comment. * src/progman.c (register_prog0): Register shutdown components in disabled state. (program_shutdown): New function. (progman_stop): Call program_shutdown. * tests/shutdown.at: New test. * tests/Makefile.am: Add new test. * tests/testsuite.at: Likewise. * tests/aux/startup: Rename to tests/aux/touchfile * tests/startup.at: Reflect the change.
Diffstat (limited to 'tests') (more/less context) (ignore whitespace changes)
-rw-r--r--tests/Makefile.am3
-rwxr-xr-xtests/aux/touchfile (renamed from tests/aux/startup)0
-rw-r--r--tests/shutdown.at58
-rw-r--r--tests/startup.at4
-rw-r--r--tests/testsuite.at1
5 files changed, 63 insertions, 3 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index b2f2719..b404ed4 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -18,7 +18,7 @@ AUXTOOLS = \
18 aux/respawn\ 18 aux/respawn\
19 aux/retcode\ 19 aux/retcode\
20 aux/mailer\ 20 aux/mailer\
21 aux/startup 21 aux/touchfile
22 22
23EXTRA_DIST = $(TESTSUITE_AT) testsuite package.m4 $(AUXTOOLS) 23EXTRA_DIST = $(TESTSUITE_AT) testsuite package.m4 $(AUXTOOLS)
24DISTCLEANFILES = atconfig $(check_SCRIPTS) 24DISTCLEANFILES = atconfig $(check_SCRIPTS)
@@ -53,6 +53,7 @@ TESTSUITE_AT = \
53 ret-exec.at\ 53 ret-exec.at\
54 ret-notify.at\ 54 ret-notify.at\
55 startup.at\ 55 startup.at\
56 shutdown.at\
56 version.at 57 version.at
57 58
58TESTSUITE = $(srcdir)/testsuite 59TESTSUITE = $(srcdir)/testsuite
diff --git a/tests/aux/startup b/tests/aux/touchfile
index b9d92a3..b9d92a3 100755
--- a/tests/aux/startup
+++ b/tests/aux/touchfile
diff --git a/tests/shutdown.at b/tests/shutdown.at
new file mode 100644
index 0000000..79bec37
--- a/dev/null
+++ b/tests/shutdown.at
@@ -0,0 +1,58 @@
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([Shutdown components])
18
19AT_CHECK([
20PIES_XFAIL_CHECK
21PIES_CONTROL_INIT
22comp_pid_file=$PWD/comp.pid
23
24cat > pies.conf <<_EOT
25component s {
26 mode shutdown;
27 command "$auxdir/touchfile $PWD 0 shutdown";
28}
29
30component test {
31 mode respawn;
32 command "$auxdir/respawn -append -pid $comp_pid_file";
33}
34_EOT
35
36pies --config-file control.conf --config-file pies.conf
37
38n=0
39while :
40do
41 if test -f $comp_pid_file; then
42 break
43 fi
44 sleep 1
45 n=$(($n + 1))
46 if test $n -gt 10; then
47 echo >&2 "timed out"
48 break
49 fi
50done
51
52PIES_STOP
53
54test -f shutdown
55])
56
57AT_CLEANUP
58
diff --git a/tests/startup.at b/tests/startup.at
index 72017ce..440c249 100644
--- a/tests/startup.at
+++ b/tests/startup.at
@@ -24,12 +24,12 @@ comp_pid_file=$PWD/comp.pid
24cat > pies.conf <<_EOT 24cat > pies.conf <<_EOT
25component b1 { 25component b1 {
26 mode startup; 26 mode startup;
27 command "$auxdir/startup $PWD 1 b1"; 27 command "$auxdir/touchfile $PWD 1 b1";
28} 28}
29 29
30component b2 { 30component b2 {
31 mode startup; 31 mode startup;
32 command "$auxdir/startup $PWD 2 b2"; 32 command "$auxdir/touchfile $PWD 2 b2";
33} 33}
34 34
35component test { 35component test {
diff --git a/tests/testsuite.at b/tests/testsuite.at
index 2a1167d..6775ee7 100644
--- a/tests/testsuite.at
+++ b/tests/testsuite.at
@@ -66,3 +66,4 @@ m4_include([redirect.at])
66m4_include([ret-exec.at]) 66m4_include([ret-exec.at])
67m4_include([ret-notify.at]) 67m4_include([ret-notify.at])
68m4_include([startup.at]) 68m4_include([startup.at])
69m4_include([shutdown.at])

Return to:

Send suggestions and report system problems to the System administrator.