Fixes to match new Q construct processing. Use proper login process in the

fake IS server so that the servers feel at home with it.


git-svn-id: http://repo.ham.fi/svn/aprsc/trunk@390 3ce903b1-3385-4e86-93cd-f9a4a239f7ac
This commit is contained in:
Heikki Hannikainen 2012-06-04 14:45:44 +00:00
parent cc2891faeb
commit 332da2c956
3 changed files with 22 additions and 34 deletions

View File

@ -3,14 +3,16 @@
#
use Test;
BEGIN { plan tests => 2 + 5 + 2 + 2 + 2 };
BEGIN { plan tests => 2 + 6 + 2 + 3 + 2 };
use runproduct;
use istest;
use Ham::APRS::IS;
use Ham::APRS::IS_Fake;
ok(1); # If we made it this far, we're ok.
my $iss1 = new Ham::APRS::IS_Fake('127.0.0.1:54153', 'CORE1');
my $upstream_call = 'FAKEUP';
my $iss1 = new Ham::APRS::IS_Fake('127.0.0.1:54153', $upstream_call);
ok(defined $iss1, 1, "Test failed to initialize listening server socket (IPv4)");
$iss1->bind_and_listen();
@ -28,11 +30,7 @@ ok(defined $i_rx, 1, "Failed to initialize Ham::APRS::IS");
my $is1 = $iss1->accept();
ok(defined $is1, (1), "Failed to accept connection 1 from server");
#warn "sending login prompt\n";
$iss1->send_login_prompt($is1);
#warn "sending login ok\n";
$iss1->send_login_ok($is1);
ok($iss1->process_login($is1), 'ok', "Failed to accept login 1 from server");
my $ret;
$ret = $i_rx->connect('retryuntil' => 8);
@ -57,14 +55,14 @@ ok($ret, 1, "Failed to connect to the server: " . $i_rx->{'error'});
# (2):
istest::txrx(\&ok, $is1, $i_rx,
"SRC>DST,DIGI1,DIGI2*,qAI,FOOBA,BLAA:testing qAI (1)",
"SRC>DST,DIGI1,DIGI2*,qAI,FOOBA,BLAA,7F000001,$server_call:testing qAI (1)");
"SRC>DST,DIGI1,DIGI2*,qAI,FOOBA,BLAA,$upstream_call,$server_call:testing qAI (1)");
# unbind the IPv4 server and create IPv6 server
$iss1->unbind();
#warn "switching to ipv6\n";
my $iss6 = new Ham::APRS::IS_Fake('[::1]:54153', 'CORE6');
my $iss6 = new Ham::APRS::IS_Fake('[::1]:54153', $upstream_call);
ok(defined $iss6, 1, "Test failed to initialize listening server socket on IPv6");
$iss6->bind_and_listen();
@ -76,13 +74,12 @@ $is1->disconnect();
my $is6 = $iss6->accept();
ok(defined $is6, (1), "Failed to accept connection ipv6 from server");
$iss6->send_login_prompt($is6);
$iss6->send_login_ok($is6);
ok($iss6->process_login($is6), 'ok', "Failed to accept login ipv6 from server");
# (2), ipv6:
istest::txrx(\&ok, $is6, $i_rx,
"SRC>DST,DIGI1,DIGI2*,qAI,FOOBAR,BLAA:testing qAI (ipv6)",
"SRC>DST,DIGI1,DIGI2*,qAI,FOOBAR,BLAA,00000000000000000000000000000001,$server_call:testing qAI (ipv6)");
"SRC>DST,DIGI1,DIGI2*,qAI,FOOBAR,BLAA,$upstream_call,$server_call:testing qAI (ipv6)");
# disconnect
$ret = $i_rx->disconnect();

View File

