lintian doesn't like orphan packages with uploaders...
[debian/amanda] / installcheck / amrmtape.pl
index 01efe923ecb5f84615be8e7c8d558d3bd92cc26c..7b080c6abea8079b49184723b0fb5894ac62a265 100644 (file)
@@ -1,8 +1,9 @@
-# Copyright (c) 2008,2009 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
@@ -17,6 +18,8 @@
 # Sunnyvale, CA 94086, USA, or: http://www.zmanda.com
 
 use Test::More tests => 41;
+use strict;
+use warnings;
 
 use lib "@amperldir@";
 use File::Find;
@@ -66,13 +69,13 @@ Installcheck::Dumpcache::load("notimestamps");
 config_init($CONFIG_INIT_EXPLICIT_NAME, 'TESTCONF');
 
 cmp_ok(
-    run(qw(amrmtape -o tapelist="/this/is/a/fake/tapelist" TESTCONF TESTCONF01)),
-    "==", 0, "config override run"
+    run(qw(amrmtape -o tapelist=/this/is/a/fake/tapelist TESTCONF TESTCONF01)),
+    "==", 1, "config override run"
 ) or proc_diag();
 
 cmp_ok(
-    $Installcheck::Run::stderr, "=~",
-    qr/amrmtape: Could not read the tapelist/,
+    $Installcheck::Run::stdout, "=~",
+    qr/label 'TESTCONF01' not found in \/this\/is\/a\/fake\/tapelist/,
     "config overrides handled correctly"
 ) or proc_diag();
 
@@ -81,7 +84,7 @@ cmp_ok(
 Installcheck::Dumpcache::load("notimestamps");
 
 config_init($CONFIG_INIT_EXPLICIT_NAME, 'TESTCONF');
-my $tapelist = Amanda::Tapelist::read_tapelist(config_dir_relative("tapelist"));
+my $tapelist = Amanda::Tapelist->new(config_dir_relative("tapelist"));
 ok($tapelist->lookup_tapelabel('TESTCONF01'), "looked up tape after dump");
 
 $idx_count_pre = dir_file_count($CNF_INDEXDIR);
@@ -92,7 +95,7 @@ ok(run('amrmtape', 'TESTCONF', 'TESTCONF01'), "amrmtape runs successfully")
 $idx_count_post = dir_file_count($CNF_INDEXDIR);
 is($idx_count_post, $idx_count_pre, "number of index files before and after is the same");
 
-$tapelist = Amanda::Tapelist::read_tapelist(config_dir_relative("tapelist"));
+$tapelist->reload();
 ok(!$tapelist->lookup_tapelabel('TESTCONF01'),
      "should fail to look up tape that should has been removed");
 
@@ -119,7 +122,7 @@ ok(run('amrmtape', '--cleanup', 'TESTCONF', 'TESTCONF01'),
 $idx_count_post = dir_file_count($CNF_INDEXDIR);
 isnt($idx_count_post, $idx_count_pre, "number of index files before and after is different");
 
-$tapelist = Amanda::Tapelist::read_tapelist(config_dir_relative("tapelist"));
+$tapelist->reload();
 ok(!$tapelist->lookup_tapelabel('TESTCONF01'),
      "succesfully looked up tape that should have been removed after --cleanup");
 
@@ -146,7 +149,7 @@ ok(run('amrmtape', '--erase', 'TESTCONF', 'TESTCONF01'),
 $idx_count_post = dir_file_count($CNF_INDEXDIR);
 is($idx_count_post, $idx_count_pre, "number of index files before and after is the same");
 
-$tapelist = Amanda::Tapelist::read_tapelist(config_dir_relative("tapelist"));
+$tapelist->reload();
 ok(!$tapelist->lookup_tapelabel('TESTCONF01'),
      "succesfully looked up tape that should have been removed after --erase");
 
@@ -174,7 +177,7 @@ ok(run('amrmtape', '--keep-label', 'TESTCONF', 'TESTCONF01'),
 $idx_count_post = dir_file_count($CNF_INDEXDIR);
 is($idx_count_post, $idx_count_pre, "number of index files before and after is the same");
 
-$tapelist = Amanda::Tapelist::read_tapelist(config_dir_relative("tapelist"));
+$tapelist->reload();
 my $tape = $tapelist->lookup_tapelabel('TESTCONF01');
 ok($tape, "succesfully looked up tape that should still be there");
 is($tape->{'datestamp'}, "0", "datestamp was zeroed");
@@ -202,7 +205,7 @@ ok(run('amrmtape', '--keep-label', '--erase', 'TESTCONF', 'TESTCONF01'),
 $idx_count_post = dir_file_count($CNF_INDEXDIR);
 is($idx_count_post, $idx_count_pre, "number of index files before and after is the same");
 
-$tapelist = Amanda::Tapelist::read_tapelist(config_dir_relative("tapelist"));
+$tapelist->reload();
 $tape = $tapelist->lookup_tapelabel('TESTCONF01');
 ok($tape, "succesfully looked up tape that should still be there");
 is($tape->{'datestamp'}, "0", "datestamp was zeroed");
@@ -228,7 +231,7 @@ ok(run('amrmtape', '--keep-label', '--erase', 'TESTCONF', 'TESTCONF01'),
 $idx_count_post = dir_file_count($CNF_INDEXDIR);
 is($idx_count_post, $idx_count_pre, "number of index files before and after is the same");
 
-$tapelist = Amanda::Tapelist::read_tapelist(config_dir_relative("tapelist"));
+$tapelist->reload();
 $tape = $tapelist->lookup_tapelabel('TESTCONF01');
 ok($tape, "succesfully looked up tape that should still be there");
 is($tape->{'datestamp'}, "0", "datestamp was zeroed");
@@ -254,7 +257,7 @@ ok(run('amrmtape', '--dryrun', '--erase', '--cleanup', 'TESTCONF', 'TESTCONF01')
 $idx_count_post = dir_file_count($CNF_INDEXDIR);
 is($idx_count_post, $idx_count_pre, "number of index files before and after is the same");
 
-$tapelist = Amanda::Tapelist::read_tapelist(config_dir_relative("tapelist"));
+$tapelist->reload();
 ok($tapelist->lookup_tapelabel('TESTCONF01'),
      "succesfully looked up tape that should still be there");