diff options
Diffstat (limited to 'tests/startup.at')
-rw-r--r-- | tests/startup.at | 84 |
1 files changed, 84 insertions, 0 deletions
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 | |||
17 | AT_SETUP([Startup 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 b1 { | ||
26 | mode startup; | ||
27 | command "$auxdir/startup $PWD 1 b1"; | ||
28 | } | ||
29 | |||
30 | component b2 { | ||
31 | mode startup; | ||
32 | command "$auxdir/startup $PWD 2 b2"; | ||
33 | } | ||
34 | |||
35 | component test { | ||
36 | mode respawn; | ||
37 | command "$auxdir/respawn -append -pid $comp_pid_file"; | ||
38 | } | ||
39 | _EOT | ||
40 | |||
41 | pies --config-file control.conf --config-file pies.conf | ||
42 | |||
43 | n=0 | ||
44 | res= | ||
45 | b1= | ||
46 | b2= | ||
47 | while : | ||
48 | do | ||
49 | echo "n=$n" >> tracefile | ||
50 | if test -z "$b1" && test -f b1; then | ||
51 | res="${res}b1" | ||
52 | b1=1 | ||
53 | echo "got b1" >> tracefile | ||
54 | fi | ||
55 | if test -z "$b2" && test -f b2; then | ||
56 | res="${res}b2" | ||
57 | b2=1 | ||
58 | echo "got b2" >> tracefile | ||
59 | fi | ||
60 | if test -f $comp_pid_file; then | ||
61 | echo "got pidfile" >> tracefile | ||
62 | res="${res}pid" | ||
63 | break | ||
64 | fi | ||
65 | sleep 1 | ||
66 | n=$(($n + 1)) | ||
67 | if test $n -gt 10; then | ||
68 | echo >&2 "timed out" | ||
69 | break | ||
70 | fi | ||
71 | done | ||
72 | |||
73 | PIES_STOP | ||
74 | case $res in | ||
75 | b1b2pid|b2b1pid) echo b1b2pid;; | ||
76 | *) echo $res | ||
77 | esac | ||
78 | ], | ||
79 | [0], | ||
80 | [b1b2pid | ||
81 | ]) | ||
82 | |||
83 | AT_CLEANUP | ||
84 | |||