Skip to content

Commit a76b858

Browse files
committed
Tentative fix for epoll server test case
1 parent 2ecd1d9 commit a76b858

3 files changed

Lines changed: 5 additions & 8 deletions

File tree

qiling/os/posix/syscall/epoll.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def ql_syscall_epoll_ctl(ql: Qiling, epfd: int, op: int, fd: int, event: int):
118118
if op not in (EPOLL_CTL_ADD, EPOLL_CTL_DEL, EPOLL_CTL_MOD):
119119
return -EINVAL
120120

121-
if epfd == fd:
121+
if epfd == fd or fd == 0xffffffff: # latter condition was seen in testing, but should not happen in the real world
122122
return -EINVAL
123123

124124
if epfd not in range(NR_OPEN):

tests/test_elf.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -217,13 +217,13 @@ def test_elf_linux_x8664_static(self):
217217
ql = Qiling(["../examples/rootfs/x8664_linux/bin/x8664_hello_static"], "../examples/rootfs/x8664_linux", verbose=QL_VERBOSE.DEBUG)
218218
ql.run()
219219
del ql
220-
220+
#@unittest.skip('Experiment to avoid FD issue')
221221
def test_elf_linux_x86(self):
222222
filename = 'test.qlog'
223223

224224
ql = Qiling(["../examples/rootfs/x86_linux/bin/x86_hello"], "../examples/rootfs/x86_linux", verbose=QL_VERBOSE.DEBUG, log_devices=[filename])
225225
ql.run()
226-
226+
ql._log_file_fd.handlers[0].close() # prevent FD leak that causes downstream issues
227227
os.remove(filename)
228228
del ql
229229

@@ -789,8 +789,7 @@ def test_elf_linux_x8664_epoll_simple(self):
789789
ql.run()
790790

791791
self.assertIn(b'echo\n', ql.os.stdout.read())
792-
del ql
793-
@unittest.skip("See comment in https://github.com/qilingframework/qiling/pull/1558")
792+
del ql
794793
def test_elf_linux_x8664_epoll_server(self):
795794
# This tests a simple server that uses epoll to wait for data, then prints it out. It has
796795
# been modified to exit after data has been received; instead of a typical server operation
@@ -810,7 +809,6 @@ def hook_newfstatat(ql: Qiling, dirfd: int, pathname: int, statbuf: int, flags:
810809
def client():
811810
# give time for the server to listen
812811
time.sleep(3)
813-
814812
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
815813
s.connect(("127.0.0.1", 8000))
816814
s.send(b"hello world")
@@ -826,7 +824,6 @@ def client():
826824

827825
client_thread = threading.Thread(target=client, daemon=True)
828826
client_thread.start()
829-
830827
ql.run()
831828

832829
self.assertIn(b'hello world', ql.os.stdout.read(200)) # 200 is arbitrary--"good enough" for this task

tests/test_onlinux.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Cross Platform and Multi Architecture Advanced Binary Emulation Framework
55
#
66

7-
python3 ./test_posix.py &&
7+
python3 -m pdb ./test_posix.py &&
88
python3 ./test_elf_multithread.py &&
99
python3 ./test_elf_ko.py &&
1010
python3 ./test_debugger.py &&

0 commit comments

Comments
 (0)