(self)
| 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] = [] |
nothing calls this directly
no test coverage detected