summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJakub Grajciar <jgrajcia@cisco.com>2019-10-24 13:52:42 +0200
committerOle Trøan <otroan@employees.org>2020-03-09 13:46:29 +0000
commit145e330f019920b5ef77f4e8b3fa70de3228710d (patch)
tree7eede6c2dfa7a3f0568071c9f1bbf6aa8319fb71 /test
parent262971e7830413c58b9b45965f799f540e634437 (diff)
l2: API cleanup
Use consistent API types. Type: fix Change-Id: I7ac7cd00606101864fa3422e7b9ea2f1143665dd Signed-off-by: Jakub Grajciar <jgrajcia@cisco.com>
Diffstat (limited to 'test')
-rw-r--r--test/ext/vapi_c_test.c50
-rw-r--r--test/test_l2_fib.py19
-rw-r--r--test/vpp_papi_provider.py11
3 files changed, 9 insertions, 71 deletions
diff --git a/test/ext/vapi_c_test.c b/test/ext/vapi_c_test.c
index 51fc572746f..a91e4014761 100644
--- a/test/ext/vapi_c_test.c
+++ b/test/ext/vapi_c_test.c
@@ -131,11 +131,6 @@ START_TEST (test_hton_4)
d->header._vl_msg_id = cnt++;
d->header.context = cnt++;
d->payload.bd_id = cnt++;
- d->payload.flood = cnt++;
- d->payload.uu_flood = cnt++;
- d->payload.forward = cnt++;
- d->payload.learn = cnt++;
- d->payload.arp_term = cnt++;
d->payload.mac_age = cnt++;
d->payload.bvi_sw_if_index = cnt++;
d->payload.n_sw_ifs = vla_count;
@@ -156,16 +151,6 @@ START_TEST (test_hton_4)
++tmp;
verify_hton_swap (d->payload.bd_id, tmp);
++tmp;
- verify_hton_swap (d->payload.flood, tmp);
- ++tmp;
- verify_hton_swap (d->payload.uu_flood, tmp);
- ++tmp;
- verify_hton_swap (d->payload.forward, tmp);
- ++tmp;
- verify_hton_swap (d->payload.learn, tmp);
- ++tmp;
- verify_hton_swap (d->payload.arp_term, tmp);
- ++tmp;
verify_hton_swap (d->payload.mac_age, tmp);
++tmp;
verify_hton_swap (d->payload.bvi_sw_if_index, tmp);
@@ -189,16 +174,6 @@ START_TEST (test_hton_4)
++tmp;
ck_assert_int_eq (d->payload.bd_id, tmp);
++tmp;
- ck_assert_int_eq (d->payload.flood, tmp);
- ++tmp;
- ck_assert_int_eq (d->payload.uu_flood, tmp);
- ++tmp;
- ck_assert_int_eq (d->payload.forward, tmp);
- ++tmp;
- ck_assert_int_eq (d->payload.learn, tmp);
- ++tmp;
- ck_assert_int_eq (d->payload.arp_term, tmp);
- ++tmp;
ck_assert_int_eq (d->payload.mac_age, tmp);
++tmp;
ck_assert_int_eq (d->payload.bvi_sw_if_index, tmp);
@@ -268,11 +243,6 @@ START_TEST (test_ntoh_4)
d->header._vl_msg_id = cnt++;
d->header.context = cnt++;
d->payload.bd_id = cnt++;
- d->payload.flood = cnt++;
- d->payload.uu_flood = cnt++;
- d->payload.forward = cnt++;
- d->payload.learn = cnt++;
- d->payload.arp_term = cnt++;
d->payload.mac_age = cnt++;
d->payload.bvi_sw_if_index = cnt++;
d->payload.n_sw_ifs = htobe32 (vla_count);
@@ -293,16 +263,6 @@ START_TEST (test_ntoh_4)
++tmp;
verify_ntoh_swap (d->payload.bd_id, tmp);
++tmp;
- verify_ntoh_swap (d->payload.flood, tmp);
- ++tmp;
- verify_ntoh_swap (d->payload.uu_flood, tmp);
- ++tmp;
- verify_ntoh_swap (d->payload.forward, tmp);
- ++tmp;
- verify_ntoh_swap (d->payload.learn, tmp);
- ++tmp;
- verify_ntoh_swap (d->payload.arp_term, tmp);
- ++tmp;
verify_ntoh_swap (d->payload.mac_age, tmp);
++tmp;
verify_ntoh_swap (d->payload.bvi_sw_if_index, tmp);
@@ -326,16 +286,6 @@ START_TEST (test_ntoh_4)
++tmp;
ck_assert_int_eq (d->payload.bd_id, tmp);
++tmp;
- ck_assert_int_eq (d->payload.flood, tmp);
- ++tmp;
- ck_assert_int_eq (d->payload.uu_flood, tmp);
- ++tmp;
- ck_assert_int_eq (d->payload.forward, tmp);
- ++tmp;
- ck_assert_int_eq (d->payload.learn, tmp);
- ++tmp;
- ck_assert_int_eq (d->payload.arp_term, tmp);
- ++tmp;
ck_assert_int_eq (d->payload.mac_age, tmp);
++tmp;
ck_assert_int_eq (d->payload.bvi_sw_if_index, tmp);
diff --git a/test/test_l2_fib.py b/test/test_l2_fib.py
index 106a7902da5..51c17470966 100644
--- a/test/test_l2_fib.py
+++ b/test/test_l2_fib.py
@@ -69,12 +69,7 @@ from scapy.layers.inet import IP, UDP
from framework import VppTestCase, VppTestRunner
from util import Host, ppp
-from vpp_papi import mac_pton
-
-# from src/vnet/l2/l2_fib.h
-MAC_EVENT_ACTION_ADD = 0
-MAC_EVENT_ACTION_DELETE = 1
-MAC_EVENT_ACTION_MOVE = 2
+from vpp_papi import mac_pton, VppEnum
class TestL2fib(VppTestCase):
@@ -325,7 +320,7 @@ class TestL2fib(VppTestCase):
self.assertEqual(ip.dst, saved_packet[IP].dst)
self.assertEqual(udp.sport, saved_packet[UDP].sport)
self.assertEqual(udp.dport, saved_packet[UDP].dport)
- except:
+ except BaseException:
self.logger.error(ppp("Unexpected or invalid packet:", packet))
raise
for i in self.pg_interfaces:
@@ -494,9 +489,10 @@ class TestL2fib(VppTestCase):
self.sleep(1)
self.logger.info(self.vapi.ppcli("show l2fib"))
evs = self.vapi.collect_events()
+ action = VppEnum.vl_api_mac_event_action_t.MAC_EVENT_ACTION_API_ADD
learned_macs = {
- e.mac[i].mac_addr for e in evs for i in range(e.n_macs)
- if e.mac[i].action == MAC_EVENT_ACTION_ADD}
+ e.mac[i].mac_addr.packed for e in evs for i in range(e.n_macs)
+ if e.mac[i].action == action}
macs = {h.bin_mac for swif in self.bd_ifs(bd1)
for h in hosts[self.pg_interfaces[swif].sw_if_index]}
self.vapi.want_l2_macs_events(enable_disable=0)
@@ -518,9 +514,10 @@ class TestL2fib(VppTestCase):
self.vapi.want_l2_macs_events(enable_disable=0)
self.assertGreater(len(evs), 0)
+ action = VppEnum.vl_api_mac_event_action_t.MAC_EVENT_ACTION_API_ADD
learned_macs = {
- e.mac[i].mac_addr for e in evs for i in range(e.n_macs)
- if e.mac[i].action == MAC_EVENT_ACTION_ADD}
+ e.mac[i].mac_addr.packed for e in evs for i in range(e.n_macs)
+ if e.mac[i].action == action}
macs = {h.bin_mac for swif in self.bd_ifs(bd1)
for h in hosts[self.pg_interfaces[swif].sw_if_index]}
diff --git a/test/vpp_papi_provider.py b/test/vpp_papi_provider.py
index bf3f17d2c51..832fd8ff93c 100644
--- a/test/vpp_papi_provider.py
+++ b/test/vpp_papi_provider.py
@@ -126,7 +126,7 @@ defaultmapping = {
'want_bfd_events': {'enable_disable': 1, },
'want_igmp_events': {'enable': 1, },
'want_interface_events': {'enable_disable': 1, },
- 'want_l2_macs_events': {'enable_disable': 1, },
+ 'want_l2_macs_events': {'enable_disable': 1, 'pid': os.getpid(), },
}
@@ -374,15 +374,6 @@ class VppPapiProvider(object):
{'enable_disable': enable_disable,
'pid': os.getpid(), })
- def want_l2_macs_events(self, enable_disable=1, scan_delay=0,
- max_macs_in_event=0, learn_limit=0):
- return self.api(self.papi.want_l2_macs_events,
- {'enable_disable': enable_disable,
- 'scan_delay': scan_delay,
- 'max_macs_in_event': max_macs_in_event,
- 'learn_limit': learn_limit,
- 'pid': os.getpid(), })
-
def sw_interface_set_mac_address(self, sw_if_index, mac):
return self.api(self.papi.sw_interface_set_mac_address,
{'sw_if_index': sw_if_index,