X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=installcheck%2Famlabel.pl;h=5326f0b8b3a56c2d0993468c6418de2c3a393a1c;hb=0ab9787cd7de76aad522ee8d55ed7e87e3047458;hp=fd5be1dab48ee0bfa9d6223cbef85592e61b9085;hpb=d5853102f67d85d8e169f9dbe973ad573306c215;p=debian%2Famanda diff --git a/installcheck/amlabel.pl b/installcheck/amlabel.pl index fd5be1d..5326f0b 100644 --- a/installcheck/amlabel.pl +++ b/installcheck/amlabel.pl @@ -16,7 +16,9 @@ # Contact information: Zmanda Inc, 465 S. Mathilda Ave., Suite 300 # Sunnyvale, CA 94086, USA, or: http://www.zmanda.com -use Test::More tests => 19; +use Test::More tests => 24; +use strict; +use warnings; use lib "@amperldir@"; use Installcheck::Config; @@ -33,7 +35,8 @@ my $testconf; Amanda::Debug::dbopen("installcheck"); Installcheck::log_test_output(); -$testconf = Installcheck::Run::setup(); +$testconf = Installcheck::Run::setup(1, 4); +$testconf->add_param('autolabel', '"TESTCONF%%" any'); $testconf->write(); config_init($CONFIG_INIT_EXPLICIT_NAME, "TESTCONF"); @@ -58,7 +61,7 @@ $dev->finish() or BAIL_OUT("device error"); my $tlf = Amanda::Config::config_dir_relative(getconf($CNF_TAPELIST)); -my $tl = Amanda::Tapelist::read_tapelist($tlf); +my $tl = Amanda::Tapelist->new($tlf, 1); $tl->add_tapelabel("0", "TESTCONF13", "test tape"); $tl->write($tlf); @@ -74,9 +77,12 @@ like(run_get('amlabel', 'TESTCONF', 'TESTCONF92'), qr/Writing label 'TESTCONF92'/, "amlabel labels the current slot by default"); -$tl = Amanda::Tapelist::read_tapelist($tlf); -is_deeply($tl->[0], { +$tl->reload(); +is_deeply($tl->{'tles'}->[0], { 'reuse' => 1, + 'barcode' => undef, + 'meta' => undef, + 'blocksize' => '32', 'comment' => undef, 'position' => 1, 'label' => 'TESTCONF92', @@ -131,3 +137,43 @@ Writing label 'TESTCONF88'/, ok(run('amlabel', 'TESTCONF', 'TESTCONF88', '-f', 'slot', '2'), "-f option doesn't have to follow 'amlabel'"); + +ok(run('amlabel', 'TESTCONF', 'TESTCONF88', '--meta', 'meta-01', '--barcode', 'bar-01', '--assign'), + "--assign works"); + +$tl->reload(); +is_deeply($tl->{'tles'}->[0], { + 'reuse' => 1, + 'barcode' => 'bar-01', + 'meta' => 'meta-01', + 'blocksize' => undef, + 'comment' => undef, + 'position' => 1, + 'label' => 'TESTCONF88', + 'datestamp' => '0' + }, + "tapelist correctly updated after --assign"); + +ok(run('amlabel', 'TESTCONF', 'slot', '4'), + "amlabel works without a label"); +like($Installcheck::Run::stdout, + qr/Reading label\.\.\. +Found an empty tape\. +Writing label 'TESTCONF01'\.\.\. +Checking label\.\.\. +Success!/, + "amlabel without label use autolabel"); + +$tl->reload(); +is_deeply($tl->{'tles'}->[0], { + 'reuse' => 1, + 'barcode' => undef, + 'meta' => 'meta-01', + 'blocksize' => '32', + 'comment' => undef, + 'position' => 1, + 'label' => 'TESTCONF01', + 'datestamp' => '0' + }, + "tapelist correctly updated after autolabel"); +