1 # Copyright (c) 2005-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 Mathlida 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::Run qw(run run_get run_err $diskname);
29 # First, try amgetconf out without a config
31 ok(!run('amcheckdump'),
32 "amcheckdump with no arguments returns an error exit status");
33 like($Installcheck::Run::stdout, qr/\AUSAGE:/i,
34 ".. and gives usage message");
36 like(run_err('amcheckdump', 'this-probably-doesnt-exist'), qr(could not open conf file)i,
37 "run with non-existent config fails with an appropriate error message.");
40 # Now use a config with a vtape and without usetimestamps
42 $testconf = Installcheck::Run::setup();
43 $testconf->add_param('label_new_tapes', '"TESTCONF%%"');
44 $testconf->add_param('usetimestamps', 'no');
45 $testconf->add_dle("localhost $diskname installcheck-test");
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 BAIL_OUT("amdump failed")
54 unless run('amdump', 'TESTCONF');
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 # And a config with usetimestamps enabled
68 $testconf = Installcheck::Run::setup();
69 $testconf->add_param('label_new_tapes', '"TESTCONF%%"');
70 $testconf->add_param('usetimestamps', 'yes');
71 $testconf->add_dle("localhost $diskname installcheck-test");
74 BAIL_OUT("amdump failed")
75 unless run('amdump', 'TESTCONF');
77 like(run_get('amcheckdump', 'TESTCONF'), qr(Validating),
78 "amcheckdump succeeds, claims to validate something (usetimestamps=yes)");
81 # now try zeroing out the dumps
83 my $vtape1 = Installcheck::Run::vtape_dir(1);
84 opendir(my $vtape_dir, $vtape1) || die "can't opendir $vtape1: $!";
85 @dump1 = grep { /^0+1/ } readdir($vtape_dir);
88 for my $dumpfile (@dump1) {
89 open(my $dumpfh, "+<", "$vtape1/$dumpfile");
90 sysseek($dumpfh, 32768, 0); # jump past the header
91 syswrite($dumpfh, "\0" x 100); # and write some zeroes
95 ok(!run('amcheckdump', 'TESTCONF'),
96 "amcheckdump detects a failure from a zeroed-out dumpfile");
98 Installcheck::Run::cleanup();