(self)
| 388 | self.assertTrue(msg.endswith(f'{num} return {num}.')) |
| 389 | |
| 390 | def test_tcp_elf_linux_mips32el(self): |
| 391 | logged: List[str] = [] |
| 392 | |
| 393 | def check_write(ql: Qiling, fd: int, write_buf, count: int): |
| 394 | if fd == 2: |
| 395 | content = ql.mem.read(write_buf, count) |
| 396 | |
| 397 | logged.extend(content.decode().splitlines()) |
| 398 | |
| 399 | ql = Qiling([fr'{MIPSEL_LINUX_ROOTFS}/bin/mips32el_tcp_test', '20006'], MIPSEL_LINUX_ROOTFS, multithread=True, verbose=QL_VERBOSE.DEBUG) |
| 400 | |
| 401 | ql.os.stats = QlOsNullStats() |
| 402 | ql.os.set_syscall("write", check_write, QL_INTERCEPT.ENTER) |
| 403 | ql.run() |
| 404 | |
| 405 | self.assertGreaterEqual(len(logged), 2) |
| 406 | self.assertTrue(logged[-2].startswith('server read()')) |
| 407 | self.assertTrue(logged[-1].startswith('server write()')) |
| 408 | |
| 409 | # the server is expected to send the value it received, for example: |
| 410 | # 'server read() return 14.\n' |
| 411 | # 'server write() 14 return 14.\n' |
| 412 | |
| 413 | m = re.search(r'(?P<num>\d+)\.\Z', logged[-2]) |
| 414 | self.assertIsNotNone(m, f'could not extract numeric value from log message "{logged[-2]}"') |
| 415 | |
| 416 | num = m.group('num') |
| 417 | msg = logged[-1].strip() |
| 418 | |
| 419 | self.assertTrue(msg.endswith(f'{num} return {num}.')) |
| 420 | |
| 421 | def test_udp_elf_linux_x86(self): |
| 422 | logged: List[str] = [] |
nothing calls this directly
no test coverage detected