1 # Copyright (c) 2008-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 => 18;
24 use lib "@amperldir@";
26 use Installcheck::Run qw( run run_get );
28 use Amanda::Constants;
29 use File::Path qw( mkpath rmtree );
31 my $tmpdir = "$Installcheck::TMP/amarchiver-installcheck";
32 my $archfile = "$tmpdir/test.amar";
33 my $data = "abcd" x 500;
40 open($fh, ">", "test.tmp-1");
44 open($fh, ">", "test.tmp-2");
48 ok(run('amarchiver', '--version'),
49 "amarchiver --version OK");
50 like($Installcheck::Run::stdout,
52 "..and output is reasonable");
54 # test creating archives
56 ok(run('amarchiver', '--create', "test.tmp-1"),
57 "archive creation without --file succeeds");
58 like($Installcheck::Run::stdout, qr{^AMANDA ARCHIVE FORMAT },
59 "..and produces something that looks like an archive");
62 ok(run('amarchiver', '--create', '--file', $archfile,
63 "$sbindir/amarchiver", "$sbindir/amgetconf"),
64 "archive creation succeeds");
65 ok(-f $archfile, "..and target file exists");
68 ok(run('amarchiver', '--create', '--verbose', '--file', $archfile,
69 "$sbindir/amarchiver", "$sbindir/amgetconf"),
70 "archive creation with --verbose succeeds");
71 like($Installcheck::Run::stdout,
72 qr{^\Q$sbindir\E/amarchiver\n\Q$sbindir\E/amgetconf$},
73 "..and output is correct");
75 ok(run('amarchiver', '--create', '--verbose', $archfile),
76 "archive creation with --verbose and without --file succeeds");
77 like($Installcheck::Run::stderr,
79 "..and output goes to stderr");
82 ok(run('amarchiver', '--create', '--verbose', '--verbose', '--file', $archfile,
83 "$sbindir/amarchiver", "$sbindir/amgetconf", "test.tmp-1"),
84 "archive creation with two --verbose args succeeds");
85 like($Installcheck::Run::stdout,
86 qr{^[[:digit:]]+ \Q$sbindir\E/amarchiver\n[[:digit:]]+ \Q$sbindir\E/amgetconf\n2000 test.tmp-1$},
87 "..and output is correct");
89 # test listing archives
91 run('amarchiver', '--create', '--file', $archfile, "test.tmp-1", "test.tmp-2")
92 or BAIL_OUT("could not create an archive to test listing/extracting");
94 ok(run('amarchiver', '--list', '--file', $archfile),
95 "archive listing succeeds");
96 is($Installcheck::Run::stdout, "test.tmp-1\ntest.tmp-2\n",
97 "..and output is correct");
99 # test extracting archives
101 unlink("test.tmp-1.16");
102 unlink("test.tmp-2.16");
103 ok(run('amarchiver', '--extract', '--file', $archfile),
104 "archive extraction succeeds");
105 ok((-f "test.tmp-1.16" && -f "test.tmp-2.16"), "..and the files reappear")
108 unlink("test.tmp-1.16");
109 unlink("test.tmp-2.16");
110 ok(run('amarchiver', '--extract', '--file', $archfile, "test.tmp-2"),
111 "archive extraction of only one file succeeds");
112 ok((! -f "test.tmp-1.16" && -f "test.tmp-2.16"), "..and the file reappears")