MCPcopy Create free account
hub / github.com/qilingframework/qiling / test_tcp_elf_linux_x8664

Method test_tcp_elf_linux_x8664

tests/test_elf_multithread.py:235–264  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

233 self.assertTrue(msg.endswith(f'{num} return {num}.'))
234
235 def test_tcp_elf_linux_x8664(self):
236 logged: List[str] = []
237
238 def check_write(ql: Qiling, fd: int, write_buf, count: int):
239 if fd == 2:
240 content = ql.mem.read(write_buf, count)
241
242 logged.extend(content.decode().splitlines())
243
244 ql = Qiling([fr'{X64_LINUX_ROOTFS}/bin/x8664_tcp_test', '20001'], X64_LINUX_ROOTFS, multithread=True, verbose=QL_VERBOSE.DEBUG)
245
246 ql.os.stats = QlOsNullStats()
247 ql.os.set_syscall("write", check_write, QL_INTERCEPT.ENTER)
248 ql.run()
249
250 self.assertGreaterEqual(len(logged), 2)
251 self.assertTrue(logged[-2].startswith('server recv()'))
252 self.assertTrue(logged[-1].startswith('server send()'))
253
254 # the server is expected to send the value it received, for example:
255 # 'server recv() return 14.\n'
256 # 'server send() 14 return 14.\n'
257
258 m = re.search(r'(?P<num>\d+)\.\Z', logged[-2])
259 self.assertIsNotNone(m, f'could not extract numeric value from log message "{logged[-2]}"')
260
261 num = m.group('num')
262 msg = logged[-1].strip()
263
264 self.assertTrue(msg.endswith(f'{num} return {num}.'))
265
266 def test_tcp_elf_linux_arm(self):
267 logged: List[str] = []

Callers

nothing calls this directly

Calls 5

runMethod · 0.95
QilingClass · 0.90
QlOsNullStatsClass · 0.90
set_syscallMethod · 0.80
searchMethod · 0.45

Tested by

no test coverage detected