mirror of
https://github.com/danderson/netboot.git
synced 2025-10-17 10:31:28 +02:00
Use cmp.Diff to compare pcap packets.
This fixes a spurious failure from reflect.DeepEqual.
This commit is contained in:
parent
bff58e14b3
commit
e8185cf62d
@ -10,3 +10,8 @@ import:
|
|||||||
- bpf
|
- bpf
|
||||||
- icmp
|
- icmp
|
||||||
- ipv4
|
- ipv4
|
||||||
|
testImport:
|
||||||
|
- package: github.com/google/go-cmp
|
||||||
|
version: ^0.1.0
|
||||||
|
subpackages:
|
||||||
|
- cmp
|
||||||
|
@ -17,9 +17,10 @@ package pcap
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"reflect"
|
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestReadback(t *testing.T) {
|
func TestReadback(t *testing.T) {
|
||||||
@ -81,8 +82,8 @@ func TestReadback(t *testing.T) {
|
|||||||
t.Fatalf("Reading packets back: %s", r.Err())
|
t.Fatalf("Reading packets back: %s", r.Err())
|
||||||
}
|
}
|
||||||
|
|
||||||
if !reflect.DeepEqual(pkts, readBack) {
|
if diff := cmp.Diff(pkts, readBack); diff != "" {
|
||||||
t.Fatalf("Packets were mutated by write-then-read")
|
t.Fatalf("Packets mutated by write-then-read (-want +got):\n%s", diff)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user