diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2024-06-24 11:39:39 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2024-07-02 15:07:08 +0000 |
| commit | 3d475bc56886c8183b3189b762451095985b6c84 (patch) | |
| tree | 10bac897dc3c3cb1e9e2d655a5becaff8a9d1eb3 /prog/rand.go | |
| parent | 0be05f03ef149d0a149a51bf1111a5153708b1ef (diff) | |
prog: reduce amount of hint replacements
Several optimizations to reduce amount of hint replacements:
1. Don't mutate int's that are <= 8 bits.
2. Don't mutate data that is <= 3 bytes.
3. Restrict mutation of len only value >10 and < 1<<20.
Values <= 10 we can produce during normal mutation.
Values > 1<<20 are presumably not length of something
and we have logic to produce various large bogus lengths.
4. Include all small ints <= 16 into specialInts and remove 31, 32, 63
(don't remember where they come from).
5. Don't produce other known flags (and combinations) for flags.
And a larger part computes groups of related arguments
so that we don't try to produce known ioctl's from other known ioctl's,
and similarly for socket/socketpair/setsockopt/etc.
See comments in Target.initRelatedFields for details.
Update #477
Diffstat (limited to 'prog/rand.go')
| -rw-r--r-- | prog/rand.go | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/prog/rand.go b/prog/rand.go index c55d43a3f..b15871b8a 100644 --- a/prog/rand.go +++ b/prog/rand.go @@ -66,8 +66,8 @@ func (r *randGen) rand64() uint64 { var ( // Some potentially interesting integers. specialInts = []uint64{ - 0, 1, 31, 32, 63, 64, 127, 128, - 129, 255, 256, 257, 511, 512, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 64, 127, 128, 129, 255, 256, 257, 511, 512, 1023, 1024, 1025, 2047, 2048, 4095, 4096, (1 << 15) - 1, (1 << 15), (1 << 15) + 1, (1 << 16) - 1, (1 << 16), (1 << 16) + 1, @@ -153,11 +153,12 @@ func (r *randGen) biasedRand(n, k int) int { return int(bf) } +const maxArrayLen = 10 + func (r *randGen) randArrayLen() uint64 { - const maxLen = 10 // biasedRand produces: 10, 9, ..., 1, 0, // we want: 1, 2, ..., 9, 10, 0 - return uint64(maxLen-r.biasedRand(maxLen+1, 10)+1) % (maxLen + 1) + return uint64(maxArrayLen-r.biasedRand(maxArrayLen+1, 10)+1) % (maxArrayLen + 1) } func (r *randGen) randBufLen() (n uint64) { |
