Imported Upstream version 3.2.0
[debian/amanda] / installcheck / amoverview.pl
1 # Copyright (c) 2007, 2008, 2010 Zmanda, Inc.  All Rights Reserved.
2 #
3 # This program is free software; you can redistribute it and/or modify it
4 # under the terms of the GNU General Public License version 2 as published
5 # by the Free Software Foundation.
6 #
7 # This program is distributed in the hope that it will be useful, but
8 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
9 # or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
10 # for more details.
11 #
12 # You should have received a copy of the GNU General Public License along
13 # with this program; if not, write to the Free Software Foundation, Inc.,
14 # 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
15 #
16 # Contact information: Zmanda Inc, 465 S. Mathilda Ave., Suite 300
17 # Sunnyvale, CA 94086, USA, or: http://www.zmanda.com
18
19 use Test::More tests => 4;
20 use strict;
21 use warnings;
22
23 use lib "@amperldir@";
24 use Installcheck::Config;
25 use Installcheck::Dumpcache;
26 use Installcheck::Catalogs;
27 use Installcheck::Run qw(run run_get run_err $diskname);
28 use Amanda::Paths;
29 use Amanda::Debug;
30
31 Amanda::Debug::dbopen("installcheck");
32
33 ##
34 # First, try amoverview without a config
35
36 ok(!run('amoverview'),
37     "amoverview with no arguments returns an error exit status");
38 like($Installcheck::Run::stderr, qr/\AUSAGE:/i,
39     ".. and gives usage message on stderr");
40
41 ##
42 # Now try it against a cached dump
43
44 Installcheck::Dumpcache::load("multi");
45
46 like(run_get('amoverview', 'TESTCONF'),
47     # this pattern is pretty loose, but that's OK
48     qr{
49         \s+date\s+\d\d\s+
50         host\s+disk\s+\d\d\s+
51         localhos\s+/.*\s+00\s+
52         localhos\s+/.*\s+01
53     }mxs,
54     "amoverview of the 'multi' dump looks good");
55
56 Installcheck::Run::cleanup();
57
58 ##
59 # And some cached catalogs
60
61 my $testconf = Installcheck::Run::setup();
62 $testconf->write();
63
64 my $cat = Installcheck::Catalogs::load("bigdb");
65 $cat->install();
66
67 like(run_get('amoverview', 'TESTCONF', '--skipmissed'),
68     qr{
69 \s*              date      \s+ 01\s+02\s+03\s+03\s+04\s+05\s+05\s+06\s+07 \s+
70 \s*  host \s+    disk      \s+ 11\s+22\s+11\s+13\s+14\s+11\s+15\s+16\s+22 \s+
71 \s*
72 \s*  lovelace\s+ /home/ada \s+  -\s+ -\s+ -\s+ -\s+ -\s+ -\s+ -\s+ -\s+ 3 \s+
73 \s*  otherbox\s+ /direct   \s+  -\s+ -\s+ -\s+ -\s+ -\s+ -\s+ 0\s+ -\s+ - \s+
74 \s*  otherbox\s+ /lib      \s+  -\s+ -\s+ -\s+ 0\s+1E\s+ 0\s+ -\s+ -\s+ - \s+
75 \s*  otherbox\s+ /usr/bin  \s+  -\s+ -\s+00\s+ -\s+ -\s+ 0\s+ -\s+ -\s+ - \s+
76 \s*  somebox \s+ /lib      \s+  0\s+ 0\s+ -\s+ 0\s+ -\s+ -\s+ 0\s+ E\s+ - \s+
77 \s*  somebox \s+ /usr/bin  \s+  -\s+ -\s+ -\s+ 1\s+ -\s+ -\s+ 1\s+ 1\s+ -
78     }mxs,
79     "amoverview of the bigdb catalog looks right");