22e7c1818b010ac577fac5cf1d6f5e238bf72bff
[debian/amanda] / installcheck / amserverconfig.pl
1 # Copyright (c) 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 => 10;
20
21 use lib "@amperldir@";
22 use File::Path;
23 use Installcheck;
24 use Installcheck::Run qw(run run_err $diskname);
25 use Amanda::Paths;
26 use Amanda::Constants;
27 use Amanda::Util qw( slurp burp );
28 use Amanda::Config qw( :init );
29
30 # this basically gets one run of amserverconfig in for each template, and then
31 # checks that the config loads correctly
32
33 sub config_ok {
34     my ($msg) = @_;
35
36     config_init($CONFIG_INIT_EXPLICIT_NAME, "TESTCONF");
37
38     my ($cfgerr_level, @cfgerr_errors) = config_errors();
39     ok($cfgerr_level < $CFGERR_WARNINGS, $msg || "..config is OK") or
40         config_print_errors();
41
42     config_uninit();
43 }
44
45 Installcheck::Run::cleanup();
46 ok(run("$sbindir/amserverconfig", 'TESTCONF', '--template', 'S3'),
47     "amserverconfig with S3 template")
48     or diag($Installcheck::Run::stdout);
49 config_ok();
50
51 Installcheck::Run::cleanup();
52 ok(run("$sbindir/amserverconfig", 'TESTCONF', '--template', 'harddisk'),
53     "amserverconfig with harddisk template")
54     or diag($Installcheck::Run::stdout);
55 config_ok();
56
57 Installcheck::Run::cleanup();
58 mkpath(Installcheck::Run::vtape_dir());
59 ok(run("$sbindir/amserverconfig", 'TESTCONF', '--template', 'harddisk',
60                     '--tapecycle', '2',
61                     '--tapedev', Installcheck::Run::vtape_dir()),
62     "amserverconfig with harddisk template and tapedev and tapecycle")
63     or diag($Installcheck::Run::stdout);
64 config_ok();
65
66 Installcheck::Run::cleanup();
67 ok(run("$sbindir/amserverconfig", 'TESTCONF', '--template', 'single-tape'),
68     "amserverconfig with single-tape template")
69     or diag($Installcheck::Run::stdout);
70 config_ok();
71
72 SKIP: {
73     skip "tape-changer template requires mtx", 2
74         unless $Amanda::Constants::MTX && -x $Amanda::Constants::MTX;
75     Installcheck::Run::cleanup();
76     ok(run("$sbindir/amserverconfig", 'TESTCONF', '--template', 'tape-changer'),
77         "amserverconfig with tape-changer template")
78         or diag($Installcheck::Run::stdout);
79     config_ok();
80 }
81
82 Installcheck::Run::cleanup();