(self)
| 419 | self.assertTrue(msg.endswith(f'{num} return {num}.')) |
| 420 | |
| 421 | def test_udp_elf_linux_x86(self): |
| 422 | logged: List[str] = [] |
| 423 | |
| 424 | def check_write(ql: Qiling, fd: int, write_buf, count: int): |
| 425 | if fd == 2: |
| 426 | content = ql.mem.read(write_buf, count) |
| 427 | |
| 428 | logged.extend(content.decode().splitlines()) |
| 429 | |
| 430 | ql = Qiling([fr'{X86_LINUX_ROOTFS}/bin/x86_udp_test', '20010'], X86_LINUX_ROOTFS, multithread=True, verbose=QL_VERBOSE.DEBUG) |
| 431 | |
| 432 | ql.os.stats = QlOsNullStats() |
| 433 | ql.os.set_syscall("write", check_write, QL_INTERCEPT.ENTER) |
| 434 | ql.run() |
| 435 | |
| 436 | self.assertGreaterEqual(len(logged), 2) |
| 437 | self.assertTrue(logged[-2].startswith('server recvfrom()')) |
| 438 | self.assertTrue(logged[-1].startswith('server sendto()')) |
| 439 | |
| 440 | # the server is expected to send the value it received, for example: |
| 441 | # 'server recvfrom() return 14.\n' |
| 442 | # 'server sendto() 14 return 14.\n' |
| 443 | |
| 444 | m = re.search(r'(?P<num>\d+)\.\Z', logged[-2]) |
| 445 | self.assertIsNotNone(m, f'could not extract numeric value from log message "{logged[-2]}"') |
| 446 | |
| 447 | num = m.group('num') |
| 448 | msg = logged[-1].strip() |
| 449 | |
| 450 | self.assertTrue(msg.endswith(f'{num} return {num}.')) |
| 451 | |
| 452 | def test_udp_elf_linux_x8664(self): |
| 453 | logged: List[str] = [] |
nothing calls this directly
no test coverage detected