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