+$chg->quit();
+
+# test two simultaneous invocations of info()
+
+$chg = Amanda::Changer->new();
+die($chg) if $chg->isa("Amanda::Changer::Error");
+
+sub test_get_infos {
+ my ($finished_cb) = @_;
+ my $n_info_results = 0;
+
+ my $steps = define_steps
+ cb_ref => \$finished_cb;
+
+ step get_infos => sub {
+ # convince the changer that it has not gotten any info yet
+ $chg->{'got_info'} = 0;
+
+ $chg->info(info_cb => $steps->{'got_info_result'}, info => [ 'num_slots' ]);
+ $chg->info(info_cb => $steps->{'got_info_result'}, info => [ 'fast_search' ]);
+ };
+
+ step got_info_result => sub {
+ my ($err, %info) = @_;
+ die $err if $err;
+ ++$n_info_results;
+ if ($n_info_results >= 2) {
+ pass("two simultaneous info() invocations are successful");
+ $finished_cb->();
+ }
+ };
+}
+test_get_infos(\&Amanda::MainLoop::quit);
+Amanda::MainLoop::run();
+
+# scan the changer using except_slots
+sub test_except_slots {
+ my ($finished_cb) = @_;
+ my $slot;
+ my %except_slots;
+
+ my $steps = define_steps
+ cb_ref => \$finished_cb;
+
+ step start => sub {
+ $chg->load(relative_slot => "current",
+ except_slots => { %except_slots },
+ res_cb => $steps->{'loaded'});
+ };
+
+ step loaded => sub {
+ my ($err, $res) = @_;
+ if ($err) {
+ if ($err->notfound) {
+ # this means the scan is done
+ return $steps->{'quit'}->();
+ } elsif ($err->volinuse and defined $err->{'slot'}) {
+ $slot = $err->{'slot'};
+ } else {
+ die $err;
+ }
+ } else {
+ $slot = $res->{'this_slot'};
+ }
+
+ $except_slots{$slot} = 1;
+
+ if ($res) {
+ $res->release(finished_cb => $steps->{'released'});
+ } else {
+ $steps->{'released'}->();
+ }
+ };
+
+ step released => sub {
+ my ($err) = @_;
+ die $err if $err;
+
+ $chg->load(relative_slot => 'next', slot => $slot,
+ except_slots => { %except_slots },
+ res_cb => $steps->{'loaded'});
+ };
+
+ step quit => sub {
+ is_deeply({ %except_slots }, { 1=>1, 2=>1, 3=>1 },
+ "scanning with except_slots works");
+ $finished_cb->();
+ };
+}
+test_except_slots(\&Amanda::MainLoop::quit);
+Amanda::MainLoop::run();
+$chg->quit();
+
+unlink($changer_filename);
+unlink($result_file);