Imported Upstream version 3.2.0
[debian/amanda] / installcheck / amcheck.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 => 12;
20 use strict;
21 use warnings;
22
23 use lib "@amperldir@";
24 use Installcheck::Config;
25 use Installcheck::Dumpcache;
26 use Installcheck::Run qw(run run_get run_err $diskname);
27 use Amanda::Paths;
28
29 my $testconf;
30
31 ##
32 # First, try amgetconf out without a config
33
34 ok(!run('amcheck'),
35     "amcheck with no arguments returns an error exit status");
36 like($Installcheck::Run::stdout, qr/\AUSAGE:/i,
37     ".. and gives usage message");
38
39 like(run_err('amcheck', 'this-probably-doesnt-exist'),
40     qr(could not open conf file)i,
41     "run with non-existent config fails with an appropriate error message.");
42
43 ##
44 # Now use a fresh new config
45
46 $testconf = Installcheck::Run::setup();
47 $testconf->add_param("autolabel", "\"TESTCONF%%\" empty volume_error");
48 $testconf->add_dle("localhost $diskname installcheck-test");
49 $testconf->write();
50
51 like(run_get('amcheck', 'TESTCONF'),
52     qr/Amanda Tape Server Host Check/,
53     "amcheck with a new config succeeds");
54
55 like(run_get('amcheck', '-s', 'TESTCONF'),
56     qr/Amanda Tape Server Host Check/,
57     "amcheck -s works");
58
59 like(run_get('amcheck', '-l', 'TESTCONF'),
60     qr/Amanda Tape Server Host Check/,
61     "amcheck -l works");
62
63 like(run_get('amcheck', '-t', 'TESTCONF'),
64     qr/Amanda Tape Server Host Check/,
65     "amcheck -t works");
66
67 like(run_get('amcheck', '-c', 'TESTCONF'),
68     qr/Amanda Backup Client Hosts Check/,
69     "amcheck -c works");
70
71 like(run_get('amcheck', '-c', 'TESTCONF', 'localhost', "$diskname"),
72     qr/Amanda Backup Client Hosts Check/,
73     "amcheck -c works with a hostname and diskname");
74
75 ok(!run('amcheck', '-o', 'autolabel=', 'TESTCONF'),
76     "amcheck -o configoption works");
77
78 # do this after the other tests, above, since it writes to the tape
79 like(run_get('amcheck', '-sw', 'TESTCONF'),
80     qr/Volume 'TESTCONF01' is writeable/,
81     "amcheck -w works (with -s)");
82
83 Installcheck::Dumpcache::load("basic");
84 ok(run('amcheck', 'TESTCONF'),
85     "amcheck on a cached dump run works");
86
87 Installcheck::Run::cleanup();