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 => 7;
21 use lib "@amperldir@";
22 use Installcheck::Config;
23 use Installcheck::Run qw(run run_get run_err $diskname);
24 use File::Path qw(rmtree mkpath);
31 my $testdir = "$AMANDA_TMPDIR/amfetchdump-installcheck";
39 for my $filename (<$testdir/*>) {
44 $testconf = Installcheck::Run::setup();
45 $testconf->add_param('label_new_tapes', '"TESTCONF%%"');
46 $testconf->add_dle("localhost $diskname installcheck-test");
49 run('amdump', 'TESTCONF')
50 or BAIL_OUT("amdump run failed");
52 like(run_err('amfetchdump', 'TESTCONF'),
54 "'amfetchdump TESTCONF' gives usage message on stderr");
57 skip "Expect.pm not installed", 2
58 unless $Installcheck::Run::have_expect;
62 my $exp = Installcheck::Run::run_expect('amfetchdump', 'TESTCONF', 'localhost');
67 [ qr{1 tape\(s\) needed for restoration}, sub {
68 push @results, "tapes-needed";
71 [ qr{amfetchdump: 1: restoring FILE: date [[:digit:]]+ host localhost disk .*},
73 push @results, "restoring";
76 [ 'Press enter when ready', sub {
77 push @results, "press-enter";
85 is_deeply([ @results ], [ "tapes-needed", "press-enter", "restoring", "eof" ],
86 "simple restore follows the correct steps");
88 my @filenames = <localhost.*>;
89 is(scalar @filenames, 1, "..and restored file is present in testdir")
90 or diag(join("\n", @filenames));
96 ok(run('amfetchdump', '-a', 'TESTCONF', 'localhost'),
97 "run with -a successful");
99 my @filenames = <localhost.*>;
100 is(scalar @filenames, 1, "..and restored file is present in testdir")
101 or diag(join("\n", @filenames));
105 skip "Expect.pm not installed", 2
106 unless $Installcheck::Run::have_expect;
109 chdir($AMANDA_TMPDIR);
111 my $exp = Installcheck::Run::run_expect('amfetchdump', '-O', $testdir, 'TESTCONF', 'localhost');
116 [ qr{1 tape\(s\) needed for restoration}, sub {
117 push @results, "tapes-needed";
120 [ qr{amfetchdump: 1: restoring FILE: date [[:digit:]]+ host localhost disk .*},
122 push @results, "restoring";
125 [ 'Press enter when ready', sub {
126 push @results, "press-enter";
131 push @results, "eof";
134 is_deeply([ @results ], [ "tapes-needed", "press-enter", "restoring", "eof" ],
135 "restore with -O follows the correct steps");
138 my @filenames = <localhost.*>;
139 is(scalar @filenames, 1, "..and restored file is present in testdir")
140 or diag(join("\n", @filenames));
144 # - test piping (-p),
145 # - test compression (-c and -C)
146 # - test a specified device (-d)
147 # - test splits (regular, -w, -n)
150 chdir("$testdir/..");