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

Method test_udp_elf_linux_x8664

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

Source from the content-addressed store, hash-verified

450 self.assertTrue(msg.endswith(f'{num} return {num}.'))
451
452 def test_udp_elf_linux_x8664(self):
453 logged: List[str] = []
454
455 def check_write(ql: Qiling, fd: int, write_buf, count: int):
456 if fd == 2:
457 content = ql.mem.read(write_buf, count)
458
459 logged.extend(content.decode().splitlines())
460
461 ql = Qiling([fr'{X64_LINUX_ROOTFS}/bin/x8664_udp_test', '20011'], X64_LINUX_ROOTFS, multithread=True, verbose=QL_VERBOSE.DEBUG)
462
463 ql.os.stats = QlOsNullStats()
464 ql.os.set_syscall("write", check_write, QL_INTERCEPT.ENTER)
465 ql.run()
466
467 self.assertGreaterEqual(len(logged), 2)
468 self.assertTrue(logged[-2].startswith('server recvfrom()'))
469 self.assertTrue(logged[-1].startswith('server sendto()'))
470
471 # the server is expected to send the value it received, for example:
472 # 'server recvfrom() return 14.\n'
473 # 'server sendto() 14 return 14.\n'
474
475 m = re.search(r'(?P<num>\d+)\.\Z', logged[-2])
476 self.assertIsNotNone(m, f'could not extract numeric value from log message "{logged[-2]}"')
477
478 num = m.group('num')
479 msg = logged[-1].strip()
480
481 self.assertTrue(msg.endswith(f'{num} return {num}.'))
482
483 def test_udp_elf_linux_arm64(self):
484 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