X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=installcheck%2Famdevcheck.pl;h=f82e37dd5605af98a59dd5e0e58ce1bb8860b1fb;hb=2627875b7d18858bc1f9f7652811e4d8c15a23eb;hp=895f73a107e5891642c635b4614edb7939cd242e;hpb=94a044f90357edefa6f4ae9f0b1d5885b0e34aee;p=debian%2Famanda diff --git a/installcheck/amdevcheck.pl b/installcheck/amdevcheck.pl index 895f73a..f82e37d 100644 --- a/installcheck/amdevcheck.pl +++ b/installcheck/amdevcheck.pl @@ -1,4 +1,4 @@ -# Copyright (c) 2006 Zmanda Inc. All Rights Reserved. +# Copyright (c) 2005-2008 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 @@ -13,55 +13,68 @@ # with this program; if not, write to the Free Software Foundation, Inc., # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # -# Contact information: Zmanda Inc, 505 N Mathlida Ave, Suite 120 -# Sunnyvale, CA 94085, USA, or: http://www.zmanda.com +# Contact information: Zmanda Inc, 465 S Mathlida Ave, Suite 300 +# Sunnyvale, CA 94086, USA, or: http://www.zmanda.com -use Test::More qw( no_plan ); +use Test::More tests => 10; -use Amconfig; use lib "@amperldir@"; +use Installcheck::Config; +use Installcheck::Run qw(run run_get run_err $diskname); use Amanda::Paths; -sub amdevcheck { - my $cmd = "$sbindir/amdevcheck " . join(" ", @_) . " 2>&1"; - my $result = `$cmd`; - chomp $result; - return $result; -} - my $testconf; ## # First, try amgetconf out without a config -like(amdevcheck(), qr(\AUsage: )i, - "bare 'amdevcheck' gives usage message"); -like(amdevcheck("this-probably-doesnt-exist"), qr(could not open conf file)i, - "error message when configuration parameter doesn't exist"); +ok(!run('amdevcheck'), + "'amdevcheck' with no arguments returns an error exit status"); +like($Installcheck::Run::stdout, qr(\AUsage: )i, + ".. and gives usage message on stdout"); + +like(run_err('amdevcheck', 'this-probably-doesnt-exist'), qr(could not open conf file)i, + "if the configuration doesn't exist, fail with the correct message"); ## # Next, work against a basically empty config # this is re-created for each test -$testconf = Amconfig->new(); +$testconf = Installcheck::Config->new(); $testconf->add_param("tapedev", '"/dev/null"'); $testconf->write(); # test some defaults -like(amdevcheck('TESTCONF'), qr{File /dev/null is not a tape device}, - "uses tapedev by default"); +ok(run('amdevcheck', 'TESTCONF'), "run succeeds with a /dev/null tapedev"); +is_deeply([ sort split "\n", $Installcheck::Run::stdout], + [ sort "MESSAGE File /dev/null is not a tape device", "DEVICE_ERROR"], + "Fail with correct message for a /dev/null tapedev"); ## # Now use a config with a vtape # this is re-created for each test -$testconf = Amconfig->new(); -$testconf->setup_vtape(); +$testconf = Installcheck::Run::setup(); +$testconf->add_param('label_new_tapes', '"TESTCONF%%"'); +$testconf->add_dle("localhost $diskname installcheck-test"); $testconf->write(); -is_deeply([ sort split "\n", amdevcheck('TESTCONF') ], - [ sort "VOLUME_UNLABELED", "VOLUME_ERROR", "DEVICE_ERROR" ], - "empty vtape described as VOLUME_UNLABELED, VOLUME_ERROR, DEVICE_ERROR"); +ok(run('amdevcheck', 'TESTCONF'), "run succeeds with an unlabeled tape"); +is_deeply([ sort split "\n", $Installcheck::Run::stdout], + [ sort "MESSAGE Error loading device header -- unlabeled volume?", "VOLUME_UNLABELED", "DEVICE_ERROR", "VOLUME_ERROR"], + "..and output is correct"); -like(amdevcheck('TESTCONF', "/dev/null"), qr{File /dev/null is not a tape device}, +ok(run('amdevcheck', 'TESTCONF', "/dev/null"), "can override device on the command line"); +is_deeply([ sort split "\n", $Installcheck::Run::stdout], + [ sort "MESSAGE File /dev/null is not a tape device", "DEVICE_ERROR"], + ".. and produce a corresponding error message"); + +BAIL_OUT("amdump failed") + unless run('amdump', 'TESTCONF'); + +is_deeply([ sort split "\n", run_get('amdevcheck', 'TESTCONF') ], + [ sort "SUCCESS" ], + "used vtape described as SUCCESS"); + +Installcheck::Run::cleanup();