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