1 # Copyright (c) 2005-2008 Zmanda Inc. All Rights Reserved.
3 # This program is free software; you can redistribute it and/or modify it
4 # under the terms of the GNU General Public License version 2 as published
5 # by the Free Software Foundation.
7 # This program is distributed in the hope that it will be useful, but
8 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
9 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 # You should have received a copy of the GNU General Public License along
13 # with this program; if not, write to the Free Software Foundation, Inc.,
14 # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 # Contact information: Zmanda Inc, 465 S Mathlida Ave, Suite 300
17 # Sunnyvale, CA 94086, USA, or: http://www.zmanda.com
19 use Test::More tests => 10;
21 use lib "@amperldir@";
22 use Installcheck::Config;
23 use Installcheck::Run qw(run run_get run_err $diskname);
29 # First, try amgetconf out without a config
31 ok(!run('amdevcheck'),
32 "'amdevcheck' with no arguments returns an error exit status");
33 like($Installcheck::Run::stdout, qr(\AUsage: )i,
34 ".. and gives usage message on stdout");
36 like(run_err('amdevcheck', 'this-probably-doesnt-exist'), qr(could not open conf file)i,
37 "if the configuration doesn't exist, fail with the correct message");
40 # Next, work against a basically empty config
42 # this is re-created for each test
43 $testconf = Installcheck::Config->new();
44 $testconf->add_param("tapedev", '"/dev/null"');
48 ok(run('amdevcheck', 'TESTCONF'), "run succeeds with a /dev/null tapedev");
49 is_deeply([ sort split "\n", $Installcheck::Run::stdout],
50 [ sort "MESSAGE File /dev/null is not a tape device", "DEVICE_ERROR"],
51 "Fail with correct message for a /dev/null tapedev");
54 # Now use a config with a vtape
56 # this is re-created for each test
57 $testconf = Installcheck::Run::setup();
58 $testconf->add_param('label_new_tapes', '"TESTCONF%%"');
59 $testconf->add_dle("localhost $diskname installcheck-test");
62 ok(run('amdevcheck', 'TESTCONF'), "run succeeds with an unlabeled tape");
63 is_deeply([ sort split "\n", $Installcheck::Run::stdout],
64 [ sort "MESSAGE Error loading device header -- unlabeled volume?", "VOLUME_UNLABELED", "DEVICE_ERROR", "VOLUME_ERROR"],
65 "..and output is correct");
67 ok(run('amdevcheck', 'TESTCONF', "/dev/null"),
68 "can override device on the command line");
69 is_deeply([ sort split "\n", $Installcheck::Run::stdout],
70 [ sort "MESSAGE File /dev/null is not a tape device", "DEVICE_ERROR"],
71 ".. and produce a corresponding error message");
73 BAIL_OUT("amdump failed")
74 unless run('amdump', 'TESTCONF');
76 is_deeply([ sort split "\n", run_get('amdevcheck', 'TESTCONF') ],
78 "used vtape described as SUCCESS");
80 Installcheck::Run::cleanup();