Skip to content

pgrep: retry flaky test_thread_ids - #839

Merged
sylvestre merged 2 commits into
uutils:mainfrom
sarankumar1325:pgrep-retry-flaky-test-thread-ids
Nov 11, 2026
Merged

sylvestre merged 2 commits into
uutils:mainfrom
sarankumar1325:pgrep-retry-flaky-test-thread-ids

Conversation

@sarankumar1325

Copy link
Copy Markdown
Contributor

Fixes #471.

test_thread_ids took a single /proc/<pid>/task snapshot from a newly spawned thread. That directory can lag, so the new tid was sometimes missing and the test failed at random in PR CI (and not on main, where it is rarely retried).

The test now polls until both the main and new thread ids are visible, or panics with the snapshot after two seconds. A new ProcessInformation is built on each try because thread_ids() caches the walk.

cargo +1.88.0 test -p uu_pgrep test_thread_ids passed.

The test took a single /proc/<pid>/task snapshot from a newly spawned
thread. That directory can lag, so the new tid was sometimes missing and
the test failed at random in PR CI.

Poll until both the main and new thread ids are visible, or fail with
the snapshot after two seconds.

Fixes uutils#471

Signed-off-by: sarankumar1325 <120080287+sarankumar1325@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 11, 2026 05:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@codecov

codecov Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 20.13%. Comparing base (67832aa) to head (080b5c1).
⚠️ Report is 32 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #839      +/-   ##
==========================================
+ Coverage   19.20%   20.13%   +0.93%     
==========================================
  Files          68       68              
  Lines       10156    10346     +190     
  Branches      546      552       +6     
==========================================
+ Hits         1950     2083     +133     
- Misses       8206     8263      +57     
Flag Coverage Δ
macos_latest 7.00% <ø> (+0.25%) ⬆️
ubuntu_latest 20.50% <ø> (+0.94%) ⬆️
windows_latest 0.02% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread src/uu/pgrep/src/process.rs Outdated
let new_thread_tid = rustix::thread::gettid().as_raw_nonzero().get() as u64;
assert!(thread_ids.contains(&(new_thread_tid as usize)));
let new_thread_tid = rustix::thread::gettid().as_raw_nonzero().get() as usize;
// /proc/<pid>/task can lag a newly started thread, and a single

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is it really a lag? the thread is already running when it reads its own task dir
i think it is more readdir skipping entries while other test threads exit concurrently, could you please reword?

The new thread is already running when it reads its own task directory.
The miss comes from readdir on /proc/<pid>/task skipping entries while
other test threads exit concurrently, not from the directory lagging.

Signed-off-by: sarankumar1325 <120080287+sarankumar1325@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 11, 2026 08:51

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@sylvestre
sylvestre merged commit e7d6ba1 into uutils:main Nov 11, 2026
18 checks passed
@sylvestre

Copy link
Copy Markdown
Contributor

Thanks for your PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test process::tests::test_thread_ids randomly fails

3 participants