@ -24,7 +24,7 @@ BEGIN {
if ($append) {
push @l, "D" x $append;
} elsif (@l) {
$l[$#l] .= '*';
$l[$#l] =~ s/(.)$/,Y/;
}
#warn join(',', @l) . "\n";
my $packet = "SRC>DST,qAI," . join(',', @l) . ":$data";
@ -33,12 +33,12 @@ BEGIN {
push @packets, $packet;
}
plan tests => 6 + ($#packets+1) + 5;
plan tests => 7 + ($#packets+1) + 5;
};
ok(1); # If we made it this far, we're ok.
my $iss6 = new Ham::APRS::IS_Fake('[::1]:54153', 'CORE6');
my $iss6 = new Ham::APRS::IS_Fake('[::1]:54153', 'FAKEIS');
ok(defined $iss6, 1, "Test failed to initialize listening server socket on IPv6");
$iss6->bind_and_listen();
@ -54,9 +54,7 @@ ok(defined $i_rx, 1, "Failed to initialize Ham::APRS::IS");
my $is6 = $iss6->accept();
ok(defined $is6, (1), "Failed to accept connection ipv6 from server");
$iss6->send_login_prompt($is6);
my $log2 = $is6->getline_noncomment(1);
$iss6->send_login_ok($is6);
ok($iss6->process_login($is6), 'ok', "Failed to accept login ipv6 from server");
my $ret;
$ret = $i_rx->connect('retryuntil' => 8);
@ -65,11 +63,12 @@ ok($ret, 1, "Failed to connect to the server: " . $i_rx->{'error'});
# do the actual tests
my $maxlen = 509;
$maxlen = 510 if ($ENV{'TEST_PRODUCT'} eq 'javap');
$maxlen = 510 if (defined $ENV{'TEST_PRODUCT'} && $ENV{'TEST_PRODUCT'} =~ /^javap/);
foreach my $packet (@packets) {
my $expect = $packet;
$expect =~ s/:/,00000000000000000000000000000001,$server_call:/;
$expect =~ s/:/,FAKEIS,$server_call:/;
#warn "tx: $packet\n";
if (length($expect) > $maxlen) {
$is6->sendline($packet);
ok(1);

View File

@ -33,16 +33,16 @@ BEGIN {
push @packets, $packet;
}
plan tests => 8 + ($#packets+1) + 2 + 2;
plan tests => 9 + ($#packets+1) + 2 + 2;
};
ok(1); # If we made it this far, we're ok.
my $iss1 = new Ham::APRS::IS_Fake('127.0.0.1:54153', 'CORE1');
my $iss1 = new Ham::APRS::IS_Fake('127.0.0.1:54153', 'FAKE4');
ok(defined $iss1, 1, "Test failed to initialize listening server socket");
$iss1->bind_and_listen();
my $iss6 = new Ham::APRS::IS_Fake('[::1]:54153', 'CORE6');
my $iss6 = new Ham::APRS::IS_Fake('[::1]:54153', 'FAKE6');
ok(defined $iss6, 1, "Test failed to initialize listening server socket on IPv6");
$iss6->bind_and_listen();
@ -56,17 +56,9 @@ my $server_call = "TESTING";
my $i_rx = new Ham::APRS::IS("localhost:55152", $login);
ok(defined $i_rx, 1, "Failed to initialize Ham::APRS::IS");
#my $is1 = $iss1->accept();
#ok(defined $is1, (1), "Failed to accept connection 1 from server");
#$iss1->send_login_prompt($is1);
#my $log1 = $is1->getline_noncomment(1);
#$iss1->send_login_ok($is1);
my $is6 = $iss6->accept();
ok(defined $is6, (1), "Failed to accept connection ipv6 from server");
$iss6->send_login_prompt($is6);
my $log2 = $is6->getline_noncomment(1);
$iss6->send_login_ok($is6);
ok($iss6->process_login($is6), 'ok', "Failed to accept login ipv6 from server");
my $ret;
$ret = $i_rx->connect('retryuntil' => 8);
@ -75,12 +67,12 @@ ok($ret, 1, "Failed to connect to the server: " . $i_rx->{'error'});
# do the actual tests
my $maxlen = 509;
$maxlen = 510 if ($ENV{'TEST_PRODUCT'} eq 'javap');
$maxlen = 510 if (defined $ENV{'TEST_PRODUCT'} && $ENV{'TEST_PRODUCT'} =~ /^javap/);
# (1):
foreach my $packet (@packets) {
my $expect = $packet;
$expect =~ s/IGATE:/IGATE,00000000000000000000000000000001,$server_call:/;
$expect =~ s/IGATE:/IGATE,FAKE6,$server_call:/;
if (length($expect) > $maxlen) {
my $res = $is6->sendline($packet);
if ($res) {