Added capability to test decoding of asn buffers 32/2232/1
authorJuha Hyttinen <juha.hyttinen@nokia.com>
Wed, 15 Jan 2020 13:39:32 +0000 (15:39 +0200)
committerJuha Hyttinen <juha.hyttinen@nokia.com>
Wed, 15 Jan 2020 13:40:05 +0000 (15:40 +0200)
Change-Id: Ie587393a6dbab6e42d5ad1a770b69820e062e7d7
Signed-off-by: Juha Hyttinen <juha.hyttinen@nokia.com>
e2ap/pkg/e2ap/e2ap_tests/msg.go
e2ap/pkg/e2ap/e2ap_tests/msg_e2ap_subscription.go
e2ap/pkg/e2ap/e2ap_tests/msg_e2ap_subscriptiondelete.go

index b94cacc..7502cf1 100644 (file)
 package e2ap_tests
 
 import (
+       "encoding/hex"
        "fmt"
        "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap"
+       "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/packer"
        "github.com/google/go-cmp/cmp"
        "log"
        "os"
@@ -76,6 +78,17 @@ type E2ApTests struct {
        packerif e2ap.E2APPackerIf
 }
 
+func (testCtxt *E2ApTests) toPackedData(t *testing.T, buffer string) *packer.PackedData {
+       msg, err := hex.DecodeString(buffer)
+       if err != nil {
+               testCtxt.testError(t, "Hex DecodeString Failed: %s [%s]", err.Error(), buffer)
+               return nil
+       }
+       packedData := &packer.PackedData{}
+       packedData.Buf = msg
+       return packedData
+}
+
 func NewE2ApTests(name string, packerif e2ap.E2APPackerIf) *E2ApTests {
        testCtxt := &E2ApTests{}
        testCtxt.packerif = packerif
@@ -101,4 +114,11 @@ func RunTests(t *testing.T, e2aptestctxt *E2ApTests) {
                e2aptestctxt.E2ApTestMsgSubscriptionDeleteFailure(t)
        })
        t.Run(e2aptestctxt.Name(), func(t *testing.T) { e2aptestctxt.E2ApTestMsgIndication(t) })
+
+       t.Run(e2aptestctxt.Name(), func(t *testing.T) { e2aptestctxt.E2ApTestMsgSubscriptionRequestBuffers(t) })
+       t.Run(e2aptestctxt.Name(), func(t *testing.T) { e2aptestctxt.E2ApTestMsgSubscriptionResponseBuffers(t) })
+       t.Run(e2aptestctxt.Name(), func(t *testing.T) { e2aptestctxt.E2ApTestMsgSubscriptionFailureBuffers(t) })
+       t.Run(e2aptestctxt.Name(), func(t *testing.T) { e2aptestctxt.E2ApTestMsgSubscriptionDeleteRequestBuffers(t) })
+       t.Run(e2aptestctxt.Name(), func(t *testing.T) { e2aptestctxt.E2ApTestMsgSubscriptionDeleteResponseBuffers(t) })
+       t.Run(e2aptestctxt.Name(), func(t *testing.T) { e2aptestctxt.E2ApTestMsgSubscriptionDeleteFailureBuffers(t) })
 }
index 348fe4e..10b2d12 100644 (file)
@@ -231,3 +231,92 @@ func (testCtxt *E2ApTests) E2ApTestMsgSubscriptionFailure(t *testing.T) {
        }
        testCtxt.testValueEquality(t, "msg", &afailenc, afaildec)
 }
