1 /*******************************************************************************
3 * Copyright (c) 2019 AT&T Intellectual Property.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 *******************************************************************************/
27 func TestKnownCausesToX2ResetPDU(t *testing.T) {
28 _, err := logger.InitLogger(logger.InfoLevel)
30 t.Errorf("failed to initialize logger, error: %s", err)
32 var testCases = []struct {
37 cause: OmInterventionCause,
38 packedPdu: "000700080000010005400164",
41 cause: "PROTOCOL:transfer-syntax-error",
42 packedPdu: "000700080000010005400140",
45 cause: "transport:transport-RESOURCE-unavailable",
46 packedPdu: "000700080000010005400120",
50 cause: "radioNetwork:invalid-MME-groupid",
51 packedPdu: "00070009000001000540020680",
55 for _, tc := range testCases {
56 t.Run(tc.packedPdu, func(t *testing.T) {
58 payload, ok := KnownCausesToX2ResetPDU(tc.cause)
60 t.Errorf("want: success, got: not found.\n")
62 tmp := fmt.Sprintf("%x", payload)
63 if len(tmp) != len(tc.packedPdu) {
64 t.Errorf("want packed len:%d, got: %d\n", len(tc.packedPdu)/2, len(payload)/2)
67 if strings.Compare(tmp, tc.packedPdu) != 0 {
68 t.Errorf("\nwant :\t[%s]\n got: \t\t[%s]\n", tc.packedPdu, tmp)
75 func TestKnownCausesToX2ResetPDUFailure(t *testing.T) {
76 _, err := logger.InitLogger(logger.InfoLevel)
78 t.Errorf("failed to initialize logger, error: %s", err)
81 _, ok := KnownCausesToX2ResetPDU("xxxx")
83 t.Errorf("want: not found, got: success.\n")
87 func TestPrepareX2ResetPDUsFailure(t *testing.T) {
88 _, err := logger.InitLogger(logger.InfoLevel)
90 t.Errorf("failed to initialize logger, error: %s", err)
93 err = prepareX2ResetPDUs(1, 4096)
95 t.Errorf("want: error, got: success.\n")
98 expected := "#x2_reset_known_causes_test.TestPrepareX2ResetPDUsFailure - failed to build and pack the reset message #src/asn1codec_utils.c.pack_pdu_aux - Encoded output of E2AP-PDU, is too big:"
99 if !strings.Contains(err.Error(), expected) {
100 t.Errorf("want :[%s], got: [%s]\n", expected, err)