Note failure as well as success.
[irspy-moved-to-github.git] / lib / ZOOM / IRSpy / Test / Ping.pm
1 # $Id: Ping.pm,v 1.6 2006-07-18 10:40:13 mike Exp $
2
3 # See the "Main" test package for documentation
4
5 package ZOOM::IRSpy::Test::Ping;
6
7 use 5.008;
8 use strict;
9 use warnings;
10
11 use ZOOM::IRSpy::Test;
12 our @ISA;
13 @ISA = qw(ZOOM::IRSpy::Test);
14
15
16 sub run {
17     my $this = shift();
18     my $irspy = $this->irspy();
19     my $pod = $irspy->pod();
20
21     $pod->callback(ZOOM::Event::CONNECT, \&connected);
22     $pod->callback("exception", \&not_connected);
23     my $err = $pod->wait($irspy);
24
25     return 0;
26 }
27
28
29 sub connected { maybe_connected(@_, 1) }
30 sub not_connected { maybe_connected(@_, 0) }
31
32 sub maybe_connected {
33     my($conn, $irspy, $rs, $event, $ok) = @_;
34
35     my $rec = $irspy->record($conn);
36     $irspy->log("irspy_test", $conn->option("host"),
37                 ($ok ? "" : " not"), " connected");
38     $rec->failed(1) if !$ok;
39     ### At this point we should note the successful connection in $rec
40     return 0;
41 }
42
43
44 1;