1 # Copyright (c) 2008 Zmanda, Inc. All Rights Reserved.
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.
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
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
16 # Contact information: Zmanda Inc, 465 S. Mathilda Ave., Suite 300
17 # Sunnyvale, CA 94086, USA, or: http://www.zmanda.com
19 use Test::More tests => 13;
21 use lib "@amperldir@";
22 use Amanda::Config qw( :init :getconf );
24 use Installcheck::Config;
28 $testconf = Installcheck::Config->new();
29 $testconf->add_dumptype("mytype", [
30 "compress" => "server",
31 "starttime" => "1830",
32 "amandad_path" => "\"/path/to/amandad\"",
34 $testconf->add_interface("eth1", []);
35 $testconf->add_dle("otherbox /home mytype");
36 $testconf->add_dle("otherbox /disk1 mytype");
37 $testconf->add_dle("otherbox /disk2 mytype");
38 $testconf->add_dle(<<EOF);
45 if (config_init($CONFIG_INIT_EXPLICIT_NAME, "TESTCONF") != $CFGERR_OK) {
46 config_print_errors();
50 is(Amanda::Disklist::read_disklist(), $CFGERR_OK,
51 "read_disklist returns CFGERR_OK")
52 or die("Error loading disklist");
56 $x = Amanda::Disklist::get_host("otherbox");
57 ok($x, "get_host returns a host");
58 is($x->{'auth'}, 'BSD', "..host has correct auth");
59 is_deeply([ sort @{$x->{'disks'}} ],
60 [ sort "/disk1", "/disk2", "/home" ],
62 is(interface_name($x->{'interface'}->{'config'}), "default", "..and correct interface");
64 $d = $x->get_disk("/home");
65 is($d->{'name'}, "/home", "host->get_disk() works");
67 @list = $x->all_disks();
68 is_deeply([ sort map { $_->{'name'} } @list ],
69 [ sort "/disk1", "/disk2", "/home" ],
70 "host->all_disks returns all disk objects");
72 @list = Amanda::Disklist::all_hosts();
73 is_deeply([ sort( map { $_->{'hostname'} } @list ) ],
74 [ sort qw(myhost otherbox) ],
75 "all_hosts returns correct hosts");
77 $x = Amanda::Disklist::get_disk("myhost", "/mydisk");
78 ok($x, "get_disk returns a disk");
79 is($x->{'name'}, "/mydisk", "..and it's the right one");
81 @list = Amanda::Disklist::all_disks();
82 is(scalar @list, 4, "all_lists returns 4 disks");
84 $x = Amanda::Disklist::get_interface("eth1");
85 is(interface_name($x->{'config'}), "eth1", "get_interface returns an interface");
87 @list = Amanda::Disklist::all_interfaces();
88 is(scalar @list, 2, "all_interfaces returns two interfaces");