Imported Upstream version 3.3.3
[debian/amanda] / installcheck / example.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 => 2;
21
22 use lib "@amperldir@";
23 use File::Path;
24 use Installcheck;
25 use Installcheck::Config;
26 use Installcheck::Run;
27 use Amanda::Paths;
28 use Amanda::Util qw( slurp burp );
29 use Amanda::Config qw( :init );
30
31 # set up a basic TESTCONF, and then burp the example configs over amanda.conf
32 my $testconf = Installcheck::Config->new();
33 $testconf->write();
34 my $example_dir = "$amdatadir/example";
35 my $testconf_dir = "$CONFIG_DIR/TESTCONF";
36 my ($cfgerr_level, @cfgerr_errors);
37
38 burp("$testconf_dir/amanda.conf", slurp("$example_dir/amanda.conf"));
39 config_init($CONFIG_INIT_EXPLICIT_NAME, "TESTCONF");
40 ($cfgerr_level, @cfgerr_errors) = config_errors();
41 ok($cfgerr_level < $CFGERR_WARNINGS, "example/amanda.conf parses without warnings or errors") or
42     config_print_errors();
43 config_uninit();
44
45 burp("$testconf_dir/amanda-client.conf", slurp("$example_dir/amanda-client.conf"));
46 config_init($CONFIG_INIT_EXPLICIT_NAME|$CONFIG_INIT_CLIENT, "TESTCONF");
47 ($cfgerr_level, @cfgerr_errors) = config_errors();
48 ok($cfgerr_level < $CFGERR_WARNINGS, "example/amanda-client.conf parses without warnings or errors") or
49     config_print_errors();
50 config_uninit();
51
52 Installcheck::Run::cleanup();