1 # Copyright (c) 2007-2012 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;
23 use lib "@amperldir@";
24 use Installcheck::Config;
25 use Installcheck::Run qw(run run_get run_err $diskname);
26 use Installcheck::Dumpcache;
32 # First, try amgetconf out without a config
34 ok(!run('amdevcheck'),
35 "'amdevcheck' with no arguments returns an error exit status");
36 like($Installcheck::Run::stdout, qr(\AUsage: )i,
37 ".. and gives usage message on stdout");
39 like(run_err('amdevcheck', 'this-probably-doesnt-exist'), qr(could not open conf file)i,
40 "if the configuration doesn't exist, fail with the correct message");
43 # Next, work against a basically empty config
45 # this is re-created for each test
46 $testconf = Installcheck::Config->new();
47 $testconf->add_param("tapedev", '"null:null"');
51 ok(run('amdevcheck', 'TESTCONF'), "run succeeds with a null tapedev");
52 is_deeply([ sort split "\n", $Installcheck::Run::stdout],
53 [ sort "MESSAGE Can't open NULL device for reading or appending.", "DEVICE_ERROR"],
54 "Fail with correct message for a null tapedev");
57 # Now use a config with a vtape
59 # this is re-created for each test
60 $testconf = Installcheck::Run::setup();
61 $testconf->add_param('autolabel', '"TESTCONF%%" empty volume_error');
62 $testconf->add_dle("localhost $diskname installcheck-test");
65 ok(run('amdevcheck', 'TESTCONF'), "run succeeds with an unlabeled tape");
66 is_deeply([ sort split "\n", $Installcheck::Run::stdout],
67 [ sort "MESSAGE File 0 not found", "VOLUME_UNLABELED"],
68 "..and output is correct");
70 ok(run('amdevcheck', 'TESTCONF', "--properties"),
71 "can list properties with --properties option");
73 ok(run('amdevcheck', 'TESTCONF', "--properties", "BLOCK_SIZE"),
74 "check block_size property value");
75 is_deeply([ sort split "\n", $Installcheck::Run::stdout],
76 [ sort "BLOCK_SIZE=32768"],
77 ".. and confirm it is default value");
79 ok(run('amdevcheck', 'TESTCONF', "--properties", "CANONICAL_NAME"),
80 "check canonical_name property value");
81 is_deeply([ sort split "\n", $Installcheck::Run::stdout],
82 [ sort "CANONICAL_NAME=file:" . Installcheck::Run::vtape_dir() ],
83 ".. and confirm it is set to default value");
85 ok(run('amdevcheck', 'TESTCONF', "--properties", "BLOCK_SIZE,CANONICAL_NAME"),
86 "check a list of properties");
87 is_deeply([ sort split "\n", $Installcheck::Run::stdout],
88 [ sort "BLOCK_SIZE=32768",
89 "CANONICAL_NAME=file:" . Installcheck::Run::vtape_dir() ],
90 ".. with correct results");
92 ok(run('amdevcheck', 'TESTCONF', 'null:null'),
93 "can override device on the command line");
94 is_deeply([ sort split "\n", $Installcheck::Run::stdout],
95 [ sort "MESSAGE Can't open NULL device for reading or appending.", "DEVICE_ERROR"],
96 ".. and produce a corresponding error message");
98 Installcheck::Dumpcache::load("basic");
100 # the 'basic' dumpcache uses a changer, not a tapedev, and amdevcheck doesn't
101 # understand that, so we have to give an explicit device here
102 is_deeply([ sort split "\n",
103 run_get('amdevcheck', 'TESTCONF', 'file:'.$Installcheck::Run::taperoot) ],
105 "used vtape described as SUCCESS");
106 Installcheck::Run::cleanup();