Skip to content

Commit

Permalink
test/arp: Add ARP test
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
ffainelli committed Oct 13, 2017
1 parent bf88593 commit 4b8201d
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions tests/port/arp.py
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit 4b8201d

Please sign in to comment.