dev-perl/Net-ARP: EAPI6 + Tests
authorKent Fredric <kentnl@gentoo.org>
Wed, 13 Dec 2017 09:49:27 +0000 (22:49 +1300)
committerKent Fredric <kentnl@gentoo.org>
Wed, 13 Dec 2017 09:50:20 +0000 (22:50 +1300)
- EAPI6ify
- Enable tests
- Fix tests failing due to '.' in @INC
- Fix tests failing due to assumptions about root/network devices
- Document extended testing strategy

Package-Manager: Portage-2.3.18, Repoman-2.3.6

dev-perl/Net-ARP/Net-ARP-1.0.9-r1.ebuild [new file with mode: 0644]
dev-perl/Net-ARP/files/Net-ARP-1.0.9-perl-5.26.patch [new file with mode: 0644]
dev-perl/Net-ARP/files/Net-ARP-1.0.9-tests.patch [new file with mode: 0644]

diff --git a/dev-perl/Net-ARP/Net-ARP-1.0.9-r1.ebuild b/dev-perl/Net-ARP/Net-ARP-1.0.9-r1.ebuild
new file mode 100644 (file)
index 0000000..30628f6
--- /dev/null
@@ -0,0 +1,40 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=6
+
+DIST_AUTHOR=CRAZYDJ
+DIST_VERSION=1.0.9
+DIST_A_EXT=tgz
+inherit perl-module
+
+DESCRIPTION="Perl extension for creating ARP packets"
+
+SLOT="0"
+KEYWORDS="~amd64"
+IUSE=""
+
+RDEPEND="dev-perl/Net-Pcap"
+DEPEND="${RDEPEND}"
+
+S="${WORKDIR}/${PN}"
+
+PATCHES=(
+       "${FILESDIR}/1.0.9-header.diff"
+       "${FILESDIR}/${PN}-1.0.9-perl-5.26.patch"
+       "${FILESDIR}/${PN}-1.0.9-tests.patch"
+)
+
+src_prepare() {
+       perl -MDevel::PPPort -e 'Devel::PPPort::WriteFile();'
+       perl-module_src_prepare
+}
+
+src_test() {
+       if [[ $EUID != 0 || -z $TEST_ARP_IF ]]; then
+               elog "Comprehensive testing needs additional configuration (and root)."
+               elog "For details, see:"
+               elog "https://wiki.gentoo.org/wiki/Project:Perl/maint-notes/${CATEGORY}/${PN}"
+       fi
+       perl-module_src_test
+}
diff --git a/dev-perl/Net-ARP/files/Net-ARP-1.0.9-perl-5.26.patch b/dev-perl/Net-ARP/files/Net-ARP-1.0.9-perl-5.26.patch
new file mode 100644 (file)
index 0000000..c15f1d0
--- /dev/null
@@ -0,0 +1,26 @@
+From 56f7021306fe1dbd3b83981062acf2db7e296447 Mon Sep 17 00:00:00 2001
+From: Kent Fredric <kentnl@gentoo.org>
+Date: Wed, 13 Dec 2017 21:38:52 +1300
+Subject: Fix loading ARP.pm on Perl 5.26
+
+This is now broken without '.' in @INC
+---
+ t/ARP.t | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/t/ARP.t b/t/ARP.t
+index 9b3ef08..bab58aa 100755
+--- a/t/ARP.t
++++ b/t/ARP.t
+@@ -6,7 +6,7 @@
+ # change 'tests => 1' to 'tests => last_test_to_print';
+ 
+ use Test::More tests => 1;
+-BEGIN { use_ok('ARP') };
++BEGIN { use_ok('Net::ARP') };
+ 
+ #########################
+ 
+-- 
+2.14.3
+
diff --git a/dev-perl/Net-ARP/files/Net-ARP-1.0.9-tests.patch b/dev-perl/Net-ARP/files/Net-ARP-1.0.9-tests.patch
new file mode 100644 (file)
index 0000000..3cd799a
--- /dev/null
@@ -0,0 +1,117 @@
+From 38c823ef25d78205e24314233ae7a503967b53e9 Mon Sep 17 00:00:00 2001
+From: Kent Fredric <kentnl@gentoo.org>
+Date: Wed, 13 Dec 2017 22:22:20 +1300
+Subject: Guard tests that require network device names and root via ENV
+
+---
+ Makefile.PL     |  9 ---------
+ t/arp_lookup.t  | 10 ++++++++--
+ t/send_packet.t | 13 +++++++++++--
+ test.pl         | 23 ++++++++---------------
+ 4 files changed, 27 insertions(+), 28 deletions(-)
+
+diff --git a/Makefile.PL b/Makefile.PL
+index e1a4ee7..fbfe0b0 100755
+--- a/Makefile.PL
++++ b/Makefile.PL
+@@ -18,15 +18,6 @@
+ use ExtUtils::MakeMaker;
+ use Config;
+ 
+-BEGIN {
+-      eval { require Net::Pcap };
+-
+-      if($@)
+-      {
+-          print "Module Net::Pcap is required for make test!\n";
+-      }
+-}
+-
+ if($Config{'osname'} =~ /linux/i)
+ {
+     $flags = "-DLINUX";
+diff --git a/t/arp_lookup.t b/t/arp_lookup.t
+index 4cf9626..df68c90 100644
+--- a/t/arp_lookup.t
++++ b/t/arp_lookup.t
+@@ -13,8 +13,14 @@ ok( $mac eq "unknown", "unkown mac on strange dev value -> $mac" );
+ $mac = Net::ARP::arp_lookup("$fu","127.0.0.1");
+ ok( $mac eq "unknown", "unkown mac on strange dev value 2 -> $mac" );
+ 
+-$mac = Net::ARP::arp_lookup("eth0","this_is_not_an_ip_address");
+-ok( $mac eq "unknown", "unkown mac on strange ip value -> $mac" );
++SKIP: {
++
++  skip "TEST_ARP_IF unset", 1 unless exists $ENV{TEST_ARP_IF};
++
++  $mac = Net::ARP::arp_lookup($ENV{TEST_ARP_IF},"this_is_not_an_ip_address");
++  ok( $mac eq "unknown", "unkown mac on strange ip value -> $mac" );
++
++}
+ 
+ #Net::ARP::arp_lookup("eth0","192.168.1.1","fu");
+ #ok( $mac eq "unknown", "unkown mac on strange mac value" );
+diff --git a/t/send_packet.t b/t/send_packet.t
+index 1f95f4f..3b4b998 100644
+--- a/t/send_packet.t
++++ b/t/send_packet.t
+@@ -5,9 +5,18 @@
+ # Last update: 22.06.2013
+ 
+ use Net::ARP;
+-use Test::More qw( no_plan );
++use Test::More;
++BEGIN {
++  if ( $> != 0 )  {
++      plan skip_all => "This test must be run as root";
++  }
++  if ( not exists $ENV{TEST_ARP_IF} ) {
++    plan skip_all => "TEST_ARP_IF not specified";
++  }
++  $dev = $ENV{TEST_ARP_IF};
++  plan qw/no_plan/;
++}
+ 
+-$dev="lo";
+ print "Using device $dev to test send_packet()\n";
+ 
+ $ret = Net::ARP::send_packet("strange_dev",   # network interface
+diff --git a/test.pl b/test.pl
+index 27af515..c2e4cc2 100755
+--- a/test.pl
++++ b/test.pl
+@@ -19,23 +19,16 @@
+ use ExtUtils::testlib;
+ use Net::ARP;
+ 
+-BEGIN
+-{
+-    eval{ require Net::Pcap; };
+-              
+-    if($@ =~ /^Can\'t\slocate/)
+-    {
+-        $dev = "eth0";
+-    }
+-    else
+-    {
+-      import Net::Pcap;
+-        $dev = Net::Pcap::lookupdev(\$errbuf);
+-    }
++if ( $> != 0 ) {
++  print "SKIPPED: test must be run as root\n";
++  exit 0;
+ }
+-
++if ( not exists $ENV{TEST_ARP_IF} ) {
++  print "SKIPPED: TEST_ARP_IF unset\n";
++  exit 0;
++}
++$dev = $ENV{TEST_ARP_IF};
+ print "Sending ARP reply packet via dev $dev... ";
+-
+ $ret = Net::ARP::send_packet($dev,                           # network interface
+                     '127.0.0.1',                    # source ip
+                     '127.0.0.1',                    # destination ip
+-- 
+2.14.3
+