jameysharp requested fitzgen for a review on PR #4862.
jameysharp opened PR #4862 from test-inputs-length
to main
:
But don't keep going once we've consumed it all.
I got tired of having a bunch of copies of the same all-zeros test inputs at the end. This version always produces exactly one all-zeros test input at the end, which I feel okay about. I could remove that by explicitly checking for
self.u.is_empty()
but, eh, testing an all-zeros input could be useful.This uses less of the fuzz input too since it doesn't need to come up with a count of how many test inputs to generate.
This changes the input format for this fuzz target, so I figure I'll bundle it together with #4824 and merge both sometime next week.
cc: @afonso360
afonso360 submitted PR review.
fitzgen submitted PR review.
fitzgen submitted PR review.
fitzgen created PR review comment:
Might be simpler as
loop { inputs.push(todo!("generate one input")); if u.is_empty() { break; } }
which avoids the semi-subtle use of
usize::MAX
here.
jameysharp created PR review comment:
That's how I wrote it first, actually! I could go back to
loop
plus a conditionalbreak
at the end if you want. But just testingu.is_empty
doesn't work if generating an input doesn't consume any ofu
: it loops forever then. The usual way that would happen is if the generated function doesn't take any parameters, but I haven't ruled out the possibility that a parameter could only have one legal value and therefore consume no input. So instead I check that the loop makes some progress on every iteration, and stop after the first iteration where it doesn't make progress.I agree that using
usize::MAX
here is subtle. We'd get nearly the same result from initializinglast_len
toself.u.len() + 1
, if that would make you feel better?
jameysharp submitted PR review.
fitzgen submitted PR review.
fitzgen created PR review comment:
I guess we could also have a maximum length on
inputs
as well.Otherwise I guess I would prefer making
last_len
an option and doing something likewhile last_len.map_or(true, |last_len| self.u.len() < last_len) { ... }
jameysharp submitted PR review.
jameysharp created PR review comment:
I'm definitely not a fan of that alternative :laughing: but I can still move the test to the end of the loop, if that works for you.
jameysharp updated PR #4862 from test-inputs-length
to main
.
jameysharp merged PR #4862.
Last updated: Nov 22 2024 at 17:03 UTC