1 # Copyright (c) 2008,2009 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;
21 use lib "@amperldir@";
23 use Installcheck::Run qw( run run_get );
25 use Amanda::Constants;
26 use File::Path qw( mkpath rmtree );
28 my $tmpdir = "$Installcheck::TMP/amarchiver-installcheck";
29 my $archfile = "$tmpdir/test.amar";
30 my $data = "abcd" x 500;
37 open($fh, ">", "test.tmp-1");
41 open($fh, ">", "test.tmp-2");
45 ok(run('amarchiver', '--version'),
46 "amarchiver --version OK");
47 like($Installcheck::Run::stdout,
49 "..and output is reasonable");
51 # test creating archives
53 ok(run('amarchiver', '--create', "test.tmp-1"),
54 "archive creation without --file succeeds");
55 like($Installcheck::Run::stdout, qr{^AMANDA ARCHIVE FORMAT },
56 "..and produces something that looks like an archive");
59 ok(run('amarchiver', '--create', '--file', $archfile,
60 "$sbindir/amarchiver", "$sbindir/amgetconf"),
61 "archive creation succeeds");
62 ok(-f $archfile, "..and target file exists");
65 ok(run('amarchiver', '--create', '--verbose', '--file', $archfile,
66 "$sbindir/amarchiver", "$sbindir/amgetconf"),
67 "archive creation with --verbose succeeds");
68 like($Installcheck::Run::stdout,
69 qr{^\Q$sbindir\E/amarchiver\n\Q$sbindir\E/amgetconf$},
70 "..and output is correct");
72 ok(run('amarchiver', '--create', '--verbose', $archfile),
73 "archive creation with --verbose and without --file succeeds");
74 like($Installcheck::Run::stderr,
76 "..and output goes to stderr");
79 ok(run('amarchiver', '--create', '--verbose', '--verbose', '--file', $archfile,
80 "$sbindir/amarchiver", "$sbindir/amgetconf", "test.tmp-1"),
81 "archive creation with two --verbose args succeeds");
82 like($Installcheck::Run::stdout,
83 qr{^[[:digit:]]+ \Q$sbindir\E/amarchiver\n[[:digit:]]+ \Q$sbindir\E/amgetconf\n2000 test.tmp-1$},
84 "..and output is correct");
86 # test listing archives
88 run('amarchiver', '--create', '--file', $archfile, "test.tmp-1", "test.tmp-2")
89 or BAIL_OUT("could not create an archive to test listing/extracting");
91 ok(run('amarchiver', '--list', '--file', $archfile),
92 "archive listing succeeds");
93 is($Installcheck::Run::stdout, "test.tmp-1\ntest.tmp-2\n",
94 "..and output is correct");
96 # test extracting archives
98 unlink("test.tmp-1.16");
99 unlink("test.tmp-2.16");
100 ok(run('amarchiver', '--extract', '--file', $archfile),
101 "archive extraction succeeds");
102 ok((-f "test.tmp-1.16" && -f "test.tmp-2.16"), "..and the files reappear")
105 unlink("test.tmp-1.16");
106 unlink("test.tmp-2.16");
107 ok(run('amarchiver', '--extract', '--file', $archfile, "test.tmp-2"),
108 "archive extraction of only one file succeeds");
109 ok((! -f "test.tmp-1.16" && -f "test.tmp-2.16"), "..and the file reappears")