1 # Copyright (c) 2007, 2008, 2010 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. Mathilda Ave., Suite 300
17 # Sunnyvale, CA 94086, USA, or: http://www.zmanda.com
19 use Test::More tests => 17;
21 use lib "@amperldir@";
22 use Installcheck::Config;
23 use Installcheck::Run qw(run run_get run_err $diskname);
24 use Installcheck::Dumpcache;
30 # First, try amgetconf out without a config
32 ok(!run('amdevcheck'),
33 "'amdevcheck' with no arguments returns an error exit status");
34 like($Installcheck::Run::stdout, qr(\AUsage: )i,
35 ".. and gives usage message on stdout");
37 like(run_err('amdevcheck', 'this-probably-doesnt-exist'), qr(could not open conf file)i,
38 "if the configuration doesn't exist, fail with the correct message");
41 # Next, work against a basically empty config
43 # this is re-created for each test
44 $testconf = Installcheck::Config->new();
45 $testconf->add_param("tapedev", '"/dev/null"');
49 ok(run('amdevcheck', 'TESTCONF'), "run succeeds with a /dev/null tapedev");
50 is_deeply([ sort split "\n", $Installcheck::Run::stdout],
51 [ sort "MESSAGE File /dev/null is not a tape device", "DEVICE_ERROR"],
52 "Fail with correct message for a /dev/null tapedev");
55 # Now use a config with a vtape
57 # this is re-created for each test
58 $testconf = Installcheck::Run::setup();
59 $testconf->add_param('autolabel', '"TESTCONF%%" empty volume_error');
60 $testconf->add_dle("localhost $diskname installcheck-test");
63 ok(run('amdevcheck', 'TESTCONF'), "run succeeds with an unlabeled tape");
64 is_deeply([ sort split "\n", $Installcheck::Run::stdout],
65 [ sort "MESSAGE Error loading device header -- unlabeled volume?", "VOLUME_UNLABELED", "DEVICE_ERROR", "VOLUME_ERROR"],
66 "..and output is correct");
68 ok(run('amdevcheck', 'TESTCONF', "--properties"),
69 "can list properties with --properties option");
71 ok(run('amdevcheck', 'TESTCONF', "--properties", "BLOCK_SIZE"),
72 "check block_size property value");
73 is_deeply([ sort split "\n", $Installcheck::Run::stdout],
74 [ sort "BLOCK_SIZE=32768"],
75 ".. and confirm it is default value");
77 ok(run('amdevcheck', 'TESTCONF', "--properties", "CANONICAL_NAME"),
78 "check canonical_name property value");
79 is_deeply([ sort split "\n", $Installcheck::Run::stdout],
80 [ sort "CANONICAL_NAME=file:" . Installcheck::Run::vtape_dir() ],
81 ".. and confirm it is set to default value");
83 ok(run('amdevcheck', 'TESTCONF', "--properties", "BLOCK_SIZE,CANONICAL_NAME"),
84 "check a list of properties");
85 is_deeply([ sort split "\n", $Installcheck::Run::stdout],
86 [ sort "BLOCK_SIZE=32768",
87 "CANONICAL_NAME=file:" . Installcheck::Run::vtape_dir() ],
88 ".. with correct results");
90 ok(run('amdevcheck', 'TESTCONF', '/dev/null'),
91 "can override device on the command line");
92 is_deeply([ sort split "\n", $Installcheck::Run::stdout],
93 [ sort "MESSAGE File /dev/null is not a tape device", "DEVICE_ERROR"],
94 ".. and produce a corresponding error message");
96 Installcheck::Dumpcache::load("basic");
98 # the 'basic' dumpcache uses a changer, not a tapedev, and amdevcheck doesn't
99 # understand that, so we have to give an explicit device here
100 is_deeply([ sort split "\n",
101 run_get('amdevcheck', 'TESTCONF', 'file:'.$Installcheck::Run::taperoot) ],
103 "used vtape described as SUCCESS");
105 Installcheck::Run::cleanup();