Debian Codegraph @

tests/t/lib/ProFTPD/Tests/Signals/TERM.pm

raw
1 package ProFTPD::Tests::Signals::TERM;
2
3 use lib qw(t/lib);
4 use base qw(ProFTPD::TestSuite::Child);
5 use strict;
6
7 use File::Spec;
8 use IO::Handle;
9
10 use ProFTPD::TestSuite::FTP;
11 use ProFTPD::TestSuite::Utils qw(:auth :config :running :test :testsuite);
12
13 $| = 1;
14
15 my $order = 0;
16
17 my $TESTS = {
18 term_daemon_ok => {
19 order => ++$order,
20 test_class => [qw(bug)],
21 },
22 };
23
24 sub new {
25 return shift()->SUPER::new(@_);
26 }
27
28 sub list_tests {
29 return testsuite_get_runnable_tests($TESTS);
30 }
31
32 sub term_daemon_ok {
33 my $self = shift;
34 my $tmpdir = $self->{tmpdir};
35
36 my $config_file = "$tmpdir/signals.conf";
37 my $pid_file = File::Spec->rel2abs("$tmpdir/signals.pid");
38 my $scoreboard_file = File::Spec->rel2abs("$tmpdir/signals.scoreboard");
39
40 my $log_file = File::Spec->rel2abs('tests.log');
41
42 my $config = {
43 PidFile => $pid_file,
44 ScoreboardFile => $scoreboard_file,
45 SystemLog => $log_file,
46
47 IfModules => {
48 'mod_delay.c' => {
49 DelayEngine => 'off',
50 },
51 },
52 };
53
54 my ($port, $config_user, $config_group) = config_write($config_file, $config);
55
56 my $ex;
57
58 # Start server
59 server_start($config_file);
60
61 # Allow a short interval between startup and shutdown
62 sleep(1);
63
64 # Stop server
65 server_stop($pid_file, 1);
66
67 # Make sure that the pid file has been removed by the server as part of
68 # its shutdown procedures. We need the delay since proftpd handles
69 # signals synchronously; it make take a short while for proftpd to
70 # process the SIGTERM and shut down all of the way.
71
72 sleep(1);
73
74 if (-e $pid_file) {
75 die("Unclean shutdown: PidFile $pid_file still present");
76 }
77
78 if (-e $scoreboard_file) {
79 die("Unclean shutdown: ScoreboardFile $scoreboard_file still present");
80 }
81
82 if ($ex) {
83 die($ex);
84 }
85
86 unlink($log_file);
87 }
88
89 1;