+
+func (testCtxt *E2ApTests) E2ApTestMsgSubscriptionRequestBuffers(t *testing.T) {
+
+       testfunc := func(buffer string) {
+               packedData := testCtxt.toPackedData(t, buffer)
+               if packedData == nil {
+                       return
+               }
+               e2SubResp := testCtxt.packerif.NewPackerSubscriptionRequest()
+               err := e2SubResp.UnPack(packedData)
+               if err != nil {
+                       testCtxt.testError(t, "UnPack() Failed: %s [%s]", err.Error(), buffer)
+                       return
+               }
+               err, _ = e2SubResp.Get()
+               if err != nil {
+                       testCtxt.testError(t, "Get() Failed: %s [%s]", err.Error(), buffer)
+                       return
+               }
+               testCtxt.testPrint("OK [%s]", buffer)
+       }
+
+       testCtxt.SetDesc("SubReqBuffer")
+       testfunc("00c9402c000003ea7e00050000010000ea6300020001ea810016000b00130051407b000000054000ea6b000420000000")
+}
+
+func (testCtxt *E2ApTests) E2ApTestMsgSubscriptionResponseBuffers(t *testing.T) {
+
+       testfunc := func(buffer string) {
+               packedData := testCtxt.toPackedData(t, buffer)
+               if packedData == nil {
+                       return
+               }
+               e2SubResp := testCtxt.packerif.NewPackerSubscriptionResponse()
+               err := e2SubResp.UnPack(packedData)
+               if err != nil {
+                       testCtxt.testError(t, "UnPack() Failed: %s [%s]", err.Error(), buffer)
+                       return
+               }
+               err, _ = e2SubResp.Get()
+               if err != nil {
+                       testCtxt.testError(t, "Get() Failed: %s [%s]", err.Error(), buffer)
+                       return
+               }
+               testCtxt.testPrint("OK [%s]", buffer)
+       }
+
+       testCtxt.SetDesc("SubRespBuffer")
+       testfunc("20c9402a000004ea7e00050000018009ea6300020001ea6c000700ea6d00020000ea6e000908ea6f000400000040")
+       testfunc("20c9402a000004ea7e000500000106e7ea6300020001ea6c000700ea6d00020000ea6e000908ea6f000400000040")
+       testfunc("20c9402a000004ea7e000500000106e8ea6300020001ea6c000700ea6d00020000ea6e000908ea6f000400000040")
+       testfunc("20c9402a000004ea7e000500000106e9ea6300020001ea6c000700ea6d00020000ea6e000908ea6f000400000040")
+       testfunc("20c9402a000004ea7e000500000106eaea6300020001ea6c000700ea6d00020000ea6e000908ea6f000400000040")
+       testfunc("20c9402a000004ea7e000500000106ebea6300020001ea6c000700ea6d00020000ea6e000908ea6f000400000040")
+       testfunc("20c9402a000004ea7e000500000106ecea6300020001ea6c000700ea6d00020000ea6e000908ea6f000400000040")
+       testfunc("20c9402a000004ea7e000500000106edea6300020001ea6c000700ea6d00020000ea6e000908ea6f000400000040")
+       testfunc("20c9402a000004ea7e000500000106eeea6300020001ea6c000700ea6d00020000ea6e000908ea6f000400000040")
+       testfunc("20c9402a000004ea7e000500000106efea6300020001ea6c000700ea6d00020000ea6e000908ea6f000400000040")
+       testfunc("20c9402a000004ea7e000500000106f0ea6300020001ea6c000700ea6d00020000ea6e000908ea6f000400000040")
+       testfunc("20c9402a000004ea7e000500000106f4ea6300020001ea6c000700ea6d00020000ea6e000908ea6f000400000040")
+       testfunc("20c9402a000004ea7e000500000106f5ea6300020001ea6c000700ea6d00020000ea6e000908ea6f000400000040")
+       testfunc("20c9402a000004ea7e000500000106f6ea6300020001ea6c000700ea6d00020000ea6e000908ea6f000400000040")
+
+}
+
+func (testCtxt *E2ApTests) E2ApTestMsgSubscriptionFailureBuffers(t *testing.T) {
+
+       testfunc := func(buffer string) {
+               packedData := testCtxt.toPackedData(t, buffer)
+               if packedData == nil {
+                       return
+               }
+               e2SubResp := testCtxt.packerif.NewPackerSubscriptionFailure()
+               err := e2SubResp.UnPack(packedData)
+               if err != nil {
+                       testCtxt.testError(t, "UnPack() Failed: %s [%s]", err.Error(), buffer)
+                       return
+               }
+               err, _ = e2SubResp.Get()
+               if err != nil {
+                       testCtxt.testError(t, "Get() Failed: %s [%s]", err.Error(), buffer)
+                       return
+               }
+               testCtxt.testPrint("OK [%s]", buffer)
+       }
+
+       testCtxt.SetDesc("SubFailBuffer")
+       testfunc("40c94017000003ea7e000500000106f3ea6300020001ea6e000100")
+}
index 4cae8cc..aa20637 100644 (file)
@@ -167,3 +167,103 @@ func (testCtxt *E2ApTests) E2ApTestMsgSubscriptionDeleteFailure(t *testing.T) {
        }
        testCtxt.testValueEquality(t, "msg", &afailenc, afaildec)
 }
