aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKlement Sekera <klement@graphiant.com>2022-02-18 10:32:08 +0000
committerNeale Ranns <neale@graphiant.com>2022-02-21 08:29:00 +0000
commit107ad73e1be0b95f72b68c06f22d4e94ea841181 (patch)
treed54353bb3de92321aa45ec3e6d940063c0d1ca58
parent140af1559e603d319806d1e580a4dc1f5debfb07 (diff)
tests: add a generalised counter assert function
Type: improvement Signed-off-by: Klement Sekera <klement.sekera@gmail.com> Change-Id: I5e0fd1019372df0cd403725b8cac52363af13718
-rw-r--r--test/framework.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/test/framework.py b/test/framework.py
index 73da515064a..f0d916fd9a6 100644
--- a/test/framework.py
+++ b/test/framework.py
@@ -1195,7 +1195,7 @@ class VppTestCase(CPUInterface, unittest.TestCase):
if pkt.haslayer(ICMPv6EchoReply):
self.assert_checksum_valid(pkt, 'ICMPv6EchoReply', 'cksum')
- def get_packet_counter(self, counter):
+ def get_counter(self, counter):
if counter.startswith("/"):
counter_value = self.statistics.get_counter(counter)
else:
@@ -1208,8 +1208,17 @@ class VppTestCase(CPUInterface, unittest.TestCase):
break
return counter_value
+ def assert_counter_equal(self, counter, expected_value,
+ thread=None, index=0):
+ c = self.get_counter(counter)
+ if thread is not None:
+ c = c[thread][index]
+ else:
+ c = sum(x[index] for x in c)
+ self.assert_equal(c, expected_value, "counter `%s'" % counter)
+
def assert_packet_counter_equal(self, counter, expected_value):
- counter_value = self.get_packet_counter(counter)
+ counter_value = self.get_counter(counter)
self.assert_equal(counter_value, expected_value,
"packet counter `%s'" % counter)