aprsc/tests/t/60udp-client.t

55 lines
1.3 KiB
Perl

#
# Test UDP client functions
#
use Test;
BEGIN { plan tests => 6 + 1 + 3 };
use runproduct;
use istest;
use Ham::APRS::IS;
use Time::HiRes qw(sleep);
my $p = new runproduct('basic');
ok(defined $p, 1, "Failed to initialize product runner");
ok($p->start(), 1, "Failed to start product");
my $login = "N5CAL-1";
my $server_call = "TESTING";
my $i_tx = new Ham::APRS::IS("localhost:55580", $login);
ok(defined $i_tx, 1, "Failed to initialize Ham::APRS::IS");
# an udp client
my $i_rx = new Ham::APRS::IS("localhost:55152", "N5CAL-2", 'udp' => 51342);
ok(defined $i_rx, 1, "Failed to initialize Ham::APRS::IS");
my $ret;
$ret = $i_tx->connect('retryuntil' => 8);
ok($ret, 1, "Failed to connect to the server: " . $i_tx->{'error'});
$ret = $i_rx->connect('retryuntil' => 8);
ok($ret, 1, "Failed to connect to the server: " . $i_rx->{'error'});
# test ###########################
my $data = "udp packet content";
istest::txrx(\&ok, $i_tx, $i_rx,
"SRC>DST,qAR,$login:$data",
"SRC>DST,qAR,$login:$data");
# disconnect ####################
$ret = $i_rx->disconnect();
ok($ret, 1, "Failed to disconnect from the server: " . $i_rx->{'error'});
$ret = $i_tx->disconnect();
ok($ret, 1, "Failed to disconnect from the server: " . $i_tx->{'error'});
# stop
ok($p->stop(), 1, "Failed to stop product");