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

Method test_ipc_roundtrip

tests/test_kernel_proxy.py:259–279  ·  view source on GitHub ↗

IPC serialization/deserialization is correct.

(self)

Source from the content-addressed store, hash-verified

257 # -------------------------------------------------------------------------
258
259 def test_ipc_roundtrip(self):
260 """IPC serialization/deserialization is correct."""
261 from qiling.os.posix.kernel_proxy.ipc import (
262 HEADER_FMT, HEADER_SIZE,
263 SYSCALL_REQ_FMT, SYSCALL_RESP_FMT,
264 FD_OP_REQ_FMT, FD_OP_RESP_FMT,
265 MsgType, FdOp
266 )
267 import struct
268
269 # syscall request roundtrip
270 payload = struct.pack(SYSCALL_REQ_FMT, 39, 1, 2, 3, 4, 5, 6)
271 nr, a0, a1, a2, a3, a4, a5 = struct.unpack(SYSCALL_REQ_FMT, payload)
272 self.assertEqual(nr, 39)
273 self.assertEqual((a0, a1, a2, a3, a4, a5), (1, 2, 3, 4, 5, 6))
274
275 # syscall response roundtrip
276 payload = struct.pack(SYSCALL_RESP_FMT, -2, 2) # -ENOENT
277 retval, errno_val = struct.unpack(SYSCALL_RESP_FMT, payload)
278 self.assertEqual(retval, -2)
279 self.assertEqual(errno_val, 2)
280
281 # -------------------------------------------------------------------------
282 # Error handling

Callers

nothing calls this directly

Calls 1

packMethod · 0.45

Tested by

no test coverage detected