Compare commits

...

1 Commits

Author SHA1 Message Date
Xavier Roche
5f4b1cef1a tests: assert the strjoker budget fired, not just that work stayed bounded
The filterbounds self-test added in #551 asserted `steps < 10*maxsteps`, which
catches a budget whose enforcement is dropped (the counter still climbs to
~1.26e9). But the counter and the enforcement are the same statement, so
deleting the budget line outright leaves steps at 0: `0 < 10*maxsteps` holds and
the probe passes. Only the trailing strjokerfind call then catches it, by
hanging into a harness timeout, which is exactly what #551 set out to remove.

Add the floor `steps > maxsteps`: the budget must push the counter past the cap.
Deleting the budget now aborts the test in milliseconds instead of timing out.
Verified both regressions (line deleted; enforcement dropped) trip an assertion.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Xavier Roche <roche@httrack.com>
2026-07-12 16:03:24 +02:00

View File

@@ -767,10 +767,10 @@ static int st_filterbounds(httrackp *opt, int argc, char **argv) {
pat[2 * stars] = 'b'; /* never matches an all-'a' subject */
pat[2 * stars + 1] = '\0';
subj[subjlen] = '\0';
/* Budget must bound the work; NULL alone wouldn't prove it (a cheap mismatch
is NULL too). */
/* Budget must fire and hold: steps > cap (deleting the budget zeroes the
counter that is the enforcement), steps < 10*cap (unbudgeted ~1.26e9). */
assertf(strjoker_steps(subj, pat, &steps, &maxsteps) == NULL);
assertf(steps < 10 * maxsteps);
assertf(steps > maxsteps && steps < 10 * maxsteps);
assertf(strjokerfind(subj, pat) == NULL);
freet(pat);
freet(subj);