diff options
Diffstat (limited to 'tests/ret-notify.at')
-rw-r--r-- | tests/ret-notify.at | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/tests/ret-notify.at b/tests/ret-notify.at new file mode 100644 index 0000000..2119ed5 --- /dev/null +++ b/tests/ret-notify.at | |||
@@ -0,0 +1,68 @@ | |||
1 | # This file is part of GNU pies testsuite. -*- Autotest -*- | ||
2 | # Copyright (C) 2016 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([Notify on return code]) | ||
18 | AT_KEYWORDS([ret-notify]) | ||
19 | |||
20 | AT_CHECK([ | ||
21 | PIES_XFAIL_CHECK | ||
22 | PIES_CONTROL_INIT | ||
23 | report_file=$PWD/report | ||
24 | cat > pies.conf <<_EOT | ||
25 | mailer-program "$abs_srcdir/mailer"; | ||
26 | mailer-command-line "$abs_srcdir/mailer $report_file"; | ||
27 | component test { | ||
28 | mode respawn; | ||
29 | return-code 10 { | ||
30 | notify root; | ||
31 | action disable; | ||
32 | } | ||
33 | command "$abs_srcdir/respawn -sleep 2 -exit 10"; | ||
34 | } | ||
35 | _EOT | ||
36 | |||
37 | >$report_file | ||
38 | |||
39 | pies --config-file control.conf --config-file pies.conf | ||
40 | |||
41 | n=0 | ||
42 | while test ! -s $report_file | ||
43 | do | ||
44 | sleep 1 | ||
45 | n=$(($n + 1)) | ||
46 | if test $n -gt 4; then | ||
47 | echo >&2 "timed out" | ||
48 | break | ||
49 | fi | ||
50 | done | ||
51 | sleep 1 | ||
52 | PIES_STOP | ||
53 | |||
54 | if test -f $report_file; then | ||
55 | cat $report_file | ||
56 | else | ||
57 | echo >&2 "no report file" | ||
58 | fi | ||
59 | ], | ||
60 | [0], | ||
61 | [root | ||
62 | From: <> | ||
63 | X-Agent: pies (AT_PACKAGE_NAME AT_PACKAGE_VERSION) | ||
64 | Subject: Component test exited with code 10. | ||
65 | |||
66 | ]) | ||
67 | |||
68 | AT_CLEANUP | ||