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