summaryrefslogtreecommitdiffstats
path: root/3rdparty/openpgm-svn-r1085/pgm/test/odata_number.pl
blob: 2d442dc40d5a3c708c78977585126435b7b6e2e0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/perl
# odata_number.pl
# 5.1.1. Maximum Cumulative Transmit Rate

use strict;
use PGM::Test;

BEGIN { require "test.conf.pl"; }

$| = 1;

my $mon = PGM::Test->new(tag => 'mon', host => $config{mon}{host}, cmd => $config{mon}{cmd});
my $app = PGM::Test->new(tag => 'app', host => $config{app}{host}, cmd => $config{app}{cmd});

$mon->connect;
$app->connect;

sub close_ssh {
	$mon = $app = undef;
	print "finished.\n";
}

$SIG{'INT'} = sub { print "interrupt caught.\n"; close_ssh(); };

$mon->say ("filter $config{app}{ip}");
print "mon: ready.\n";

$app->say ("create ao");
$app->say ("bind ao");
$app->say ("listen ao");

print "app: send 1000 data packets ...\n";
# hide stdout
open(OLDOUT, ">&STDOUT");
open(STDOUT, ">/dev/null") or die "Can't redirect stdout: $!";

for (0..999)
{
	my $i = $_;
	$app->say ("send ao $i");
	my $odata = $mon->wait_for_odata;

	die "out of sequence ODATA, received $odata->{PGM}->{odSqn} expected $i\n" unless $odata->{PGM}->{odSqn} == $i;
}

# restore stdout
close(STDOUT) or die "Can't close STDOUT: $!";
open(STDOUT, ">&OLDOUT") or die "Can't restore stdout: $!";
close(OLDOUT) or die "Can't close OLDOUT: $!";

print "mon: received 1000 x odata.\n";

print "test completed successfully.\n";

$mon->disconnect (1);
$app->disconnect;
close_ssh;

# eof