mirror of
https://github.com/jwetzell/artnet-go.git
synced 2026-08-27 17:48:59 +00:00
add benchmark and fuzz for tests with data
This commit is contained in:
@@ -966,3 +966,11 @@ func BenchmarkArtAddressMarshalBinary(b *testing.B) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func FuzzArtAddressUnmarshalBinary(f *testing.F) {
|
||||||
|
f.Add([]byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x60, 0x00, 0x0e, 0x80, 0x00, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x00, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x00, 0x85, 0x86, 0x87, 0x88, 0x81, 0x82, 0x83, 0x84, 0x80, 0xc8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})
|
||||||
|
f.Fuzz(func(t *testing.T, data []byte) {
|
||||||
|
artAddress := artnet.ArtAddress{}
|
||||||
|
artAddress.UnmarshalBinary(data)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@@ -52,3 +52,51 @@ func TestGoodArtIpProgUnmarshal(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func BenchmarkArtIpProgUnmarshalBinary(b *testing.B) {
|
||||||
|
data := []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0xf8, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
|
||||||
|
|
||||||
|
for b.Loop() {
|
||||||
|
got := artnet.ArtIpProg{}
|
||||||
|
|
||||||
|
err := got.UnmarshalBinary(data)
|
||||||
|
if err != nil {
|
||||||
|
b.Fatalf("failed to decode ArtIpProg: %s", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func BenchmarkArtIpProgMarshalBinary(b *testing.B) {
|
||||||
|
data := artnet.ArtIpProg{
|
||||||
|
Command: 0x00,
|
||||||
|
ProgIpHi: 0x00,
|
||||||
|
ProgIp2: 0x00,
|
||||||
|
ProgIp1: 0x00,
|
||||||
|
ProgIpLo: 0x00,
|
||||||
|
ProgSmHi: 0x00,
|
||||||
|
ProgSm2: 0x00,
|
||||||
|
ProgSm1: 0x00,
|
||||||
|
ProgSmLo: 0x00,
|
||||||
|
ProgPortHi: 0x00,
|
||||||
|
ProgPortLo: 0x00,
|
||||||
|
ProgDgHi: 0x00,
|
||||||
|
ProgDg2: 0x00,
|
||||||
|
ProgDg1: 0x00,
|
||||||
|
ProgDgLo: 0x00,
|
||||||
|
}
|
||||||
|
|
||||||
|
for b.Loop() {
|
||||||
|
_, err := data.MarshalBinary()
|
||||||
|
if err != nil {
|
||||||
|
b.Fatalf("failed to encode ArtIpProg: %s", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func FuzzArtIpProgUnmarshalBinary(f *testing.F) {
|
||||||
|
f.Add([]byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0xf8, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})
|
||||||
|
f.Fuzz(func(t *testing.T, data []byte) {
|
||||||
|
artIpProg := artnet.ArtIpProg{}
|
||||||
|
artIpProg.UnmarshalBinary(data)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@@ -216,3 +216,42 @@ func TestGoodArtPollUnmarshal(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func BenchmarkArtPollUnmarshalBinary(b *testing.B) {
|
||||||
|
data := []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x20, 0x00, 0x0e, 0x00, 0x00, 0x7f, 0xff, 0x00, 0x00, 0x53, 0x79, 0x22, 0x69}
|
||||||
|
|
||||||
|
for b.Loop() {
|
||||||
|
got := artnet.ArtPoll{}
|
||||||
|
|
||||||
|
err := got.UnmarshalBinary(data)
|
||||||
|
if err != nil {
|
||||||
|
b.Fatalf("failed to decode ArtPoll: %s", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func BenchmarkArtPollMarshalBinary(b *testing.B) {
|
||||||
|
data := artnet.ArtPoll{
|
||||||
|
Flags: 0x00,
|
||||||
|
DiagPriority: 0x00,
|
||||||
|
TargetPortAddressTop: 0x7fff,
|
||||||
|
TargetPortAddressBottom: 0x0000,
|
||||||
|
EstaMan: 0x5379,
|
||||||
|
Oem: 0x2269,
|
||||||
|
}
|
||||||
|
|
||||||
|
for b.Loop() {
|
||||||
|
_, err := data.MarshalBinary()
|
||||||
|
if err != nil {
|
||||||
|
b.Fatalf("failed to encode ArtPoll: %s", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func FuzzArtPollUnmarshalBinary(f *testing.F) {
|
||||||
|
f.Add([]byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x20, 0x00, 0x0e, 0x00, 0x00, 0x7f, 0xff, 0x00, 0x00, 0x53, 0x79, 0x22, 0x69})
|
||||||
|
f.Fuzz(func(t *testing.T, data []byte) {
|
||||||
|
artPoll := artnet.ArtPoll{}
|
||||||
|
artPoll.UnmarshalBinary(data)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@@ -40,3 +40,39 @@ func TestGoodArtTodControlUnmarshal(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func BenchmarkArtTodControlUnmarshalBinary(b *testing.B) {
|
||||||
|
data := []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x82, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00}
|
||||||
|
|
||||||
|
for b.Loop() {
|
||||||
|
got := artnet.ArtTodControl{}
|
||||||
|
|
||||||
|
err := got.UnmarshalBinary(data)
|
||||||
|
if err != nil {
|
||||||
|
b.Fatalf("failed to decode ArtTodControl: %s", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func BenchmarkArtTodControlMarshalBinary(b *testing.B) {
|
||||||
|
data := artnet.ArtTodControl{
|
||||||
|
Net: 0x00,
|
||||||
|
Command: artnet.AtcFlush,
|
||||||
|
Address: 0x00,
|
||||||
|
}
|
||||||
|
|
||||||
|
for b.Loop() {
|
||||||
|
_, err := data.MarshalBinary()
|
||||||
|
if err != nil {
|
||||||
|
b.Fatalf("failed to encode ArtTodControl: %s", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func FuzzArtTodControlUnmarshalBinary(f *testing.F) {
|
||||||
|
f.Add([]byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x82, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00})
|
||||||
|
f.Fuzz(func(t *testing.T, data []byte) {
|
||||||
|
artTodControl := artnet.ArtTodControl{}
|
||||||
|
artTodControl.UnmarshalBinary(data)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@@ -193,3 +193,39 @@ func TestGoodArtTodRequestUnmarshal(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func BenchmarkArtTodRequestUnmarshalBinary(b *testing.B) {
|
||||||
|
data := []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x80, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
|
||||||
|
|
||||||
|
for b.Loop() {
|
||||||
|
got := artnet.ArtTodRequest{}
|
||||||
|
|
||||||
|
err := got.UnmarshalBinary(data)
|
||||||
|
if err != nil {
|
||||||
|
b.Fatalf("failed to decode ArtTodRequest: %s", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func BenchmarkArtTodRequestMarshalBinary(b *testing.B) {
|
||||||
|
data := artnet.ArtTodRequest{
|
||||||
|
Command: artnet.TodFull,
|
||||||
|
Net: 0x00,
|
||||||
|
Address: []uint8{0x10},
|
||||||
|
}
|
||||||
|
|
||||||
|
for b.Loop() {
|
||||||
|
_, err := data.MarshalBinary()
|
||||||
|
if err != nil {
|
||||||
|
b.Fatalf("failed to encode ArtTodRequest: %s", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func FuzzArtTodRequestUnmarshalBinary(f *testing.F) {
|
||||||
|
f.Add([]byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x80, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})
|
||||||
|
f.Fuzz(func(t *testing.T, data []byte) {
|
||||||
|
artTodRequest := artnet.ArtTodRequest{}
|
||||||
|
artTodRequest.UnmarshalBinary(data)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user