X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=test%2Ftest_interface_crud.py;h=b41b2fe5b7cd0e36f593d864294d44c4bae617cf;hb=404b8a36e737e2911ca8874363a4e87cb707e5f9;hp=63917047ed400d8e14c88c30ee69d586ea48cf7b;hpb=c8efa29b6f9a91381897b54f1147daf922ed7164;p=vpp.git diff --git a/test/test_interface_crud.py b/test/test_interface_crud.py index 63917047ed4..b41b2fe5b7c 100644 --- a/test/test_interface_crud.py +++ b/test/test_interface_crud.py @@ -36,6 +36,10 @@ class TestLoopbackInterfaceCRUD(VppTestCase): cls.tearDownClass() raise + @classmethod + def tearDownClass(cls): + super(TestLoopbackInterfaceCRUD, cls).tearDownClass() + @staticmethod def create_icmp_stream(src_if, dst_ifs): """ @@ -79,7 +83,7 @@ class TestLoopbackInterfaceCRUD(VppTestCase): def test_crud(self): # create - loopbacks = self.create_loopback_interfaces(range(20)) + loopbacks = self.create_loopback_interfaces(20) for i in loopbacks: i.local_ip4_prefix_len = 32 i.config_ip4() @@ -121,7 +125,7 @@ class TestLoopbackInterfaceCRUD(VppTestCase): def test_down(self): # create - loopbacks = self.create_loopback_interfaces(range(20)) + loopbacks = self.create_loopback_interfaces(20) for i in loopbacks: i.local_ip4_prefix_len = 32 i.config_ip4() @@ -147,5 +151,38 @@ class TestLoopbackInterfaceCRUD(VppTestCase): self.pg0.assert_nothing_captured() +class TestInterfaceDumpApiLocalOnly(VppTestCase): + """test_interface_crud.TestInterfaceDumpApiLocalOnly""" + + def test_sw_if_index_0(self): + rv = self.vapi.sw_interface_dump(sw_if_index=0) + self.assertEqual(rv[0].sw_if_index, 0) + + def test_sw_if_index_twiddle0(self): + rv = self.vapi.sw_interface_dump(sw_if_index=0xffffffff) + self.assertEqual(rv[0].sw_if_index, 0) + + def test_sw_if_index_1_not_existing(self): + rv = self.vapi.sw_interface_dump(sw_if_index=1) + self.assertEqual(len(rv), 0, 'expected no records.') + + +class TestInterfaceDumpApi(VppTestCase): + """test_interface_crud.TestInterfaceDumpApi""" + + def test_sw_if_index_1(self): + self.vapi.create_loopback_instance(is_specified=1, + user_instance=10) + self.vapi.create_loopback_instance(is_specified=1, + user_instance=5) + + # Can I get back the specified record? + rv = self.vapi.sw_interface_dump(sw_if_index=1) + self.assertEqual(rv[0].sw_if_index, 1, rv) + + # verify 3 interfaces + rv = self.vapi.sw_interface_dump(sw_if_index=0xffffffff) + self.assertEqual(len(rv), 3, 'Expected 3 interfaces.') + if __name__ == '__main__': unittest.main(testRunner=VppTestRunner)