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