Imported Upstream version 3.3.3
[debian/amanda] / installcheck / amcheck-device.pl
1 # Copyright (c) 2009-2012 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
20 use Test::More tests => 4;
21 use strict;
22 use warnings;
23
24 use lib "@amperldir@";
25 use Installcheck::Run qw(run run_get run_err);
26 use Amanda::Config qw( :init :getconf );
27 use Amanda::Paths;
28 use Amanda::Debug;
29
30 my $testconf;
31
32 Amanda::Debug::dbopen("installcheck");
33 Installcheck::log_test_output();
34
35 $testconf = Installcheck::Run::setup();
36 $testconf->add_param("autolabel", "\"TESTCONF%%\" empty volume_error");
37 $testconf->write();
38
39 like(run_get("$amlibexecdir/amcheck-device", "TESTCONF"),
40     qr/Will write label 'TESTCONF01' to new volume/,
41     "a run of amcheck-device on a new config succeeds");
42
43 ok(!run("$amlibexecdir/amcheck-device", "TESTCONF", "-o", "autolabel="),
44     "accepts config_overrides, returns exit status on failure");
45
46 like(run_get("$amlibexecdir/amcheck-device", "TESTCONF", "-w"),
47     qr/Volume 'TESTCONF01' is writeable/,
48     "tests for writeability with -w");
49
50 $testconf = Installcheck::Run::setup();
51 $testconf->add_param("autolabel", "\"TESTCONF-\$4s\" empty volume_error");
52 $testconf->write();
53
54 like(run_err("$amlibexecdir/amcheck-device", "TESTCONF"),
55     qr/ERROR: Newly-generated label 'TESTCONF-0001' does not match labelstr 'TESTCONF\[0-9\]\[0-9\]'/m,
56     "a run with incompatible autolabel and labelstr");
57