5 from asfframework import VppAsfTestCase, VppTestRunner
8 class TestOffload(VppAsfTestCase):
9 """Offload Unit Test Cases"""
13 super(TestOffload, cls).setUpClass()
16 def tearDownClass(cls):
17 super(TestOffload, cls).tearDownClass()
20 super(TestOffload, self).setUp()
23 super(TestOffload, self).tearDown()
25 def test_offload_unittest(self):
26 """Checksum Offload Test"""
29 "set int ip address loop0 11.22.33.1/24",
30 "set int state loop0 up",
32 "set int ip address loop1 11.22.34.1/24",
33 "set int state loop1 up",
34 "set ip neighbor loop1 11.22.34.44 03:00:11:22:34:44",
35 "packet-generator new {\n"
40 " tx-interface loop1\n"
41 " node loop1-output\n"
42 " buffer-flags ip4 offload\n"
43 " buffer-offload-flags offload-ip-cksum offload-udp-cksum\n"
45 " IP4: 1.2.3 -> dead.0000.0001\n"
46 " UDP: 11.22.33.44 -> 11.22.34.44\n"
47 " ttl 2 checksum 13\n"
48 " UDP: 1234 -> 2345\n"
53 "trace add pg-input 1",
59 r = self.vapi.cli_return_response(cmd)
61 if hasattr(r, "reply"):
62 self.logger.info(cmd + " FAIL reply " + r.reply)
64 self.logger.info(cmd + " FAIL retval " + str(r.retval))
66 r = self.vapi.cli_return_response("show trace")
67 self.assertTrue(r.retval == 0)
68 self.assertTrue(hasattr(r, "reply"))
70 look_here = rv.find("ethernet-input")
71 self.assertFalse(look_here == -1)
72 bad_checksum_index = rv[look_here:].find("should be")
73 self.assertTrue(bad_checksum_index == -1)
76 if __name__ == "__main__":
77 unittest.main(testRunner=VppTestRunner)