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

Class BessModuleTestCase

bessctl/test_utils.py:174–363  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

172
173
174class BessModuleTestCase(unittest.TestCase):
175
176 @staticmethod
177 def assertSamePackets(pkt1, pkt2):
178 if pkt_str(pkt1) != pkt_str(pkt2):
179 raise AssertionError(
180 '"%s" != "%s"' % (pkt_str(pkt1), pkt_str(pkt2)))
181
182 @staticmethod
183 def assertNotSamePackets(pkt1, pkt2):
184 if pkt_str(pkt1) == pkt_str(pkt2):
185 raise AssertionError(
186 '"%s" == "%s"' % (pkt_str(pkt1), pkt_str(pkt2)))
187
188 def assertBessAlive(self):
189 try:
190 self.bess.get_version()
191 except BESS.APIError:
192 raise AssertionError('Bess is not alive')
193
194 def setUp(self):
195 self.bess = BESS()
196
197 try:
198 self.bess.connect()
199 except BESS.APIError:
200 raise Exception('BESS is not running')
201
202 self.bess.pause_all()
203 self.bess.reset_all()
204
205 self.sockets = {}
206 self.input_ports = {}
207 self.output_ports = {}
208
209 def tearDown(self):
210 for sock in self.sockets.values():
211 sock.close()
212
213 self.bess.pause_all()
214 self.bess.reset_all()
215
216 def run_for(self, module, igates, duration, pkt_update_fields=[]):
217 self.bess.pause_all()
218
219 fields = pkt_update_fields
220 if len(fields) == 0:
221 fields.append({'offset': 26, 'size': 4,
222 'min': 1, 'max': pow(2, 32) - 1})
223 fields.append({'offset': 30, 'size': 4,
224 'min': 1, 'max': pow(2, 32) - 1})
225
226 # source and associate sockets
227 for igate in igates:
228 src = self.bess.create_module('Source')
229 random = self.bess.create_module('RandomUpdate', 'RandomUpdateArg',
230 {'fields': fields})
231 self.bess.connect_modules(src.name, random.name)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected