1 # Copyright (c) 2009-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 => 15;
22 use lib "@amperldir@";
26 use Amanda::Constants;
30 use Installcheck::Application;
33 unless ($Amanda::Constants::GNUTAR and -x $Amanda::Constants::GNUTAR) {
35 skip("GNU tar is not available", Test::More->builder->expected_tests);
40 my $app = Installcheck::Application->new('amraw');
42 my $support = $app->support();
43 is($support->{'INDEX-LINE'}, 'YES', "supports indexing");
44 is($support->{'MESSAGE-LINE'}, 'YES', "supports messages");
46 my $root_dir = "$Installcheck::TMP/installcheck-amraw";
47 my $back_file = "$root_dir/to_backup";
48 my $rest_dir = "$root_dir/restore";
50 File::Path::mkpath($root_dir);
51 File::Path::mkpath($rest_dir);
52 Amanda::Tests::write_random_file(0xabcde, 1024*256, $back_file);
54 my $selfcheck = $app->selfcheck('device' => $back_file, 'level' => 0, 'index' => 'line');
55 is($selfcheck->{'exit_status'}, 0, "error status ok");
56 ok(!@{$selfcheck->{'errors'}}, "no errors during selfcheck");
58 my $backup = $app->backup('device' => $back_file, 'level' => 0, 'index' => 'line');
59 is($backup->{'exit_status'}, 0, "error status ok");
60 ok(!@{$backup->{'errors'}}, "no errors during backup")
61 or diag(@{$backup->{'errors'}});
63 is(length($backup->{'data'}), $backup->{'size'}, "reported and actual size match");
65 ok(@{$backup->{'index'}}, "index is not empty");
66 is_deeply($backup->{'index'}, ["/"], "index is '/'");
68 my $orig_cur_dir = POSIX::getcwd();
69 ok($orig_cur_dir, "got current directory");
71 ok(chdir($rest_dir), "changed working directory (for restore)");
73 my $restore = $app->restore('objects' => ['.'],'data' => $backup->{'data'});
74 is($restore->{'exit_status'}, 0, "error status ok");
76 ok(chdir($orig_cur_dir), "changed working directory (back to original)");
78 my $restore_file = "$rest_dir/amraw-restored";
79 ok(-f "$restore_file", "amraw-restored restored");
80 is(`cmp $back_file $restore_file`, "", "restore match");