1 # Copyright (c) 2007,2008 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;
21 use lib "@amperldir@";
22 use Installcheck::Config;
23 use Installcheck::Dumpcache;
24 use Installcheck::Run qw(run run_get run_err $diskname);
30 # First, try amgetconf out without a config
32 ok(!run('amcheckdump'),
33 "amcheckdump with no arguments returns an error exit status");
34 like($Installcheck::Run::stdout, qr/\AUSAGE:/i,
35 ".. and gives usage message");
37 like(run_err('amcheckdump', 'this-probably-doesnt-exist'), qr(could not open conf file)i,
38 "run with non-existent config fails with an appropriate error message.");
41 # Now use a config with a vtape and without usetimestamps
43 $testconf = Installcheck::Run::setup();
46 ok(run('amcheckdump', 'TESTCONF'),
47 "amcheckdump with a new config succeeds");
48 like($Installcheck::Run::stdout, qr(could not find)i,
49 "..but finds no dumps.");
51 Installcheck::Dumpcache::load("notimestamps");
53 like(run_get('amcheckdump', 'TESTCONF'), qr(Validating),
54 "amcheckdump succeeds, claims to validate something (usetimestamps=no)");
57 # and check command-line handling
59 like(run_get('amcheckdump', 'TESTCONF', '-oorg=installcheck'), qr(Validating),
60 "amcheckdump accepts '-o' options on the command line");
63 # Try with usetimestamps enabled
65 Installcheck::Dumpcache::load("basic");
67 like(run_get('amcheckdump', 'TESTCONF'), qr(Validating),
68 "amcheckdump succeeds, claims to validate something (usetimestamps=yes)");
71 # now try zeroing out the dumps
73 my $vtape1 = Installcheck::Run::vtape_dir(1);
74 opendir(my $vtape_dir, $vtape1) || die "can't opendir $vtape1: $!";
75 @dump1 = grep { /^0+1/ } readdir($vtape_dir);
78 for my $dumpfile (@dump1) {
79 open(my $dumpfh, "+<", "$vtape1/$dumpfile");
80 sysseek($dumpfh, 32768, 0); # jump past the header
81 syswrite($dumpfh, "\0" x 100); # and write some zeroes
85 ok(!run('amcheckdump', 'TESTCONF'),
86 "amcheckdump detects a failure from a zeroed-out dumpfile");
88 Installcheck::Run::cleanup();