X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=codec%2Fmarshaler_test.go;h=2a9cb942367f7dc451bcd67d7a87561141ad7fc3;hb=67cea0df30f7ef348e265c9326f7a9f15ba26240;hp=b3b20b071f7ef48f1ef666c6861050150ef5fa9c;hpb=d1f24d37bd447b64e402298bb8eb2479681facf9;p=govpp.git diff --git a/codec/marshaler_test.go b/codec/marshaler_test.go index b3b20b0..2a9cb94 100644 --- a/codec/marshaler_test.go +++ b/codec/marshaler_test.go @@ -19,12 +19,12 @@ import ( "reflect" "testing" - "git.fd.io/govpp.git/api" - "git.fd.io/govpp.git/binapi/ip_types" - "git.fd.io/govpp.git/binapi/sr" - "git.fd.io/govpp.git/codec" - "git.fd.io/govpp.git/internal/testbinapi/binapi2001/interfaces" - "git.fd.io/govpp.git/internal/testbinapi/binapi2001/ip" + "go.fd.io/govpp/api" + "go.fd.io/govpp/binapi/ip_types" + "go.fd.io/govpp/binapi/sr" + "go.fd.io/govpp/codec" + interfaces "go.fd.io/govpp/binapi/interface" + "go.fd.io/govpp/binapi/interface_types" ) // CliInband represents VPP binary API message 'cli_inband'. @@ -102,7 +102,7 @@ func TestWrapperDecode(t *testing.T) { func TestNewCodecEncodeDecode4(t *testing.T) { m := &interfaces.SwInterfaceSetRxMode{ - Mode: interfaces.RX_MODE_API_POLLING, + Mode: interface_types.RX_MODE_API_POLLING, QueueID: 70000, QueueIDValid: true, SwIfIndex: 300, @@ -167,175 +167,3 @@ func TestNewCodecEncodeDecode2(t *testing.T) { t.Fatalf("newData differs from oldData") } } - -func TestNewCodecEncode(t *testing.T) { - m := NewIPRouteLookupReply() - /*m := &sr.SrPoliciesDetails{ - Bsid: sr.IP6Address{00, 11, 22, 33, 44, 55, 66, 77, 88, 99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff}, - IsSpray: true, - IsEncap: false, - FibTable: 33, - NumSidLists: 1, - SidLists: []sr.Srv6SidList{ - { - Weight: 555, - NumSids: 2, - Sids: [16]sr.IP6Address{ - {99}, - {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}, - }, - }, - }, - }*/ - - var err error - var oldData, newData []byte - { - w := codec.Wrapper{m} - size := m.Size() - t.Logf("wrapper size: %d", size) - oldData, err = w.Marshal(nil) - if err != nil { - t.Fatalf("expected nil error, got: %v", err) - } - } - { - size := m.Size() - t.Logf("size: %d", size) - newData, err = m.Marshal(nil) - if err != nil { - t.Fatalf("expected nil error, got: %v", err) - } - } - t.Logf("Data:\nOLD[%d]: % 03x\nNEW[%d]: % 03x", len(oldData), oldData, len(newData), newData) - - if !bytes.Equal(oldData, newData) { - t.Fatalf("newData differs from oldData") - } -} - -func TestNewCodecDecode(t *testing.T) { - data := []byte{ - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, - 0x00, 0x00, 0x00, 0x05, 0x01, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x01, 0x00, - 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x06, 0x00, - 0x00, 0x00, 0x08, 0x09, 0x0a, 0x00, 0x00, 0x00, - 0x0b, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x02, 0x01, 0x09, 0x00, - 0x00, 0x00, 0x08, 0x07, 0x06, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - } - - var err error - var oldData, newData ip.IPRouteAddDel - { - w := codec.Wrapper{&oldData} - err = w.Unmarshal(data) - if err != nil { - t.Errorf("expected nil error, got: %v", err) - } - } - { - err = newData.Unmarshal(data) - if err != nil { - t.Errorf("expected nil error, got: %v", err) - } - } - t.Logf("Data:\nOLD: %+v\nNEW: %+v", oldData, newData) - - if !reflect.DeepEqual(oldData, newData) { - t.Fatalf("newData differs from oldData") - } -} - -func NewIPRouteLookupReply() *ip.IPRouteAddDel { - return &ip.IPRouteAddDel{ - Route: ip.IPRoute{ - TableID: 3, - StatsIndex: 5, - Prefix: ip.Prefix{ - Address: ip.Address{ - Af: ip.ADDRESS_IP6, - Un: ip.AddressUnion{}, - }, - Len: 24, - }, - NPaths: 2, - Paths: []ip.FibPath{ - { - SwIfIndex: 5, - TableID: 6, - RpfID: 8, - Weight: 9, - Preference: 10, - Type: 11, - Flags: 1, - Proto: 2, - Nh: ip.FibPathNh{ - Address: ip.AddressUnion{}, - ViaLabel: 3, - ObjID: 1, - ClassifyTableIndex: 2, - }, - NLabels: 1, - LabelStack: [16]ip.FibMplsLabel{ - { - IsUniform: 9, - Label: 8, - TTL: 7, - Exp: 6, - }, - }, - }, - { - SwIfIndex: 7, - TableID: 6, - RpfID: 8, - Weight: 9, - Preference: 10, - Type: 11, - Flags: 1, - Proto: 1, - Nh: ip.FibPathNh{ - Address: ip.AddressUnion{}, - ViaLabel: 3, - ObjID: 1, - ClassifyTableIndex: 2, - }, - NLabels: 2, - LabelStack: [16]ip.FibMplsLabel{ - { - IsUniform: 9, - Label: 8, - TTL: 7, - Exp: 6, - }, - { - IsUniform: 10, - Label: 8, - TTL: 7, - Exp: 6, - }, - }, - }, - }, - }, - } -}