-func TestRequestReplyTapConnect(t *testing.T) {
- ctx := setupTest(t)
- defer ctx.teardownTest()
-
- // mock reply
- ctx.mockVpp.MockReply(&tap.TapConnectReply{
- SwIfIndex: 1,
- })
-
- request := &tap.TapConnect{
- TapName: []byte("test-tap-name"),
- UseRandomMac: 1,
- }
- reply := &tap.TapConnectReply{}
-
- err := ctx.ch.SendRequest(request).ReceiveReply(reply)
- Expect(err).ShouldNot(HaveOccurred())
- Expect(reply.Retval).To(BeEquivalentTo(0),
- "Incorrect Retval value for TapConnectReply")
- Expect(reply.SwIfIndex).To(BeEquivalentTo(1),
- "Incorrect SwIfIndex value for TapConnectReply")
-}
-
-func TestRequestReplyTapModify(t *testing.T) {
- ctx := setupTest(t)
- defer ctx.teardownTest()
-
- // mock reply
- ctx.mockVpp.MockReply(&tap.TapModifyReply{
- SwIfIndex: 2,
- })
-
- request := &tap.TapModify{
- TapName: []byte("test-tap-modify"),
- UseRandomMac: 1,
- CustomDevInstance: 1,
- }
- reply := &tap.TapModifyReply{}
-
- err := ctx.ch.SendRequest(request).ReceiveReply(reply)
- Expect(err).ShouldNot(HaveOccurred())
- Expect(reply.Retval).To(BeEquivalentTo(0),
- "Incorrect Retval value for TapModifyReply")
- Expect(reply.SwIfIndex).To(BeEquivalentTo(2),
- "Incorrect SwIfIndex value for TapModifyReply")
-}
-
-func TestRequestReplyTapDelete(t *testing.T) {
- ctx := setupTest(t)
- defer ctx.teardownTest()
-
- // mock reply
- ctx.mockVpp.MockReply(&tap.TapDeleteReply{})
-
- request := &tap.TapDelete{
- SwIfIndex: 3,
- }
- reply := &tap.TapDeleteReply{}
-
- err := ctx.ch.SendRequest(request).ReceiveReply(reply)
- Expect(err).ShouldNot(HaveOccurred())
- Expect(reply.Retval).To(BeEquivalentTo(0),
- "Incorrect Retval value for TapDeleteReply")
-}
-
-func TestRequestReplySwInterfaceTapDump(t *testing.T) {
- ctx := setupTest(t)
- defer ctx.teardownTest()
-
- // mock reply
- byteName := []byte("dev-name-test")
- ctx.mockVpp.MockReply(&tap.SwInterfaceTapDetails{
- SwIfIndex: 25,
- DevName: byteName,
- })
-
- request := &tap.SwInterfaceTapDump{}
- reply := &tap.SwInterfaceTapDetails{}
-
- err := ctx.ch.SendRequest(request).ReceiveReply(reply)
- Expect(err).ShouldNot(HaveOccurred())
- Expect(reply.SwIfIndex).To(BeEquivalentTo(25),
- "Incorrect SwIfIndex value for SwInterfaceTapDetails")
- Expect(reply.DevName).ToNot(BeEquivalentTo(byteName),
- "Incorrect DevName value for SwInterfaceTapDetails")
-}
-