FuzzXOR2Chunk fuzzes the XOR2 chunk round-trip. The seed and count parameters drive a deterministic RNG that generates start timestamps, timestamps, and values; nanMask forces StaleNaN on specific samples (bit i set → sample i is StaleNaN); stMode selects whether ST stays absent, constant, appears l
(f *testing.F)
| 189 | // or changes with small or large deltas. This ensures the stale-NaN and ST |
| 190 | // encoding paths are exercised without relying on random chance. |
| 191 | func FuzzXOR2Chunk(f *testing.F) { |
| 192 | for _, s := range GetCorpusForFuzzXOR2Chunk() { |
| 193 | f.Add(s.Seed, s.N, s.NaNMask, s.STMode) |
| 194 | } |
| 195 | |
| 196 | f.Fuzz(func(t *testing.T, seed int64, n uint8, nanMask uint64, stMode uint8) { |
| 197 | count := int(n)%130 + 1 |
| 198 | r := rand.New(rand.NewSource(seed)) |
| 199 | |
| 200 | type sample struct { |
| 201 | st, t int64 |
| 202 | v float64 |
| 203 | } |
| 204 | samples := make([]sample, count) |
| 205 | var ts int64 |
| 206 | activeST := int64(0) |
| 207 | constantST := int64(0) |
| 208 | lateSTIndex := 1 |
| 209 | if count > 1 { |
| 210 | lateSTIndex = int(r.Int31n(int32(count-1))) + 1 |
| 211 | } |
| 212 | for i := range count { |
| 213 | ts += r.Int63n(10000) + 1 |
| 214 | v := math.Float64frombits(r.Uint64()) |
| 215 | if i < 64 && nanMask>>uint(i)&1 == 1 { |
| 216 | v = math.Float64frombits(value.StaleNaN) |
| 217 | } |
| 218 | |
| 219 | var st int64 |
| 220 | switch stMode % 5 { |
| 221 | case 0: |
| 222 | st = 0 |
| 223 | case 1: |
| 224 | if i == 0 { |
| 225 | constantST = ts - (r.Int63n(10000) + 1) |
| 226 | } |
| 227 | st = constantST |
| 228 | case 2: |
| 229 | if i >= lateSTIndex { |
| 230 | if i == lateSTIndex { |
| 231 | constantST = ts - (r.Int63n(10000) + 1) |
| 232 | } |
| 233 | st = constantST |
| 234 | } |
| 235 | case 3: |
| 236 | if i == 0 { |
| 237 | activeST = ts - (r.Int63n(10000) + 1) |
| 238 | } else { |
| 239 | activeST -= r.Int63n(8) - 3 |
| 240 | } |
| 241 | st = activeST |
| 242 | default: |
| 243 | activeST = ts - r.Int63() |
| 244 | st = activeST |
| 245 | } |
| 246 | |
| 247 | samples[i] = sample{ |
| 248 | st: st, |
nothing calls this directly
no test coverage detected
searching dependent graphs…