diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/channel.go | 14 | ||||
-rw-r--r-- | core/channel_test.go | 12 |
2 files changed, 18 insertions, 8 deletions
diff --git a/core/channel.go b/core/channel.go index 5b513e3..363a267 100644 --- a/core/channel.go +++ b/core/channel.go @@ -23,6 +23,7 @@ import ( "github.com/sirupsen/logrus" + "git.fd.io/govpp.git/adapter" "git.fd.io/govpp.git/api" ) @@ -144,14 +145,23 @@ func (ch *Channel) SendMultiRequest(msg api.Message) api.MultiRequestCtx { } func (ch *Channel) CheckCompatiblity(msgs ...api.Message) error { + var comperr api.CompatibilityError for _, msg := range msgs { - // TODO: collect all incompatible messages and return summarized error _, err := ch.msgIdentifier.GetMessageID(msg) if err != nil { + if uerr, ok := err.(*adapter.UnknownMsgError); ok { + m := fmt.Sprintf("%s_%s", uerr.MsgName, uerr.MsgCrc) + comperr.IncompatibleMessages = append(comperr.IncompatibleMessages, m) + continue + } + // other errors return immediatelly return err } } - return nil + if len(comperr.IncompatibleMessages) == 0 { + return nil + } + return &comperr } func (ch *Channel) SubscribeNotification(notifChan chan api.Message, event api.Message) (api.SubscriptionCtx, error) { diff --git a/core/channel_test.go b/core/channel_test.go index 7e721cd..849255a 100644 --- a/core/channel_test.go +++ b/core/channel_test.go @@ -213,15 +213,15 @@ func TestSetReplyTimeoutMultiRequest(t *testing.T) { ctx.mockVpp.MockReply( &interfaces.SwInterfaceDetails{ SwIfIndex: 1, - InterfaceName: []byte("if-name-test"), + InterfaceName: "if-name-test", }, &interfaces.SwInterfaceDetails{ SwIfIndex: 2, - InterfaceName: []byte("if-name-test"), + InterfaceName: "if-name-test", }, &interfaces.SwInterfaceDetails{ SwIfIndex: 3, - InterfaceName: []byte("if-name-test"), + InterfaceName: "if-name-test", }, ) ctx.mockVpp.MockReply(&ControlPingReply{}) @@ -288,7 +288,7 @@ func TestMultiRequestDouble(t *testing.T) { msgs = append(msgs, mock.MsgWithContext{ Msg: &interfaces.SwInterfaceDetails{ SwIfIndex: uint32(i), - InterfaceName: []byte("if-name-test"), + InterfaceName: "if-name-test", }, Multipart: true, SeqNum: 1, @@ -301,7 +301,7 @@ func TestMultiRequestDouble(t *testing.T) { mock.MsgWithContext{ Msg: &interfaces.SwInterfaceDetails{ SwIfIndex: uint32(i), - InterfaceName: []byte("if-name-test"), + InterfaceName: "if-name-test", }, Multipart: true, SeqNum: 2, @@ -427,7 +427,7 @@ func TestReceiveReplyAfterTimeoutMultiRequest(t *testing.T) { msgs = append(msgs, mock.MsgWithContext{ Msg: &interfaces.SwInterfaceDetails{ SwIfIndex: uint32(i), - InterfaceName: []byte("if-name-test"), + InterfaceName: "if-name-test", }, Multipart: true, SeqNum: 2, |