From f37c3ba9379c77805b40506dd72b3bc9eb1e8d08 Mon Sep 17 00:00:00 2001 From: Klement Sekera Date: Thu, 8 Nov 2018 11:24:34 +0100 Subject: make test: p2p ethernet refactor Change-Id: I48b4b3eaa84e4174e4d0305594675bf983184fa0 Signed-off-by: Klement Sekera --- test/framework.py | 14 +++++++++++++- test/test_p2p_ethernet.py | 24 ++---------------------- 2 files changed, 15 insertions(+), 23 deletions(-) diff --git a/test/framework.py b/test/framework.py index 5bbd56a6ef7..27fcdb5a7f6 100644 --- a/test/framework.py +++ b/test/framework.py @@ -300,7 +300,8 @@ class VppTestCase(unittest.TestCase): "}", "}", ] if plugin_path is not None: cls.vpp_cmdline.extend(["plugin_path", plugin_path]) - cls.logger.info("vpp_cmdline: %s" % cls.vpp_cmdline) + cls.logger.info("vpp_cmdline args: %s" % cls.vpp_cmdline) + cls.logger.info("vpp_cmdline: %s" % " ".join(cls.vpp_cmdline)) @classmethod def wait_for_enter(cls): @@ -896,6 +897,17 @@ class VppTestCase(unittest.TestCase): if pkt.haslayer(ICMPv6EchoReply): self.assert_checksum_valid(pkt, 'ICMPv6EchoReply', 'cksum') + def assert_packet_counter_equal(self, counter, expected_value): + counters = self.vapi.cli("sh errors").split('\n') + counter_value = -1 + for i in range(1, len(counters)-1): + results = counters[i].split() + if results[1] == counter: + counter_value = int(results[0]) + break + self.assert_equal(counter_value, expected_value, + "packet counter `%s'" % counter) + @classmethod def sleep(cls, timeout, remark=None): if hasattr(cls, 'logger'): diff --git a/test/test_p2p_ethernet.py b/test/test_p2p_ethernet.py index c901eeac39c..a4eeee0e47d 100644 --- a/test/test_p2p_ethernet.py +++ b/test/test_p2p_ethernet.py @@ -176,16 +176,6 @@ class P2PEthernetIPV6(VppTestCase): count = len(packets) return dst_if.get_capture(count) - def verify_counters(self, counter_id, expected_value): - counters = self.vapi.cli("sh errors").split('\n') - counter_value = -1 - for i in range(1, len(counters)-1): - results = counters[i].split() - if results[1] == counter_id: - counter_value = int(results[0]) - break - self.assertEqual(counter_value, expected_value) - def test_no_p2p_subif(self): """standard routing without p2p subinterfaces""" self.logger.info("FFP_TEST_START_0001") @@ -224,7 +214,7 @@ class P2PEthernetIPV6(VppTestCase): dst_ip="9001::100")) self.send_packets(self.pg0, self.pg1, self.packets) - self.verify_counters('p2p-ethernet-input', 1) + self.assert_packet_counter_equal('p2p-ethernet-input', 1) route_9001.remove_vpp_config() self.logger.info("FFP_TEST_FINISH_0002") @@ -397,16 +387,6 @@ class P2PEthernetIPV4(VppTestCase): count = len(packets) return dst_if.get_capture(count) - def verify_counters(self, counter_id, expected_value): - counters = self.vapi.cli("sh errors").split('\n') - counter_value = -1 - for i in range(1, len(counters)-1): - results = counters[i].split() - if results[1] == counter_id: - counter_value = int(results[0]) - break - self.assertEqual(counter_value, expected_value) - def create_p2p_ethernet(self, parent_if, sub_id, remote_mac): p2p = VppP2PSubint(self, parent_if, sub_id, mactobinary(remote_mac)) p2p.admin_up() @@ -436,7 +416,7 @@ class P2PEthernetIPV4(VppTestCase): self.send_packets(self.pg0, self.pg1, self.packets) - self.verify_counters('p2p-ethernet-input', 1) + self.assert_packet_counter_equal('p2p-ethernet-input', 1) route_9000.remove_vpp_config() self.logger.info("FFP_TEST_FINISH_0002") -- cgit 1.2.3-korg