tests/thread: Make stress_aes.py test run on bare-metal ports.
This is a long-running test, so make it run in reasonable time on slower, bare-metal ports. Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
parent
9340cfe774
commit
7b923d6c72
|
@ -235,7 +235,7 @@ class LockedCounter:
|
||||||
count = LockedCounter()
|
count = LockedCounter()
|
||||||
|
|
||||||
|
|
||||||
def thread_entry():
|
def thread_entry(n_loop):
|
||||||
global count
|
global count
|
||||||
|
|
||||||
aes = AES(256)
|
aes = AES(256)
|
||||||
|
@ -244,7 +244,7 @@ def thread_entry():
|
||||||
data = bytearray(128)
|
data = bytearray(128)
|
||||||
# from now on we don't use the heap
|
# from now on we don't use the heap
|
||||||
|
|
||||||
for loop in range(5):
|
for loop in range(n_loop):
|
||||||
# encrypt
|
# encrypt
|
||||||
aes.set_key(key)
|
aes.set_key(key)
|
||||||
aes.set_iv(iv)
|
aes.set_iv(iv)
|
||||||
|
@ -265,8 +265,20 @@ def thread_entry():
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
n_thread = 20
|
import sys
|
||||||
|
|
||||||
|
if sys.platform == "rp2":
|
||||||
|
n_thread = 1
|
||||||
|
n_loop = 2
|
||||||
|
elif sys.platform in ("esp32", "pyboard"):
|
||||||
|
n_thread = 2
|
||||||
|
n_loop = 2
|
||||||
|
else:
|
||||||
|
n_thread = 20
|
||||||
|
n_loop = 5
|
||||||
for i in range(n_thread):
|
for i in range(n_thread):
|
||||||
_thread.start_new_thread(thread_entry, ())
|
_thread.start_new_thread(thread_entry, (n_loop,))
|
||||||
|
thread_entry(n_loop)
|
||||||
while count.value < n_thread:
|
while count.value < n_thread:
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
print("done")
|
||||||
|
|
Loading…
Reference in New Issue