1 # Copyright (c) 2009-2012 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 => 11;
24 use lib "@amperldir@";
26 use Installcheck::Mock;
27 use Amanda::NDMP qw( :constants );
29 my $ndmp = Installcheck::Mock::NdmpServer->new();
32 Amanda::Debug::dbopen("installcheck");
34 $nc = Amanda::NDMP::NDMPConnection->new("127.0.0.1", $ndmp->{'port'},
35 "ndmp", "ndmp", "md5");
36 ok($nc, "constructor creates an object");
37 is($nc->err_code(), 0, "and no error is set");
41 # can't test the scsi_* methods in the general case, because we have nothing to talk
42 # to -- but they were tested once, never fear!
44 ok($nc->tape_open($ndmp->{'drive'}, $NDMP9_TAPE_RDWR_MODE),
47 # the stringification maps here are for old perls, which don't do well
48 # with Math::BigInt and is_deeply.
50 is_deeply([ map { "$_" } $nc->tape_write("ab"x8) ], ['1', '16'],
53 is_deeply([ map { "$_" } $nc->tape_write("cd"x8) ], ['1', '16'],
56 is_deeply([ map { "$_" } $nc->tape_mtio($NDMP9_MTIO_EOF, 1) ], ['1', '0'],
59 is_deeply([ map { "$_" } $nc->tape_mtio($NDMP9_MTIO_REW, 1) ], ['1', '0'],
60 "tape_mtio (rewind)");
62 is_deeply([ map { "$_" } $nc->tape_read(32) ], ['1', "ab"x8], "tape_read");
63 is_deeply([ map { "$_" } $nc->tape_read(32) ], ['1', "cd"x8], "tape_read");
65 is_deeply([ map { "$_" } $nc->tape_get_state() ], ['1', '0', '0', '2'], "tape_get_state");