8000 test_sys_settrace tests are not independent · Issue #108982 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

test_sys_settrace tests are not independent #108982

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
serhiy-storchaka opened this issue Sep 6, 2023 · 4 comments · Fixed by #109472
Closed

test_sys_settrace tests are not independent #108982

serhiy-storchaka opened this issue Sep 6, 2023 · 4 comments · Fixed by #109472
Labels
3.12 only security fixes 3.13 bugs and security fixes tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error

Comments

@serhiy-storchaka
Copy link
Member

Running any of TraceOpcodesTestCase tests from test_sys_settrace always fails. For example:

$ ./python -m test -v test_sys_settrace -m test.test_sys_settrace.TraceOpcodesTestCase.test_01_basic
...
test_01_basic (test.test_sys_settrace.TraceOpcodesTestCase.test_01_basic) ... FAIL

======================================================================
FAIL: test_01_basic (test.test_sys_settrace.TraceOpcodesTestCase.test_01_basic)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/serhiy/py/cpython/Lib/test/test_sys_settrace.py", line 388, in test_01_basic
    self.run_test(basic)
  File "/home/serhiy/py/cpython/Lib/test/test_sys_settrace.py", line 364, in run_test
    self.run_and_compare(func, func.events)
  File "/home/serhiy/py/cpython/Lib/test/test_sys_settrace.py", line 360, in run_and_compare
    self.compare_events(func.__code__.co_firstlineno,
  File "/home/serhiy/py/cpython/Lib/test/test_sys_settrace.py", line 1745, in compare_events
    self.assertLess(len(skip_opcode_events), len(events),
AssertionError: 3 not less than 3 : No 'opcode' events received by the tracer
...

Running several of TraceOpcodesTestCase tests only fails the first of them.

Running also RaisingTraceFuncTestCase.test_line_event_raises_before_opcode_event makes the tests passing successfully.

$ ./python -m test -v test_sys_settrace -m test.test_sys_settrace.TraceOpcodesTestCase.test_01_basic -m test_line_event_raises_before_opcode_event
...
test_line_event_raises_before_opcode_event (test.test_sys_settrace.RaisingTraceFuncTestCase.test_line_event_raises_before_opcode_event) ... ok
test_01_basic (test.test_sys_settrace.TraceOpcodesTestCase.test_01_basic) ... ok
...
@serhiy-storchaka serhiy-storchaka added type-bug An unexpected behavior, bug, or error tests Tests in the Lib/test dir 3.12 only security fixes 3.13 bugs and security fixes labels Sep 6, 2023
@serhiy-storchaka
Copy link
Member Author

It is only reproduced in 3.12+.

@gaogaotiantian
Copy link
Member

This is a known issue #103615. I have not had the chance to fix it. The issue is that you can't start the trace before you set trace_opcode = True. It's an underlying tracing mechanism problem that requires some architecture change.

@serhiy-storchaka
Copy link
Member Author

Is there a workaround for tests which does not invalidate the purposes of tests?

#103615 did not mention test_sys_settrace. Should we close this issue or keep it until #103615 be solved to ensure that this issue also is fixed?

@gaogaotiantian
Copy link
Member

I can do a hacky workaround if that's what needed for now - basically we just need to ensure f_trace_opcodes is set to True at least once on ANY frame before we start tracing. It that helps the validation, I can do the PR - it's pretty trivial. We should, however, remove it when it's not needed.

#108976 is not fixed after the workaround though. It has a deeper issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.12 only security fixes 3.13 bugs and security fixes tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants
0