diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2019-05-24 17:07:22 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2019-05-24 17:10:34 +0300 |
commit | a8d45eff28e7e186d0749e3e9cf980a23d93231e (patch) | |
tree | 50eb85966b6d87f73128728dab876e36dcc67799 /tests/shutdown.at | |
parent | 2ba31eb953d18bb818a87caddcbca80bc8a1d37d (diff) | |
download | pies-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/shutdown.at')
-rw-r--r-- | tests/shutdown.at | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/tests/shutdown.at b/tests/shutdown.at new file mode 100644 index 0000000..79bec37 --- /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 | |||
17 | AT_SETUP([Shutdown components]) | ||
18 | |||
19 | AT_CHECK([ | ||
20 | PIES_XFAIL_CHECK | ||
21 | PIES_CONTROL_INIT | ||
22 | comp_pid_file=$PWD/comp.pid | ||
23 | |||
24 | cat > pies.conf <<_EOT | ||
25 | component s { | ||
26 | mode shutdown; | ||
27 | command "$auxdir/touchfile $PWD 0 shutdown"; | ||
28 | } | ||
29 | |||
30 | component test { | ||
31 | mode respawn; | ||
32 | command "$auxdir/respawn -append -pid $comp_pid_file"; | ||
33 | } | ||
34 | _EOT | ||
35 | |||
36 | pies --config-file control.conf --config-file pies.conf | ||
37 | |||
38 | n=0 | ||
39 | while : | ||
40 | do | ||
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 | ||
50 | done | ||
51 | |||
52 | PIES_STOP | ||
53 | |||
54 | test -f shutdown | ||
55 | ]) | ||
56 | |||
57 | AT_CLEANUP | ||
58 | |||