X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=installcheck%2FAmanda_Tapelist.pl;h=f22d5554975b1fa0ea682103992b9cde42528ed4;hb=refs%2Fheads%2Fmaster;hp=02e6fb465af8930ccb6ebb0018a7aca9d7bfd48d;hpb=cd0b924f27312d57bd42f6c4fae2b795139e2d0b;p=debian%2Famanda diff --git a/installcheck/Amanda_Tapelist.pl b/installcheck/Amanda_Tapelist.pl index 02e6fb4..f22d555 100644 --- a/installcheck/Amanda_Tapelist.pl +++ b/installcheck/Amanda_Tapelist.pl @@ -1,8 +1,9 @@ -# Copyright (c) 2008, 2010 Zmanda, Inc. All Rights Reserved. +# Copyright (c) 2008-2012 Zmanda, Inc. All Rights Reserved. # -# This program is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 as published -# by the Free Software Foundation. +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY @@ -64,9 +65,12 @@ sub readtapelist { @lines = ( "20071111010002 TESTCONF004 reuse META:META1\n", - "20071110010002 TESTCONF003 reuse BARCODE:BAR-003\n", - "20071109010002 TESTCONF002 reuse BARCODE:BAR-002 META:META2 #comment 2\n", + "20071110010002 TESTCONF003 reuse BARCODE:BAR-003 BLOCKSIZE:32\n", + "20071109010002 TESTCONF002 reuse BARCODE:BAR-002 META:META2 BLOCKSIZE:64 #comment 2\n", "20071108010001 TESTCONF001 no-reuse #comment 1\n", + "20071107110002 TESTCONF015\n", + "20071107010002 TESTCONF006 no-reuse\n", + "20071106010002 TESTCONF005 reuse\n", ); mktapelist($tapelist, @lines); @@ -76,17 +80,26 @@ $tl_ok = is_deeply($tl, { lockname => $tapelist . ".lock", tles => [ { 'datestamp' => '20071111010002', 'label' => 'TESTCONF004', - 'reuse' => 1, 'position' => 1, + 'reuse' => 1, 'position' => 1, 'blocksize' => undef, 'barcode' => undef, 'meta' => 'META1', 'comment' => undef }, { 'datestamp' => '20071110010002', 'label' => 'TESTCONF003', - 'reuse' => 1, 'position' => 2, + 'reuse' => 1, 'position' => 2, 'blocksize' => '32', 'barcode' => 'BAR-003', 'meta' => undef, 'comment' => undef }, { 'datestamp' => '20071109010002', 'label' => 'TESTCONF002', - 'reuse' => 1, 'position' => 3, + 'reuse' => 1, 'position' => 3, 'blocksize' => '64', 'barcode' => 'BAR-002', 'meta' => 'META2', 'comment' => 'comment 2' }, { 'datestamp' => '20071108010001', 'label' => 'TESTCONF001', - 'reuse' => '', 'position' => 4, + 'reuse' => '', 'position' => 4, 'blocksize' => undef, 'barcode' => undef, 'meta' => undef, 'comment' => 'comment 1' }, + { 'datestamp' => '20071107110002', 'label' => 'TESTCONF015', + 'reuse' => 1, 'position' => 5, 'blocksize' => undef, + 'barcode' => undef, 'meta' => undef, 'comment' => undef }, + { 'datestamp' => '20071107010002', 'label' => 'TESTCONF006', + 'reuse' => '', 'position' => 6, 'blocksize' => undef, + 'barcode' => undef, 'meta' => undef, 'comment' => undef }, + { 'datestamp' => '20071106010002', 'label' => 'TESTCONF005', + 'reuse' => 1, 'position' => 7, 'blocksize' => undef, + 'barcode' => undef, 'meta' => undef, 'comment' => undef }, ] }, "A simple tapelist is parsed correctly"); SKIP: { @@ -96,11 +109,13 @@ SKIP: { # now try writing it out and check that the results are the same $tl->write("$tapelist-new"); my @reread_lines = readtapelist("$tapelist-new"); + chomp($lines[4]); + $lines[4] .= " reuse\n"; #'reuse' is automatically written is_deeply(\@reread_lines, \@lines, "Lines of freshly written tapelist match the original"); is_deeply($tl->lookup_tapelabel('TESTCONF002'), { 'datestamp' => '20071109010002', 'label' => 'TESTCONF002', - 'reuse' => 1, 'position' => 3, + 'reuse' => 1, 'position' => 3, 'blocksize' => '64', 'barcode' => 'BAR-002', 'meta' => 'META2', 'comment' => 'comment 2' }, "lookup_tapelabel works"); @@ -109,7 +124,7 @@ SKIP: { is_deeply($tl->lookup_tapepos(4), { 'datestamp' => '20071108010001', 'label' => 'TESTCONF001', - 'reuse' => '', 'position' => 4, + 'reuse' => '', 'position' => 4, 'blocksize' => undef, 'barcode' => undef, 'meta' => undef, 'comment' => 'comment 1' }, "lookup_tapepos works"); @@ -118,7 +133,7 @@ SKIP: { is_deeply($tl->lookup_tapedate('20071110010002'), { 'datestamp' => '20071110010002', 'label' => 'TESTCONF003', - 'reuse' => 1, 'position' => 2, + 'reuse' => 1, 'position' => 2, 'blocksize' => '32', 'barcode' => 'BAR-003', 'meta' => undef, 'comment' => undef }, "lookup_tapedate works"); @@ -127,45 +142,45 @@ SKIP: { # try some edits $tl->add_tapelabel("20080112010203", "TESTCONF007", "seven", 1, 'META3', 'BAR-007'); - is(scalar @{$tl->{'tles'}}, 5, "add_tapelabel adds a new element to the tapelist"); + is(scalar @{$tl->{'tles'}}, 8, "add_tapelabel adds a new element to the tapelist"); is_deeply($tl->lookup_tapepos(1), { 'datestamp' => '20080112010203', 'label' => 'TESTCONF007', - 'reuse' => 1, 'position' => 1, + 'reuse' => 1, 'position' => 1, 'blocksize' => undef, 'barcode' => 'BAR-007', 'meta' => 'META3', 'comment' => 'seven' }, ".. lookup_tapepos finds it at the beginning"); is_deeply($tl->lookup_tapelabel("TESTCONF007"), { 'datestamp' => '20080112010203', 'label' => 'TESTCONF007', - 'reuse' => 1, 'position' => 1, + 'reuse' => 1, 'position' => 1, 'blocksize' => undef, 'barcode' => 'BAR-007', 'meta' => 'META3' , 'comment' => 'seven' }, ".. lookup_tapelabel finds it"); is_deeply($tl->lookup_tapedate("20080112010203"), { 'datestamp' => '20080112010203', 'label' => 'TESTCONF007', - 'reuse' => 1, 'position' => 1, + 'reuse' => 1, 'position' => 1, 'blocksize' => undef, 'barcode' => 'BAR-007', 'meta' => 'META3', 'comment' => 'seven' }, ".. lookup_tapedate finds it"); # try some edits - $tl->add_tapelabel("20080112010204", "TESTCONF008", "eight", 0); - is(scalar @{$tl->{'tles'}}, 6, "add_tapelabel adds a new element to the tapelist no-reuse"); + $tl->add_tapelabel("20080112010204", "TESTCONF008", "eight", 0, undef, undef, 128); + is(scalar @{$tl->{'tles'}}, 9, "add_tapelabel adds a new element to the tapelist no-reuse"); is_deeply($tl->lookup_tapelabel("TESTCONF008"), { 'datestamp' => '20080112010204', 'label' => 'TESTCONF008', - 'reuse' => 0, 'position' => 1, + 'reuse' => 0, 'position' => 1, 'blocksize' => '128', 'barcode' => undef, 'meta' => undef, 'comment' => 'eight' }, ".. lookup_tapelabel finds it no-reuse"); $tl->remove_tapelabel("TESTCONF008"); - is(scalar @{$tl->{'tles'}}, 5, "remove_tapelabel removes an element from the tapelist, no-reuse"); + is(scalar @{$tl->{'tles'}}, 8, "remove_tapelabel removes an element from the tapelist, no-reuse"); $tl->remove_tapelabel("TESTCONF002"); - is(scalar @{$tl->{'tles'}}, 4, "remove_tapelabel removes an element from the tapelist"); + is(scalar @{$tl->{'tles'}}, 7, "remove_tapelabel removes an element from the tapelist"); is_deeply($tl->lookup_tapepos(4), # used to be in position 5 { 'datestamp' => '20071108010001', 'label' => 'TESTCONF001', - 'reuse' => '', 'position' => 4, + 'reuse' => '', 'position' => 4, 'blocksize' => undef, 'barcode' => undef, 'meta' => undef, 'comment' => 'comment 1' }, ".. tape positions are adjusted correctly"); @@ -180,13 +195,13 @@ SKIP: { is_deeply($tl->lookup_tapepos(4), { 'datestamp' => '20071109010204', 'label' => 'TESTCONF009', - 'reuse' => '1', 'position' => 4, + 'reuse' => '1', 'position' => 4, 'blocksize' => undef, 'barcode' => undef, 'meta' => undef, 'comment' => 'nine' }, ".. tape positions are adjusted correctly"); is_deeply($tl->lookup_tapelabel('TESTCONF009'), { 'datestamp' => '20071109010204', 'label' => 'TESTCONF009', - 'reuse' => '1', 'position' => 4, + 'reuse' => '1', 'position' => 4, 'blocksize' => undef, 'barcode' => undef, 'meta' => undef, 'comment' => 'nine' }, ".. tape positions are adjusted correctly"); @@ -199,20 +214,20 @@ SKIP: { or die("config_init failed"); is( Amanda::Tapelist::get_last_reusable_tape_label(0), - 'TESTCONF002', ".. get_last_reusable_tape_labe for skip=0" ); + 'TESTCONF005', ".. get_last_reusable_tape_labe for skip=0" ); is( Amanda::Tapelist::get_last_reusable_tape_label(2), - 'TESTCONF004', ".. get_last_reusable_tape_labe for skip=2" ); + 'TESTCONF002', ".. get_last_reusable_tape_labe for skip=2" ); } # try parsing various invalid lines @lines = ( "2006123456 FOO reuse\n", # valid - "TESTCONF003 290385098 reuse\n", # invalid - "20071109010002 TESTCONF002 re-use\n", # invalid - "20071108010001 TESTCONF001\n", # invalid - "20071108010001 TESTCONF001 #comment\n", # invalid - "#comment\n", # invalid +# "TESTCONF003 290385098 reuse\n", # invalid +# "20071109010002 TESTCONF002 re-use\n", # invalid +# "20071108010001 TESTCONF001\n", # invalid +# "20071108010001 TESTCONF001 #comment\n", # invalid +# "#comment\n", # invalid ); mktapelist($tapelist, @lines); @@ -222,7 +237,7 @@ is_deeply($tl, { lockname => $tapelist . ".lock", tles => [ { 'datestamp' => '2006123456', 'label' => 'FOO', - 'reuse' => 1, 'position' => 1, + 'reuse' => 1, 'position' => 1, 'blocksize' => undef, 'barcode' => undef, 'meta' => undef, 'comment' => undef }, ] }, "Invalid lines are ignored"); @@ -238,7 +253,7 @@ is_deeply($tl, { lockname => $tapelist . ".lock", tles => [ { 'datestamp' => '2006123456', 'label' => 'FOO', - 'reuse' => 1, 'position' => 1, + 'reuse' => 1, 'position' => 1, 'blocksize' => undef, 'barcode' => undef, 'meta' => undef, 'comment' => undef }, ] }, "reload works");