1 # Copyright (c) 2007-2012 Zmanda, Inc. All Rights Reserved.
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.
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
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
17 # Contact information: Zmanda Inc, 465 S. Mathilda Ave., Suite 300
18 # Sunnyvale, CA 94086, USA, or: http://www.zmanda.com
20 use Test::More tests => 9;
24 use lib "@amperldir@";
25 use Installcheck::Config;
26 use Installcheck::Dumpcache;
27 use Installcheck::Run qw(run run_get run_err $diskname);
33 # First, try amgetconf out without a config
35 ok(!run('amcheckdump'),
36 "amcheckdump with no arguments returns an error exit status");
37 like($Installcheck::Run::stdout, qr/\AUSAGE:/i,
38 ".. and gives usage message");
40 like(run_err('amcheckdump', 'this-probably-doesnt-exist'), qr(could not open conf file)i,
41 "run with non-existent config fails with an appropriate error message.");
44 # Now use a config with a vtape and without usetimestamps
46 $testconf = Installcheck::Run::setup();
49 ok(run('amcheckdump', 'TESTCONF'),
50 "amcheckdump with a new config succeeds");
51 like($Installcheck::Run::stdout, qr(could not find)i,
52 "..but finds no dumps.");
54 Installcheck::Dumpcache::load("notimestamps");
56 like(run_get('amcheckdump', 'TESTCONF'), qr(Validating),
57 "amcheckdump succeeds, claims to validate something (usetimestamps=no)");
60 # and check command-line handling
62 like(run_get('amcheckdump', 'TESTCONF', '-oorg=installcheck'), qr(Validating),
63 "amcheckdump accepts '-o' options on the command line");
66 # Try with usetimestamps enabled
68 Installcheck::Dumpcache::load("basic");
70 like(run_get('amcheckdump', 'TESTCONF'), qr(Validating),
71 "amcheckdump succeeds, claims to validate something (usetimestamps=yes)");
74 # now try zeroing out the dumps
76 my $vtape1 = Installcheck::Run::vtape_dir(1);
77 opendir(my $vtape_dir, $vtape1) || die "can't opendir $vtape1: $!";
78 my @dump1 = grep { /^0+1/ } readdir($vtape_dir);
81 for my $dumpfile (@dump1) {
82 open(my $dumpfh, "+<", "$vtape1/$dumpfile");
83 sysseek($dumpfh, 32768, 0); # jump past the header
84 syswrite($dumpfh, "\0" x 100); # and write some zeroes
88 ok(!run('amcheckdump', 'TESTCONF'),
89 "amcheckdump detects a failure from a zeroed-out dumpfile");
91 Installcheck::Run::cleanup();