|
7 | 7 | sys.path.append("..") |
8 | 8 |
|
9 | 9 | from qiling.core import Qiling |
10 | | -from qiling.const import QL_VERBOSE |
| 10 | +from qiling.const import QL_VERBOSE, QL_INTERCEPT |
11 | 11 | from qiling.extensions.pipe import SimpleOutStream |
12 | 12 |
|
13 | 13 | class RISCVTest(unittest.TestCase): |
14 | 14 | def test_riscv32_hello_linux(self): |
15 | 15 | stdout = SimpleOutStream(1) |
16 | 16 | ql = Qiling(['../examples/rootfs/riscv32_linux/bin/hello'], '../examples/rootfs/riscv32_linux/', |
17 | | - verbose=QL_VERBOSE.DEBUG, stdout=stdout) |
18 | | - |
19 | | - ql.run(end=0x66112) # avoid close 0, 1, 2 |
| 17 | + verbose=QL_VERBOSE.DEFAULT, stdout=stdout) |
| 18 | + |
| 19 | + def close(ql, fd): |
| 20 | + return 0 |
| 21 | + ql.set_syscall("close", close, QL_INTERCEPT.CALL) |
| 22 | + ql.run() |
20 | 23 | self.assertTrue(stdout.read() == b'Hello, World!\n') |
21 | 24 |
|
22 | 25 | del ql |
23 | 26 |
|
24 | 27 | def test_riscv64_hello_linux(self): |
25 | 28 | stdout = SimpleOutStream(1) |
26 | 29 | ql = Qiling(['../examples/rootfs/riscv64_linux/bin/hello'], '../examples/rootfs/riscv64_linux/', |
27 | | - verbose=QL_VERBOSE.DEBUG, stdout=stdout) |
28 | | - |
| 30 | + verbose=QL_VERBOSE.DEFAULT, stdout=stdout) |
29 | 31 |
|
30 | | - ql.run(end=0x1249e) # avoid close 0, 1, 2 |
| 32 | + def close(ql, fd): |
| 33 | + return 0 |
| 34 | + ql.set_syscall("close", close, QL_INTERCEPT.CALL) |
| 35 | + ql.run() |
31 | 36 | self.assertTrue(stdout.read() == b'Hello, World!\n') |
32 | 37 |
|
33 | 38 | del ql |
34 | 39 |
|
35 | 40 | def test_riscv64_hello_dyn_linux(self): |
36 | 41 | stdout = SimpleOutStream(1) |
37 | 42 | ql = Qiling(['../examples/rootfs/riscv64_linux/bin/hello-linux'], '../examples/rootfs/riscv64_linux/', |
38 | | - verbose=QL_VERBOSE.DEBUG, stdout=stdout) |
39 | | - |
| 43 | + verbose=QL_VERBOSE.DEFAULT, stdout=stdout) |
40 | 44 |
|
41 | | - ql.run(end=0x1249e) # avoid close 0, 1, 2 |
| 45 | + ql.run() |
42 | 46 | self.assertTrue(stdout.read() == b'Hello, World!\n') |
43 | 47 |
|
44 | 48 | del ql |
|
0 commit comments