Imported Upstream version 3.3.3
[debian/amanda] / installcheck / noop.pl
1 # Copyright (c) 2010-2012 Zmanda, Inc.  All Rights Reserved.
2 #
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.
7 #
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
11 # for more details.
12 #
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
16 #
17 # Contact information: Zmanda Inc, 465 S. Mathilda Ave., Suite 300
18 # Sunnyvale, CA 94086, USA, or: http://www.zmanda.com
19
20 use Test::More tests => 6;
21
22 use strict;
23 use warnings;
24
25 use lib '@amperldir@';
26 use Installcheck;
27 use Installcheck::ClientService;
28 use Amanda::Debug;
29 use Amanda::MainLoop;
30
31 Amanda::Debug::dbopen("installcheck");
32 Installcheck::log_test_output();
33
34 {
35     my $service;
36     my ($got_options, $got_eof, $process_done);
37
38     $got_options = sub {
39         pass("got OPTIONS");
40
41         $service->expect('main',
42             [ eof => $got_eof ]);
43     };
44
45     # note that this gets called four times, in arbitrary order
46     $got_eof = sub {
47         pass("got EOF");
48     };
49
50     $process_done = sub {
51         my ($exitstatus) = @_;
52         is($exitstatus, 0,
53             "exit status 0");
54         Amanda::MainLoop::quit();
55     };
56
57     $service = Installcheck::ClientService->new(
58             service => 'noop',
59             emulate => 'amandad',
60             process_done => $process_done);
61     # no REQ packet body
62     $service->close('main', 'w');
63     $service->expect('main',
64         [ re => qr/OPTIONS features=[0-9a-f]+;\n/, $got_options ]);
65     $service->expect('stream1', [ eof => $got_eof ]);
66     $service->expect('stream2', [ eof => $got_eof ]);
67     $service->expect('stream3', [ eof => $got_eof ]);
68     Amanda::MainLoop::run();
69 }