| 35 | |
| 36 | |
| 37 | class 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 | |
| 67 | suite = unittest.TestLoader().loadTestsFromTestCase(BessBufferTest) |
| 68 | results = unittest.TextTestRunner(verbosity=2).run(suite) |
nothing calls this directly
no outgoing calls
no test coverage detected