Imported Upstream version 3.3.2
[debian/amanda] / installcheck / amtapetype.pl
1 # Copyright (c) 2008-2012 Zmanda, Inc.  All Rights Reserved.
2 #
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.
6 #
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
10 # for more details.
11 #
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
15 #
16 # Contact information: Zmanda Inc, 465 S. Mathilda Ave., Suite 300
17 # Sunnyvale, CA 94086, USA, or: http://www.zmanda.com
18
19 use Test::More tests => 5;
20 use strict;
21 use warnings;
22
23 use lib "@amperldir@";
24 use Installcheck::Run qw(run run_get run_err vtape_dir);
25
26 ##
27 # First, check that the script runs -- this is essentially a syntax/strict
28 # check of the script.
29
30 ok(!run('amtapetype'),
31     "'amtapetype' with no arguments returns an error exit status");
32 like($Installcheck::Run::stderr, qr(\AUsage: )i,
33     ".. and gives usage message on stderr");
34
35 ##
36 # Set up a small vtape to write to
37
38 my $testconf = Installcheck::Run::setup();
39 $testconf->add_device("smallvtape", [
40     "tapedev" => '"file:' . vtape_dir() . '"',
41     "device_property" => '"MAX_VOLUME_USAGE" "2m"', # need at least 1M
42 ]);
43 $testconf->write();
44
45 like(run_get('amtapetype', 'TESTCONF', 'smallvtape'),
46     qr/define tapetype unknown-tapetype.*blocksize 32 kbytes/s,
47     "amtapetype runs successfully on a small vtape");
48
49 ok(run_err('amtapetype', 'TESTCONF', 'smallvtape'),
50     "a second run on the same device fails because -f isn't used") or die;
51
52 like(run_get('amtapetype', 'TESTCONF', '-f', '-b', '33000', 'smallvtape'),
53     qr/add device-property/,
54     "with a non-kilobyte block size, directs user to add a device_property");