1# Copyright (c) 2008-2013 Zmanda, Inc.  All Rights Reserved.
2#
3# This program is free software; you can redistribute it and/or
4# modify it under the terms of the GNU General Public License
5# as published by the Free Software Foundation; either version 2
6# of the License, or (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful, but
9# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
11# for more details.
12#
13# You should have received a copy of the GNU General Public License along
14# with this program; if not, write to the Free Software Foundation, Inc.,
15# 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16#
17# Contact information: Zmanda Inc, 465 S. Mathilda Ave., Suite 300
18# Sunnyvale, CA 94086, USA, or: http://www.zmanda.com
19
20use Test::More tests => 5;
21use strict;
22use warnings;
23
24use lib "@amperldir@";
25use Installcheck::Run qw(run run_get run_err vtape_dir);
26
27##
28# First, check that the script runs -- this is essentially a syntax/strict
29# check of the script.
30
31ok(!run('amtapetype'),
32    "'amtapetype' with no arguments returns an error exit status");
33like($Installcheck::Run::stderr, qr(\AUsage: )i,
34    ".. and gives usage message on stderr");
35
36##
37# Set up a small vtape to write to
38
39my $testconf = Installcheck::Run::setup();
40$testconf->add_device("smallvtape", [
41    "tapedev" => '"file:' . vtape_dir() . '"',
42    "device_property" => '"MAX_VOLUME_USAGE" "2m"', # need at least 1M
43]);
44$testconf->write();
45
46like(run_get('amtapetype', 'TESTCONF', 'smallvtape'),
47    qr/define tapetype unknown-tapetype.*blocksize 32 kbytes/s,
48    "amtapetype runs successfully on a small vtape");
49
50ok(run_err('amtapetype', 'TESTCONF', 'smallvtape'),
51    "a second run on the same device fails because -f isn't used") or die;
52
53like(run_get('amtapetype', 'TESTCONF', '-f', '-b', '33000', 'smallvtape'),
54    qr/add device-property/,
55    "with a non-kilobyte block size, directs user to add a device_property");
56