kopia lustrzana https://github.com/micropython/micropython
tests/multi_bluetooth/ble_irq_calls.py: Enhance test to test recursion.
Signed-off-by: Damien George <damien@micropython.org>pull/13680/head
rodzic
cd66aa05cf
commit
866fc3447c
|
@ -60,6 +60,22 @@ STATE_CHARACTERISTIC = (
|
||||||
ACCESSORY_SERVICE = (ACCESSORY_UUID, (STATE_CHARACTERISTIC,))
|
ACCESSORY_SERVICE = (ACCESSORY_UUID, (STATE_CHARACTERISTIC,))
|
||||||
|
|
||||||
|
|
||||||
|
def recursive_function():
|
||||||
|
recursive_function()
|
||||||
|
|
||||||
|
|
||||||
|
def test_deep_calls(n):
|
||||||
|
if n > 0:
|
||||||
|
# Test that a few nested calls will succeed.
|
||||||
|
test_deep_calls(n - 1)
|
||||||
|
else:
|
||||||
|
# Test that a Python stack overflow is detected.
|
||||||
|
try:
|
||||||
|
recursive_function()
|
||||||
|
except RuntimeError:
|
||||||
|
print("test_deep_calls finished")
|
||||||
|
|
||||||
|
|
||||||
class Central:
|
class Central:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.done = False
|
self.done = False
|
||||||
|
@ -79,6 +95,8 @@ class Central:
|
||||||
conn_handle, _, _ = data
|
conn_handle, _, _ = data
|
||||||
self._conn_handle = conn_handle
|
self._conn_handle = conn_handle
|
||||||
ble.gattc_discover_services(self._conn_handle, ACCESSORY_UUID)
|
ble.gattc_discover_services(self._conn_handle, ACCESSORY_UUID)
|
||||||
|
# Test deep Python calls from within this BLE IRQ handler.
|
||||||
|
test_deep_calls(5)
|
||||||
|
|
||||||
elif event == _IRQ_PERIPHERAL_DISCONNECT:
|
elif event == _IRQ_PERIPHERAL_DISCONNECT:
|
||||||
conn_handle, _, addr = data
|
conn_handle, _, addr = data
|
||||||
|
|
|
@ -8,6 +8,7 @@ _IRQ_CENTRAL_DISCONNECT
|
||||||
--- instance1 ---
|
--- instance1 ---
|
||||||
central start
|
central start
|
||||||
_IRQ_PERIPHERAL_CONNECT
|
_IRQ_PERIPHERAL_CONNECT
|
||||||
|
test_deep_calls finished
|
||||||
_IRQ_GATTC_SERVICE_RESULT
|
_IRQ_GATTC_SERVICE_RESULT
|
||||||
service found: 3 UUID('a5a5a5a5-ffff-9999-1111-5a5a5a5a5a5a')
|
service found: 3 UUID('a5a5a5a5-ffff-9999-1111-5a5a5a5a5a5a')
|
||||||
_IRQ_GATTC_SERVICE_DONE
|
_IRQ_GATTC_SERVICE_DONE
|
||||||
|
|
Ładowanie…
Reference in New Issue