X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=installcheck%2FAmanda_Changer_compat.pl;h=6e75f7c1acf446ce957fae6a3a2c33d3e26bd572;hb=d74dc4d908fcbc1a4ef474edaf51e61ec90eab6b;hp=2480204b4aa712b05d34602303c94414a23b26dc;hpb=2627875b7d18858bc1f9f7652811e4d8c15a23eb;p=debian%2Famanda diff --git a/installcheck/Amanda_Changer_compat.pl b/installcheck/Amanda_Changer_compat.pl index 2480204..6e75f7c 100644 --- a/installcheck/Amanda_Changer_compat.pl +++ b/installcheck/Amanda_Changer_compat.pl @@ -16,7 +16,7 @@ # Contact information: Zmanda Inc, 465 S Mathlida Ave, Suite 300 # Sunnyvale, CA 94086, USA, or: http://www.zmanda.com -use Test::More tests => 17; +use Test::More tests => 22; use File::Path; use strict; use warnings; @@ -38,6 +38,7 @@ Amanda::Debug::dbopen("installcheck"); Amanda::Debug::disable_die_override(); my $changer_filename = "$AMANDA_TMPDIR/chg-test"; +my $result_file = "$AMANDA_TMPDIR/chg-test.result"; # Set up a 'test' changer; several of these are defined below. sub setup_changer { @@ -54,6 +55,17 @@ sub setup_changer { chmod 0755, $changer_filename; } +# slurp the $result_file +sub slurp_result { + return '' unless (-r $result_file); + + open(my $fh, "<", $result_file) or die("open $result_file: $!"); + my $result = do { local $/; <$fh> }; + close($fh); + + return $result; +} + # Functions to invoke the changer and later verify the result { my $expected_err_re; @@ -120,9 +132,15 @@ case "${1}" in 2) echo " slot 2 is empty"; exit 1;; 3) echo "1"; exit 0;; # test missing 'device' portion esac;; - -reset) echo "reset ignored";; - -eject) echo "eject ignored";; - -clean) echo "clean ignored";; + -reset) + echo "reset" > @AMANDA_TMPDIR@/chg-test.result + echo "reset ignored";; + -eject) + echo "eject" > @AMANDA_TMPDIR@/chg-test.result + echo "eject ignored";; + -clean) + echo "clean" > @AMANDA_TMPDIR@/chg-test.result + echo "clean ignored";; -label) case "${2}" in foo?bar) echo "1 ok"; exit 0;; @@ -171,13 +189,20 @@ try_run_changer( # sub { $chg->load(slot => '3', res_cb => \&check_res_cb); }, # undef, undef, "search by slot; invalid response"); +try_run_changer( + sub { $chg->eject(finished_cb => \&check_finished_cb); }, + undef, undef, "chg->eject doesn't fail"); +like(slurp_result(), qr/eject/, ".. and calls chg-test -eject"); + try_run_changer( sub { $chg->reset(finished_cb => \&check_finished_cb); }, - undef, undef, "reset doesn't fail"); + undef, undef, "chg->reset doesn't fail"); +like(slurp_result(), qr/reset/, ".. and calls chg-test -reset"); try_run_changer( sub { $chg->clean(finished_cb => \&check_finished_cb); }, - undef, undef, "clean doesn't fail"); + undef, undef, "chg->clean doesn't fail"); +like(slurp_result(), qr/clean/, ".. and calls chg-test -clean"); # TODO test update() @@ -215,6 +240,8 @@ try_run_changer( ok(!defined $err, "release with eject succeeds"); + like(slurp_result(), qr/eject/, "..and calls chg-test -eject"); + Amanda::MainLoop::quit(); };