From ff8c4e594375711297e1c6181dec483f1127f29e Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Fri, 20 Jun 2025 19:59:14 +0200 Subject: [PATCH] tests/misc: Improve test coverage of py/profile.c. Signed-off-by: Jeff Epler --- tests/misc/sys_settrace_cov.py | 23 +++++++++++++++++++++++ tests/misc/sys_settrace_cov.py.exp | 2 ++ tests/run-tests.py | 1 + 3 files changed, 26 insertions(+) create mode 100644 tests/misc/sys_settrace_cov.py create mode 100644 tests/misc/sys_settrace_cov.py.exp diff --git a/tests/misc/sys_settrace_cov.py b/tests/misc/sys_settrace_cov.py new file mode 100644 index 0000000000..579c8a4a25 --- /dev/null +++ b/tests/misc/sys_settrace_cov.py @@ -0,0 +1,23 @@ +import sys + +try: + sys.settrace +except AttributeError: + print("SKIP") + raise SystemExit + + +def trace_tick_handler(frame, event, arg): + print("FRAME", frame) + print("LASTI", frame.f_lasti) + return None + + +def f(): + x = 3 + return x + + +sys.settrace(trace_tick_handler) +f() +sys.settrace(None) diff --git a/tests/misc/sys_settrace_cov.py.exp b/tests/misc/sys_settrace_cov.py.exp new file mode 100644 index 0000000000..423d78ec42 --- /dev/null +++ b/tests/misc/sys_settrace_cov.py.exp @@ -0,0 +1,2 @@ +FRAME +LASTI \\d\+ diff --git a/tests/run-tests.py b/tests/run-tests.py index e45122b10e..d1d22a3c53 100755 --- a/tests/run-tests.py +++ b/tests/run-tests.py @@ -354,6 +354,7 @@ special_tests = [ "micropython/meminfo.py", "basics/bytes_compare3.py", "basics/builtin_help.py", + "misc/sys_settrace_cov.py", "thread/thread_exc2.py", "ports/esp32/partition_ota.py", )