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 7112080 commit c481ec1
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions tests/port/arp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@

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_port_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)

"""
Ask the host about the target IP address
"""
reply = l.host_if.arp.get(target_addr)[0]
if reply.interface != l.host_if.name:
raise ValueError("Interface mismatch. Got {}, expected {}".
format(reply.interface, l.host_if.name))
"""
Ask the target about the host IP address
"""
reply = l.target_if.arp.get(host_addr)[0]

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 c481ec1

Please sign in to comment.