1 # Copyright (c) 2005-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 Mathlida Ave, Suite 300
17 # Sunnyvale, CA 94086, USA, or: http://www.zmanda.com
19 use Test::More tests => 4;
23 use lib "@amperldir@";
24 use Installcheck::Config;
29 use Amanda::Config qw( :init :getconf config_dir_relative );
32 # set up debugging so debug output doesn't interfere with test results
33 Amanda::Debug::dbopen("installcheck");
35 # and disable Debug's die() and warn() overrides
36 Amanda::Debug::disable_die_override();
38 my $testconf = Installcheck::Config->new();
41 my $cfg_result = config_init($CONFIG_INIT_EXPLICIT_NAME, 'TESTCONF');
42 if ($cfg_result != $CFGERR_OK) {
43 my ($level, @errors) = Amanda::Config::config_errors();
44 die(join "\n", @errors);
47 my $chg = Amanda::Changer->new("chg-single:tape:/foo");
51 my ($get_info, $get_res, $got_res, $got_second_res);
54 $chg->info(info_cb => $get_res, info => [ 'num_slots' ]);
60 die($err) if defined($err);
62 is($results{'num_slots'}, 1, "info() returns the correct num_slots");
64 $chg->load(slot => "current",
70 ok(!$err, "no error loading slot 'current'")
72 is($res->{'device_name'}, 'tape:/foo',
73 "returns correct device name");
75 $held_res = $res; # hang onto it while loading another slot
77 $chg->load(label => "FOO!",
78 res_cb => $got_second_res);
81 $got_second_res = sub {
83 ok($err, "second simultaneous reservation rejected");
85 Amanda::MainLoop::quit();
89 Amanda::MainLoop::call_later($get_info);
90 Amanda::MainLoop::run();