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 => 18;
21 use lib "@amperldir@";
22 use Installcheck::Run qw( run run_get );
24 use Amanda::Constants;
25 use File::Path qw( mkpath rmtree );
27 my $tmpdir = "$AMANDA_TMPDIR/amarchiver-installcheck";
28 my $archfile = "$tmpdir/test.amar";
29 my $data = "abcd" x 500;
36 open($fh, ">", "test.tmp-1");
40 open($fh, ">", "test.tmp-2");
44 ok(run('amarchiver', '--version'),
45 "amarchiver --version OK");
46 like($Installcheck::Run::stdout,
48 "..and output is reasonable");
50 # test creating archives
52 ok(run('amarchiver', '--create', "test.tmp-1"),
53 "archive creation without --file succeeds");
54 like($Installcheck::Run::stdout, qr{^AMANDA ARCHIVE FORMAT },
55 "..and produces something that looks like an archive");
58 ok(run('amarchiver', '--create', '--file', $archfile,
59 "$sbindir/amarchiver", "$sbindir/amgetconf"),
60 "archive creation succeeds");
61 ok(-f $archfile, "..and target file exists");
64 ok(run('amarchiver', '--create', '--verbose', '--file', $archfile,
65 "$sbindir/amarchiver", "$sbindir/amgetconf"),
66 "archive creation with --verbose succeeds");
67 like($Installcheck::Run::stdout,
68 qr{^\Q$sbindir\E/amarchiver\n\Q$sbindir\E/amgetconf$},
69 "..and output is correct");
71 ok(run('amarchiver', '--create', '--verbose', $archfile),
72 "archive creation with --verbose and without --file succeeds");
73 like($Installcheck::Run::stderr,
75 "..and output goes to stderr");
78 ok(run('amarchiver', '--create', '--verbose', '--verbose', '--file', $archfile,
79 "$sbindir/amarchiver", "$sbindir/amgetconf", "test.tmp-1"),
80 "archive creation with two --verbose args succeeds");
81 like($Installcheck::Run::stdout,
82 qr{^[[:digit:]]+ \Q$sbindir\E/amarchiver\n[[:digit:]]+ \Q$sbindir\E/amgetconf\n2000 test.tmp-1$},
83 "..and output is correct");
85 # test listing archives
87 run('amarchiver', '--create', '--file', $archfile, "test.tmp-1", "test.tmp-2")
88 or BAIL_OUT("could not create an archive to test listing/extracting");
90 ok(run('amarchiver', '--list', '--file', $archfile),
91 "archive listing succeeds");
92 is($Installcheck::Run::stdout, "test.tmp-1\ntest.tmp-2\n",
93 "..and output is correct");
95 # test extracting archives
97 unlink("test.tmp-1.16");
98 unlink("test.tmp-2.16");
99 ok(run('amarchiver', '--extract', '--file', $archfile),
100 "archive extraction succeeds");
101 ok((-f "test.tmp-1.16" && -f "test.tmp-2.16"), "..and the files reappear")
104 unlink("test.tmp-1.16");
105 unlink("test.tmp-2.16");
106 ok(run('amarchiver', '--extract', '--file', $archfile, "test.tmp-2"),
107 "archive extraction of only one file succeeds");
108 ok((! -f "test.tmp-1.16" && -f "test.tmp-2.16"), "..and the file reappears")