+
+func (testCtxt *E2ApTests) E2ApTestMsgSubscriptionDeleteRequestBuffers(t *testing.T) {
+
+       testfunc := func(buffer string) {
+               packedData := testCtxt.toPackedData(t, buffer)
+               if packedData == nil {
+                       return
+               }
+               e2SubResp := testCtxt.packerif.NewPackerSubscriptionDeleteRequest()
+               err := e2SubResp.UnPack(packedData)
+               if err != nil {
+                       testCtxt.testError(t, "UnPack() Failed: %s [%s]", err.Error(), buffer)
+                       return
+               }
+               err, _ = e2SubResp.Get()
+               if err != nil {
+                       testCtxt.testError(t, "Get() Failed: %s [%s]", err.Error(), buffer)
+                       return
+               }
+               testCtxt.testPrint("OK [%s]", buffer)
+       }
+
+       testCtxt.SetDesc("SubDelReqBuffer")
+
+       testfunc("00ca4012000002ea7e000500000106e7ea6300020001")
+       testfunc("00ca4012000002ea7e000500000106e8ea6300020001")
+       testfunc("00ca4012000002ea7e000500000106e9ea6300020001")
+       testfunc("00ca4012000002ea7e000500000106eaea6300020001")
+       testfunc("00ca4012000002ea7e000500000106ebea6300020001")
+       testfunc("00ca4012000002ea7e000500000106ecea6300020001")
+       testfunc("00ca4012000002ea7e000500000106edea6300020001")
+       testfunc("00ca4012000002ea7e000500000106eeea6300020001")
+       testfunc("00ca4012000002ea7e000500000106efea6300020001")
+       testfunc("00ca4012000002ea7e000500000106f0ea6300020001")
+       testfunc("00ca4012000002ea7e000500000106f4ea6300020001")
+       testfunc("00ca4012000002ea7e000500000106f5ea6300020001")
+       testfunc("00ca4012000002ea7e000500000106f6ea6300020001")
+}
+
+func (testCtxt *E2ApTests) E2ApTestMsgSubscriptionDeleteResponseBuffers(t *testing.T) {
+
+       testfunc := func(buffer string) {
+               packedData := testCtxt.toPackedData(t, buffer)
+               if packedData == nil {
+                       return
+               }
+               e2SubResp := testCtxt.packerif.NewPackerSubscriptionDeleteResponse()
+               err := e2SubResp.UnPack(packedData)
+               if err != nil {
+                       testCtxt.testError(t, "UnPack() Failed: %s [%s]", err.Error(), buffer)
+                       return
+               }
+               err, _ = e2SubResp.Get()
+               if err != nil {
+                       testCtxt.testError(t, "Get() Failed: %s [%s]", err.Error(), buffer)
+                       return
+               }
+               testCtxt.testPrint("OK [%s]", buffer)
+       }
+
+       testCtxt.SetDesc("SubDelRespBuffer")
+       testfunc("20ca4012000002ea7e000500000106e7ea6300020001")
+       testfunc("20ca4012000002ea7e000500000106e8ea6300020001")
+       testfunc("20ca4012000002ea7e000500000106e9ea6300020001")
+       testfunc("20ca4012000002ea7e000500000106eaea6300020001")
+       testfunc("20ca4012000002ea7e000500000106ebea6300020001")
+       testfunc("20ca4012000002ea7e000500000106ecea6300020001")
+       testfunc("20ca4012000002ea7e000500000106edea6300020001")
+       testfunc("20ca4012000002ea7e000500000106eeea6300020001")
+       testfunc("20ca4012000002ea7e000500000106efea6300020001")
+       testfunc("20ca4012000002ea7e000500000106f0ea6300020001")
+       testfunc("20ca4012000002ea7e000500000106f1ea6300020001")
+       testfunc("20ca4012000002ea7e000500000106f4ea6300020001")
+
+}
+
+func (testCtxt *E2ApTests) E2ApTestMsgSubscriptionDeleteFailureBuffers(t *testing.T) {
+
+       testfunc := func(buffer string) {
+               packedData := testCtxt.toPackedData(t, buffer)
+               if packedData == nil {
+                       return
+               }
+               e2SubResp := testCtxt.packerif.NewPackerSubscriptionDeleteFailure()
+               err := e2SubResp.UnPack(packedData)
+               if err != nil {
+                       testCtxt.testError(t, "UnPack() Failed: %s [%s]", err.Error(), buffer)
+                       return
+               }
+               err, _ = e2SubResp.Get()
+               if err != nil {
+                       testCtxt.testError(t, "Get() Failed: %s [%s]", err.Error(), buffer)
+                       return
+               }
+               testCtxt.testPrint("OK [%s]", buffer)
+       }
+
+       testCtxt.SetDesc("SubDelFailBuffer")
+       testfunc("40ca4017000003ea7e000500000106f6ea6300020001ea74000124")
+}