Commit 40cbb57
committed
test(sandbox): harden procfs binary_path tests against fork/exec race and ETXTBSY
Three tests in `procfs::tests` are flaky on arm64 CI containers:
* `binary_path_strips_deleted_suffix`, `binary_path_preserves_live_deleted_basename`
— `std::process::Command::spawn()` returns once the child is scheduled, not once
it has completed `exec()`. On a contended arm64 runner, reading `/proc/<pid>/exe`
immediately after spawn can return the parent (test-harness) path for a brief
window. The tests then assert the child's exe matches their target path and
fail with the harness path on the left.
* `binary_path_strips_suffix_for_non_utf8_filename` — sporadically gets ETXTBSY
on spawn despite the existing `sync_all()` + scope drop. The writer fd is
closed, but the kernel's write-lock release races the immediately-following
`execveat()` under load.
Adds two test helpers and applies them to the three tests:
* `wait_for_child_exec(pid, target)` polls `/proc/<pid>/exe` until the readlink's
byte prefix matches `target`, with a 2 s deadline. Tolerates the kernel's
`" (deleted)"` suffix on unlinked binaries.
* `spawn_retrying_on_etxtbsy(cmd)` retries `Command::spawn()` up to 20 times
with a 50 ms backoff when it returns `ETXTBSY`. Any other spawn error
surfaces immediately.
Both helpers are `#[cfg(target_os = "linux")]` and live in the test module;
they don't change any production behaviour. `binary_path` itself is unchanged.1 parent ae7e901 commit 40cbb57
1 file changed
Lines changed: 61 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
399 | 399 | | |
400 | 400 | | |
401 | 401 | | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
402 | 451 | | |
403 | 452 | | |
404 | 453 | | |
| |||
457 | 506 | | |
458 | 507 | | |
459 | 508 | | |
460 | | - | |
461 | | - | |
462 | | - | |
463 | | - | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
464 | 512 | | |
| 513 | + | |
465 | 514 | | |
466 | 515 | | |
467 | 516 | | |
| |||
507 | 556 | | |
508 | 557 | | |
509 | 558 | | |
510 | | - | |
511 | | - | |
512 | | - | |
513 | | - | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
514 | 562 | | |
| 563 | + | |
515 | 564 | | |
516 | 565 | | |
517 | 566 | | |
| |||
564 | 613 | | |
565 | 614 | | |
566 | 615 | | |
567 | | - | |
568 | | - | |
569 | | - | |
570 | | - | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
571 | 619 | | |
| 620 | + | |
572 | 621 | | |
573 | 622 | | |
574 | 623 | | |
| |||
0 commit comments