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