Skip to content

gh-98894: Fix DTrace test_check_probes for shared builds#151122

Merged
vstinner merged 2 commits into
python:mainfrom
stratakis:fix-dtrace-tests
Jun 10, 2026
Merged

gh-98894: Fix DTrace test_check_probes for shared builds#151122
vstinner merged 2 commits into
python:mainfrom
stratakis:fix-dtrace-tests

Conversation

@stratakis

@stratakis stratakis commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

When building with --enable-shared, the SystemTap/DTrace notes live in libpython. Add detection logic to be used by readelf.

When building with --enable-shared, the SystemTap/DTrace notes
live in libpython. Add detection logic to be used by readelf.
@bedevere-app bedevere-app Bot added awaiting review tests Tests in the Lib/test dir labels Jun 9, 2026
@stratakis

Copy link
Copy Markdown
Contributor Author

Easily reproducible traceback by:

./configure --with-dtrace --enable-shared && make -j && LD_LIBRARY_PATH=. ./python -m test -vv test_dtrace

This should cover also the install builds, the out of tree builds and their combination. Tested them all and it works.

I don't think a news entry is warranted here.

cc @pablogsal

@vstinner

vstinner commented Jun 9, 2026

Copy link
Copy Markdown
Member

./configure --with-dtrace --enable-shared && make -j && LD_LIBRARY_PATH=. ./python -m test -vv test_dtrace

I tested on Fedora 44. I confirm that currently, test_check_probes() of test_dtrace fails.

With the change, test_dtrace pass (test_check_probes() pass).

But 6 tests are skipped:

setUpClass (test.test_dtrace.BPFTraceNormalTests) ... skipped "bpftrace not available: [Errno 2] No such file or directory: 'bpftrace'"
setUpClass (test.test_dtrace.BPFTraceOptimizedTests) ... skipped "bpftrace not available: [Errno 2] No such file or directory: 'bpftrace'"
skipped 'dtrace(1) failed: /usr/bin/dtrace invalid option -q\nUsage /usr/bin/dtrace [--help] [-h | -G] [-C [-I<Path>]] -s File.d [-o <File>]'
setUpClass (test.test_dtrace.DTraceOptimizedTests) ... skipped 'dtrace(1) failed: /usr/bin/dtrace invalid option -q\nUsage /usr/bin/dtrace [--help] [-h | -G] [-C [-I<Path>]] -s File.d [-o <File>]'
setUpClass (test.test_dtrace.SystemTapNormalTests) ... skipped "stap(1) failed: [Errno 2] No such file or directory: 'stap'"
setUpClass (test.test_dtrace.SystemTapOptimizedTests) ... skipped "stap(1) failed: [Errno 2] No such file or directory: 'stap'"
OK (skipped=6, expected failures=1)
Total tests: run=3 skipped=6

Note: my locale is French (LANG=fr_FR.UTF-8) and test_dtrace fails with my locale. I had to run the test with LC_ALL=C.

@vstinner

vstinner commented Jun 9, 2026

Copy link
Copy Markdown
Member

Ah, /usr/bin/stap was not installed. I had to run sudo dnf install systemtap-client to install it.

I also had to install Linux kernel header files: dnf install kernel-devel.

After these installations, 6 tests are still skipped even if I run test_dtrace as root:

setUpClass (test.test_dtrace.BPFTraceNormalTests) ... skipped "bpftrace not available: [Errno 2] No such file or directory: 'bpftrace'"
setUpClass (test.test_dtrace.BPFTraceOptimizedTests) ... skipped "bpftrace not available: [Errno 2] No such file or directory: 'bpftrace'"
test_filter_probe_rows_ignores_warnings (test.test_dtrace.BPFTraceOutputTests.test_filter_probe_rows_ignores_warnings) ... ok
readelf version: 2.46
test_check_probes (test.test_dtrace.CheckDtraceProbes.test_check_probes) ... ok
test_missing_probes (test.test_dtrace.CheckDtraceProbes.test_missing_probes) ... expected failure
skipped 'dtrace(1) failed: /usr/sbin/dtrace invalid option -q\nUsage /usr/sbin/dtrace [--help] [-h | -G] [-C [-I<Path>]] -s File.d [-o <File>]'
setUpClass (test.test_dtrace.DTraceOptimizedTests) ... skipped 'dtrace(1) failed: /usr/sbin/dtrace invalid option -q\nUsage /usr/sbin/dtrace [--help] [-h | -G] [-C [-I<Path>]] -s File.d [-o <File>]'
setUpClass (test.test_dtrace.SystemTapNormalTests) ... skipped 'stap(1) failed: Checking "/lib/modules/7.0.9-204.fc44.x86_64/build/.config" failed with error: No such file or directory\nIncorrect version or missing kernel-devel package, use: dnf install kernel-devel-7.0.9-204.fc44.x86_64'
setUpClass (test.test_dtrace.SystemTapOptimizedTests) ... skipped 'stap(1) failed: Checking "/lib/modules/7.0.9-204.fc44.x86_64/build/.config" failed with error: No such file or directory\nIncorrect version or missing kernel-devel package, use: dnf install kernel-devel-7.0.9-204.fc44.x86_64'

@vstinner

vstinner commented Jun 9, 2026

Copy link
Copy Markdown
Member

DTraceOptimizedTests is skipped because it runs dtrace with the -q option which doesn't exist (in my dtrace version, systemtap-sdt-dtrace-5.5-1.fc44.x86_64).

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

The code is a little bit complicated (I expected shorter code), but it works as expected. So I'm fine with it.

@vstinner vstinner added skip news needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes needs backport to 3.13 bugs and security fixes labels Jun 9, 2026
Comment thread Lib/test/test_dtrace.py
@vstinner

vstinner commented Jun 9, 2026

Copy link
Copy Markdown
Member

I also installed sudo dnf install bpftrace, but even if I run test_dtrace as root, bpftrace tests fail with the timeout of 10 seconds. In practice, the tests are marked as "skipped" (which is good).

I ran the bpftrace test manually as root. I had to stop it with CTRL+C, it does not display anything.

bpftrace -e 'usdt:/home/vstinner/python/main/python:python:function__entry { printf("probe: success\\n"); exit(); }' '-c' '/usr/bin/true'

@stratakis

Copy link
Copy Markdown
Contributor Author

Locale issue fixed. This shouldn't be backported 3.13 and 3.14 as this actual fixes this is based on is from 3.15+: 9a268e3

@vstinner vstinner removed needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels Jun 10, 2026
@vstinner vstinner merged commit 3a08e93 into python:main Jun 10, 2026
52 checks passed
@miss-islington-app

Copy link
Copy Markdown

Thanks @stratakis for the PR, and @vstinner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.15.
🐍🍒⛏🤖

@bedevere-app

bedevere-app Bot commented Jun 10, 2026

Copy link
Copy Markdown

GH-151235 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Jun 10, 2026
@vstinner

Copy link
Copy Markdown
Member

Merged, thanks for your fix!

vstinner pushed a commit that referenced this pull request Jun 10, 2026
…51122) (#151235)

gh-98894: Fix DTrace test_check_probes for shared builds (GH-151122)

When building with --enable-shared, the SystemTap/DTrace notes
live in libpython. Add detection logic to be used by readelf.

Force the C locale on readelf output.
(cherry picked from commit 3a08e93)

Co-authored-by: stratakis <cstratak@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip news tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants