summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/multi_bluetooth/ble_irq_calls.py18
-rw-r--r--tests/multi_bluetooth/ble_irq_calls.py.exp1
2 files changed, 19 insertions, 0 deletions
diff --git a/tests/multi_bluetooth/ble_irq_calls.py b/tests/multi_bluetooth/ble_irq_calls.py
index c8c673daa..2717bd5f3 100644
--- a/tests/multi_bluetooth/ble_irq_calls.py
+++ b/tests/multi_bluetooth/ble_irq_calls.py
@@ -60,6 +60,22 @@ 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:
def __init__(self):
self.done = False
@@ -79,6 +95,8 @@ class Central:
conn_handle, _, _ = data
self._conn_handle = conn_handle
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:
conn_handle, _, addr = data
diff --git a/tests/multi_bluetooth/ble_irq_calls.py.exp b/tests/multi_bluetooth/ble_irq_calls.py.exp
index d655c507d..993e6f79e 100644
--- a/tests/multi_bluetooth/ble_irq_calls.py.exp
+++ b/tests/multi_bluetooth/ble_irq_calls.py.exp
@@ -8,6 +8,7 @@ _IRQ_CENTRAL_DISCONNECT
--- instance1 ---
central start
_IRQ_PERIPHERAL_CONNECT
+test_deep_calls finished
_IRQ_GATTC_SERVICE_RESULT
service found: 3 UUID('a5a5a5a5-ffff-9999-1111-5a5a5a5a5a5a')
_IRQ_GATTC_SERVICE_DONE