Blame installcheck/amcheck-device.pl

Packit Service 392537
# Copyright (c) 2009-2012 Zmanda, Inc.  All Rights Reserved.
Packit Service 392537
# Copyright (c) 2013-2016 Carbonite, Inc.  All Rights Reserved.
Packit Service 392537
#
Packit Service 392537
# This program is free software; you can redistribute it and/or
Packit Service 392537
# modify it under the terms of the GNU General Public License
Packit Service 392537
# as published by the Free Software Foundation; either version 2
Packit Service 392537
# of the License, or (at your option) any later version.
Packit Service 392537
#
Packit Service 392537
# This program is distributed in the hope that it will be useful, but
Packit Service 392537
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
Packit Service 392537
# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
Packit Service 392537
# for more details.
Packit Service 392537
#
Packit Service 392537
# You should have received a copy of the GNU General Public License along
Packit Service 392537
# with this program; if not, write to the Free Software Foundation, Inc.,
Packit Service 392537
# 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
Packit Service 392537
#
Packit Service 392537
# Contact information: Carbonite Inc., 756 N Pastoria Ave
Packit Service 392537
# Sunnyvale, CA 94086, USA, or: http://www.zmanda.com
Packit Service 392537
Packit Service 392537
use Test::More tests => 4;
Packit Service 392537
use strict;
Packit Service 392537
use warnings;
Packit Service 392537
Packit Service 392537
use lib '@amperldir@';
Packit Service 392537
use Installcheck::Run qw(run run_get run_err);
Packit Service 392537
use Amanda::Config qw( :init :getconf );
Packit Service 392537
use Amanda::Paths;
Packit Service 392537
use Amanda::Debug;
Packit Service 392537
Packit Service 392537
my $testconf;
Packit Service 392537
Packit Service 392537
Amanda::Debug::dbopen("installcheck");
Packit Service 392537
Installcheck::log_test_output();
Packit Service 392537
Packit Service 392537
$testconf = Installcheck::Run::setup();
Packit Service 392537
$testconf->add_param("autolabel", "\"TESTCONF%%\" empty volume_error");
Packit Service 392537
$testconf->write();
Packit Service 392537
Packit Service 392537
like(run_get("$amlibexecdir/amcheck-device", "TESTCONF", "TESTCONF"),
Packit Service 392537
    qr/Will write label 'TESTCONF01' to new volume/,
Packit Service 392537
    "a run of amcheck-device on a new config succeeds");
Packit Service 392537
Packit Service 392537
ok(!run("$amlibexecdir/amcheck-device", "TESTCONF", "TESTCONF", "-o", "autolabel="),
Packit Service 392537
    "accepts config_overrides, returns exit status on failure");
Packit Service 392537
Packit Service 392537
like(run_get("$amlibexecdir/amcheck-device", "TESTCONF", "TESTCONF", "-w"),
Packit Service 392537
    qr/Volume 'TESTCONF01' is writeable/,
Packit Service 392537
    "tests for writeability with -w");
Packit Service 392537
Packit Service 392537
$testconf = Installcheck::Run::setup();
Packit Service 392537
$testconf->add_param("autolabel", "\"TESTCONF-\$4s\" empty volume_error");
Packit Service 392537
$testconf->write();
Packit Service 392537
Packit Service 392537
like(run_get("$amlibexecdir/amcheck-device", "TESTCONF", "TESTCONF"),
Packit Service 392537
    qr/Will write label 'TESTCONF-0001' to new volume in slot 1/,
Packit Service 392537
    "a run with incompatible autolabel and labelstr");
Packit Service 392537