Subject: | Calling non-existent timeout method |
After upgrading libnet from 3.07 to 3.08, I receive a test failure in Net-SNPP-1.17. It complains on undefined timeout() method:
$ perl -Ilib -I/home/test/fedora/perl-libnet/libnet-3.08/lib t/server.t
1..15
ok 1 - use Net::SNPP::Server;
ok 2 - use Net::SNPP;
ok 3 - created a server
# test server up and running on 20444
# attempting to connect to server using Net::SNPP
Can't locate object method "timeout" via package "Net::SNPP::Server" at /home/test/fedora/perl-libnet/libnet-3.08/lib/Net/Cmd.pm line 201.
not ok 4 - connected to server using Net::SNPP client
# Failed test 'connected to server using Net::SNPP client'
# at t/server.t line 32.
Can't call method "ping" on an undefined value at t/server.t line 39.
# Looks like you planned 15 tests but ran 4.
# Looks like you failed 1 test of 4 run.
# Looks like your test exited with 9 just after 4.
The Net::SMP::Server inherits from Net::Cmd and Net::Cmd on line 201 is:
sub _syswrite_with_timeout {
my $cmd = shift;
my $line = shift;
my $len = length($line);
my $offset = 0;
my $win = "";
vec($win, fileno($cmd), 1) = 1;
→ my $timeout = $cmd->timeout || undef;
[...]
}
It looks like Net::Cmd expects the extending class should define the timeout() method, but Net::Cmd documentation does not document this requirement.
So either it's a bug in Net::Cmd documentation, or Net::Cmd should define the method too, or the check for $cmd->timeout value should be more robust to cope with missing timeout() method.
What's your opinion?