edith_codecs
Clone
https://git.tahinli.com/Tahinli/edith_codecs.git
0 watching0 forksRust370.3 MiB6c956a2Tahinli2 months ago3708 commits
| 1 | #!/usr/bin/env bash |
| 2 | # Wraps a test/bin invocation in a transient user cgroup scope so a runaway |
| 3 | # allocation dies inside its own cgroup instead of triggering a machine-wide |
| 4 | # OOM kill. Used as the cargo target runner (see .cargo/config.toml) so every |
| 5 | # `cargo test`/`cargo run` invocation of this workspace is capped, from any |
| 6 | # checkout (main repo or worktree). |
| 7 | |
| 8 | |
| 9 | if [; then |
| 10 | |
| 11 | |
| 12 | fi |
| 13 | |
| 14 | if ! ; then |
| 15 | |
| 16 | |
| 17 | fi |
| 18 | |
| 19 | # Explicit unique unit name: systemd-run derives `run-p<pid>.scope` when no |
| 20 | # --unit is given, so a scope left loaded from an earlier run (or a reused |
| 21 | # pid) collides with "Unit run-pNNN.scope was already loaded or has a |
| 22 | # fragment file" -- the wrapped binary then never starts, which reads as a |
| 23 | # broken tree rather than a runner collision. Measured 2026-09-29: three |
| 24 | # lanes hit it in one batch and their workaround was invoking the test |
| 25 | # binary directly, losing the memory cap. |
| 26 | # |
| 27 | # The collision is detected by PROBING, never by the wrapped command's exit |
| 28 | # status: `systemd-run --scope` returns the command's own status, so |
| 29 | # retrying on non-zero would run every failing test twice. |
| 30 | unit="memguard--" |
| 31 | # The probe must NOT reuse `$unit`: a transient scope stays loaded after it |
| 32 | # exits, so probing and then exec'ing under the same --unit fails with |
| 33 | # "unit was already loaded or has a fragment file" -- measured directly on |
| 34 | # 2026-09-29 (the probe's own scope was the collision). Probe under "-probe". |
| 35 | if ! ; then |
| 36 | # Clear a stale fragment for this name (and any leftover default-named |
| 37 | # scope) and probe once more before giving up on the cap. |
| 38 | |
| 39 | |
| 40 | || |
| 41 | || |
| 42 | if ! ; then |
| 43 | |
| 44 | |
| 45 | fi |
| 46 | |
| 47 | |
| 48 | |
| 49 | fi |
| 50 | |
| 51 | |
| 52 | |
| 53 |