1 # Copyright (c) 2008, 2009, 2010 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. Mathilda Ave., Suite 300
17 # Sunnyvale, CA 94086, USA, or: http://www.zmanda.com
19 use Test::More tests => 18;
23 use lib "@amperldir@";
25 use Installcheck::Run qw( run run_get );
27 use Amanda::Constants;
28 use File::Path qw( mkpath rmtree );
30 my $tmpdir = "$Installcheck::TMP/amarchiver-installcheck";
31 my $archfile = "$tmpdir/test.amar";
32 my $data = "abcd" x 500;
39 open($fh, ">", "test.tmp-1");
43 open($fh, ">", "test.tmp-2");
47 ok(run('amarchiver', '--version'),
48 "amarchiver --version OK");
49 like($Installcheck::Run::stdout,
51 "..and output is reasonable");
53 # test creating archives
55 ok(run('amarchiver', '--create', "test.tmp-1"),
56 "archive creation without --file succeeds");
57 like($Installcheck::Run::stdout, qr{^AMANDA ARCHIVE FORMAT },
58 "..and produces something that looks like an archive");
61 ok(run('amarchiver', '--create', '--file', $archfile,
62 "$sbindir/amarchiver", "$sbindir/amgetconf"),
63 "archive creation succeeds");
64 ok(-f $archfile, "..and target file exists");
67 ok(run('amarchiver', '--create', '--verbose', '--file', $archfile,
68 "$sbindir/amarchiver", "$sbindir/amgetconf"),
69 "archive creation with --verbose succeeds");
70 like($Installcheck::Run::stdout,
71 qr{^\Q$sbindir\E/amarchiver\n\Q$sbindir\E/amgetconf$},
72 "..and output is correct");
74 ok(run('amarchiver', '--create', '--verbose', $archfile),
75 "archive creation with --verbose and without --file succeeds");
76 like($Installcheck::Run::stderr,
78 "..and output goes to stderr");
81 ok(run('amarchiver', '--create', '--verbose', '--verbose', '--file', $archfile,
82 "$sbindir/amarchiver", "$sbindir/amgetconf", "test.tmp-1"),
83 "archive creation with two --verbose args succeeds");
84 like($Installcheck::Run::stdout,
85 qr{^[[:digit:]]+ \Q$sbindir\E/amarchiver\n[[:digit:]]+ \Q$sbindir\E/amgetconf\n2000 test.tmp-1$},
86 "..and output is correct");
88 # test listing archives
90 run('amarchiver', '--create', '--file', $archfile, "test.tmp-1", "test.tmp-2")
91 or BAIL_OUT("could not create an archive to test listing/extracting");
93 ok(run('amarchiver', '--list', '--file', $archfile),
94 "archive listing succeeds");
95 is($Installcheck::Run::stdout, "test.tmp-1\ntest.tmp-2\n",
96 "..and output is correct");
98 # test extracting archives
100 unlink("test.tmp-1.16");
101 unlink("test.tmp-2.16");
102 ok(run('amarchiver', '--extract', '--file', $archfile),
103 "archive extraction succeeds");
104 ok((-f "test.tmp-1.16" && -f "test.tmp-2.16"), "..and the files reappear")
107 unlink("test.tmp-1.16");
108 unlink("test.tmp-2.16");
109 ok(run('amarchiver', '--extract', '--file', $archfile, "test.tmp-2"),
110 "archive extraction of only one file succeeds");
111 ok((! -f "test.tmp-1.16" && -f "test.tmp-2.16"), "..and the file reappears")