1 # Copyright (c) 2008-2012 Zmanda, Inc. All Rights Reserved.
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 2
6 # of the License, or (at your option) any later version.
8 # This program is distributed in the hope that it will be useful, but
9 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 # You should have received a copy of the GNU General Public License along
14 # with this program; if not, write to the Free Software Foundation, Inc.,
15 # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 # Contact information: Zmanda Inc, 465 S. Mathilda Ave., Suite 300
18 # Sunnyvale, CA 94086, USA, or: http://www.zmanda.com
20 use Test::More tests => 11;
25 use lib "@amperldir@";
27 use Installcheck::Config;
30 use Amanda::Config qw( :init :getconf config_dir_relative );
33 # set up debugging so debug output doesn't interfere with test results
34 Amanda::Debug::dbopen("installcheck");
35 Installcheck::log_test_output();
37 # and disable Debug's die() and warn() overrides
38 Amanda::Debug::disable_die_override();
40 my $Amanda_process = Amanda::Process->new(0);
42 $Amanda_process->load_ps_table();
44 like($Amanda_process->{pstable}->{$$}, qr/(Amanda_Process|perl)/,
45 "find program name for perl script");
46 is($Amanda_process->{ppid}->{$$}, getppid,
47 "load_ps_table get correct ppid for Amanda_Process");
49 #override works done by load_ps_table, override pstable
50 $Amanda_process->{pstable} = {
66 #override works done by load_ps_table, override ppid
67 $Amanda_process->{ppid} = {
84 my $log_filename = "$Installcheck::TMP/Amanda_Logfile_test.log";
85 open my $logfile, ">", $log_filename or die("Could not create temporary log file '$log_filename': $!");
86 print $logfile <<LOGFILE;
87 INFO amdump amdump pid 30072
88 INFO driver driver pid 30093
89 INFO planner planner pid 30092
90 INFO dumper dumper pid 30100
91 INFO taper taper pid 30099
92 INFO dumper dumper pid 30103
93 INFO dumper dumper pid 30104
94 INFO dumper dumper pid 30101
95 INFO planner pid-done 30092
96 INFO chunker chunker pid 30475
97 INFO dumper gzip pid 30500
98 INFO dumper gzip pid 30501
99 INFO dumper pid-done 30500
100 INFO chunker pid-done 30475
101 INFO dumper pid-done 30501
102 INFO chunker chunker pid 30527
107 $Amanda_process->scan_log($log_filename);
108 is_deeply($Amanda_process->{pids},
118 is($Amanda_process->{master_pname}, "amdump",
119 "master_name is set to 'amdump'");
120 is($Amanda_process->{master_pid}, "30072",
121 "master_pid is set to '30072'");
123 $Amanda_process->add_child();
124 is_deeply($Amanda_process->{amprocess},
135 "add_child add the 2 gzip process");
137 is($Amanda_process->process_alive(30100, "dumper"), 1,
138 "process_alive return if pname match");
139 is($Amanda_process->process_alive(30100, "driver"), '',
140 "process_alive return '' if pname doesn't match");
141 is($Amanda_process->process_alive(30100), 1,
142 "process_alive return 1 without pname for amanda process");
143 is($Amanda_process->process_alive(30102), 1,
144 "process_alive return 1 without pname for any process");
145 is($Amanda_process->process_alive(30105), '',
146 "process_alive return '' if the process is dead");