MCPcopy Create free account
hub / github.com/NetSys/bess / BessBufferTest

Class BessBufferTest

bessctl/module_tests/buffer.py:37–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35
36
37class BessBufferTest(BessModuleTestCase):
38
39 def test_run_buffer(self):
40 buf = Buffer()
41 self.run_for(buf, [0], 3)
42 self.assertBessAlive()
43
44 def test_buffer(self):
45 buf = Buffer()
46 pkt1 = get_tcp_packet(sip='22.22.22.22', dip='22.22.22.22')
47 pkt2 = get_tcp_packet(sip='32.22.22.22', dip='22.22.22.22')
48
49 test_data = []
50
51 # Should withhold data until it has a full batch to push through.
52 for i in range(BATCH_SIZE - 1):
53 test_data.append({'input_port': 0, 'input_packet': pkt1,
54 'output_port': 0, 'output_packet': None})
55
56 test_data.append({'input_port': 0, 'input_packet': pkt2,
57 'output_port': 0, 'output_packet': pkt1})
58
59 for i in range(BATCH_SIZE - 1):
60 pkt_outs = self.run_module(buf, 0, [pkt1], [0])
61 self.assertEquals(len(pkt_outs[0]), 0)
62
63 pkt_outs = self.run_module(buf, 0, [pkt2], [0])
64 self.assertEquals(len(pkt_outs[0]), BATCH_SIZE)
65 self.assertSamePackets(pkt_outs[0][0], pkt1)
66
67suite = unittest.TestLoader().loadTestsFromTestCase(BessBufferTest)
68results = unittest.TextTestRunner(verbosity=2).run(suite)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected