From 4b8201d10f466e7d5cc35b3c0febeee78d343837 Mon Sep 17 00:00:00 2001 From: Florian Fainelli Date: Tue, 3 Oct 2017 20:24:55 -0700 Subject: [PATCH] test/arp: Add ARP test Checks that address learned by the host and target match and were also learned by the correct network interface too. Signed-off-by: Florian Fainelli --- tests/port/arp.py | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 tests/port/arp.py diff --git a/tests/port/arp.py b/tests/port/arp.py new file mode 100644 index 0000000..692f121 --- /dev/null +++ b/tests/port/arp.py @@ -0,0 +1,44 @@ + +import unittest + +from dsatest.bench import bench + +class TestArp(unittest.TestCase): + + + def setUp(self): + links = bench.links + if len(links) == 0: + self.skipTest("Empty link list") + + for i, l in enumerate(links, start=1): + l.host_if.flushAddresses() + l.target_if.flushAddresses() + + def tearDown(self): + pass + + def test_arp(self): + links = bench.links + + for i, l in enumerate(links, start=1): + host_addr = "192.168.10.{}/24".format(str(i * 2)) + target_addr = "192.168.10.{}/24".format(str(i * 2 + 1)) + + l.host_if.addAddress(host_addr) + l.target_if.addAddress(target_addr) + + host_addr = "192.168.10.{}".format(str(i * 2)) + target_addr = "192.168.10.{}".format(str(i * 2 + 1)) + + l.host_if.ping(target_addr, count=1, deadline=10) + ArpEntry reply = l.host_if.arp.get() + if reply.interface != l.host_if.name: + raise ValueError("Interface mismatch. Got {}, expected {}". + format(reply.interface, l.host_if.name)) + reply = l.target_if.arp.get() + if reply.interface != l.target_if.name: + raise ValueError("Interface mismatch. Got {}, expected {}". + format(reply.interface, l.target_if.name)) + l.host_if.flushAddresses() + l.target_if.flushAddresses()