Skip to content

Commit 853b9e9

Browse files
committed
join threads correctly
1 parent 8ac63bc commit 853b9e9

File tree

1 file changed

+15
-20
lines changed

1 file changed

+15
-20
lines changed

tests/test_tendaac15_httpd.py

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
class ELFTest(unittest.TestCase):
3232

3333
def test_tenda_ac15_arm(self):
34-
stop = False
34+
3535
def nvram_listener():
3636
server_address = '../examples/rootfs/arm_tendaac15/var/cfm_socket'
3737

@@ -47,23 +47,19 @@ def nvram_listener():
4747
sock.listen(1)
4848

4949
data = bytearray()
50+
connection, _ = sock.accept()
51+
try:
52+
while True:
53+
data += connection.recv(1024)
5054

51-
while True:
52-
connection, _ = sock.accept()
53-
54-
try:
55-
while True:
56-
data += connection.recv(1024)
57-
58-
if b"lan.webiplansslen" in data:
59-
connection.send(b'192.168.170.169')
60-
else:
61-
break
55+
if b"lan.webiplansslen" in data:
56+
connection.send(b'192.168.170.169')
57+
else:
58+
break
6259

63-
data.clear()
64-
finally:
65-
connection.close()
66-
break
60+
data.clear()
61+
finally:
62+
connection.close()
6763

6864
def patcher(ql: Qiling):
6965
br0_addr = ql.mem.search(b'br0\x00')
@@ -75,8 +71,7 @@ def my_tenda():
7571
ql = Qiling(["../examples/rootfs/arm_tendaac15/bin/httpd"], "../examples/rootfs/arm_tendaac15", verbose=QL_VERBOSE.DEBUG)
7672
ql.add_fs_mapper("/dev/urandom", "/dev/urandom")
7773
ql.hook_address(patcher, ql.loader.elf_entry)
78-
while not stop:
79-
ql.run(count=5000)
74+
ql.run(count=825000)
8075

8176
if __name__ == "__main__":
8277
threads = [
@@ -105,9 +100,9 @@ def my_tenda():
105100
response = conn.getresponse()
106101

107102
self.assertIn(b"Please update your documents to reflect the new location.", response.read())
108-
stop = True
109103
for th in threads:
110-
th.join()
104+
th.join(timeout=10.0)
105+
self.assertFalse(th.is_alive())
111106

112107
if __name__ == "__main__":
113108
unittest.main()

0 commit comments

Comments
 (0)