mirror of
https://github.com/danderson/netboot.git
synced 2025-10-17 18:41:26 +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
|
||||
- icmp
|
||||
- ipv4
|
||||
testImport:
|
||||
- package: github.com/google/go-cmp
|
||||
version: ^0.1.0
|
||||
subpackages:
|
||||
- cmp
|
||||
|
@ -17,9 +17,10 @@ package pcap
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/binary"
|
||||
"reflect"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
)
|
||||
|
||||
func TestReadback(t *testing.T) {
|
||||
@ -81,8 +82,8 @@ func TestReadback(t *testing.T) {
|
||||
t.Fatalf("Reading packets back: %s", r.Err())
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(pkts, readBack) {
|
||||
t.Fatalf("Packets were mutated by write-then-read")
|
||||
if diff := cmp.Diff(pkts, readBack); diff != "" {
|
||||
t.Fatalf("Packets mutated by write-then-read (-want +got):\n%s", diff)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user