Update to go1.24.0

This commit is contained in:
Vorapol Rinsatitnon
2025-02-14 12:42:07 +07:00
parent 25e497e367
commit bf266cebe6
3169 changed files with 236789 additions and 60275 deletions

View File

@@ -6,6 +6,7 @@ package fuzz
import (
"bytes"
"fmt"
"testing"
)
@@ -33,12 +34,6 @@ func (mr *mockRand) uint32n(n uint32) uint32 {
return uint32(c) % n
}
func (mr *mockRand) exp2() int {
c := mr.values[mr.counter]
mr.counter++
return c
}
func (mr *mockRand) bool() bool {
b := mr.b
mr.b = !mr.b
@@ -184,3 +179,43 @@ func TestByteSliceMutators(t *testing.T) {
})
}
}
func BenchmarkByteSliceMutators(b *testing.B) {
tests := [...]struct {
name string
mutator func(*mutator, []byte) []byte
}{
{"RemoveBytes", byteSliceRemoveBytes},
{"InsertRandomBytes", byteSliceInsertRandomBytes},
{"DuplicateBytes", byteSliceDuplicateBytes},
{"OverwriteBytes", byteSliceOverwriteBytes},
{"BitFlip", byteSliceBitFlip},
{"XORByte", byteSliceXORByte},
{"SwapByte", byteSliceSwapByte},
{"ArithmeticUint8", byteSliceArithmeticUint8},
{"ArithmeticUint16", byteSliceArithmeticUint16},
{"ArithmeticUint32", byteSliceArithmeticUint32},
{"ArithmeticUint64", byteSliceArithmeticUint64},
{"OverwriteInterestingUint8", byteSliceOverwriteInterestingUint8},
{"OverwriteInterestingUint16", byteSliceOverwriteInterestingUint16},
{"OverwriteInterestingUint32", byteSliceOverwriteInterestingUint32},
{"InsertConstantBytes", byteSliceInsertConstantBytes},
{"OverwriteConstantBytes", byteSliceOverwriteConstantBytes},
{"ShuffleBytes", byteSliceShuffleBytes},
{"SwapBytes", byteSliceSwapBytes},
}
for _, tc := range tests {
b.Run(tc.name, func(b *testing.B) {
for size := 64; size <= 1024; size *= 2 {
b.Run(fmt.Sprintf("%d", size), func(b *testing.B) {
m := &mutator{r: newPcgRand()}
input := make([]byte, size)
for i := 0; i < b.N; i++ {
tc.mutator(m, input)
}
})
}
})
}
}

View File

@@ -17,7 +17,6 @@ type mutatorRand interface {
uint32() uint32
intn(int) int
uint32n(uint32) uint32
exp2() int
bool() bool
save(randState, randInc *uint64)
@@ -123,11 +122,6 @@ func (r *pcgRand) uint32n(n uint32) uint32 {
return uint32(prod >> 32)
}
// exp2 generates n with probability 1/2^(n+1).
func (r *pcgRand) exp2() int {
return bits.TrailingZeros32(r.uint32())
}
// bool generates a random bool.
func (r *pcgRand) bool() bool {
return r.uint32()&1 == 0

View File

@@ -682,7 +682,7 @@ func (ws *workerServer) serve(ctx context.Context) error {
}
// chainedMutations is how many mutations are applied before the worker
// resets the input to it's original state.
// resets the input to its original state.
// NOTE: this number was picked without much thought. It is low enough that
// it seems to create a significant diversity in mutated inputs. We may want
// to consider looking into this more closely once we have a proper performance