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