2 * Copyright (c) 2019 AT&T Intellectual Property.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 * This source code is part of the near-RT RIC (RAN Intelligent Controller)
19 * platform project (RICP).
31 func TestKnownCausesToX2ResetPDU(t *testing.T) {
32 _, err := logger.InitLogger(logger.InfoLevel)
34 t.Errorf("failed to initialize logger, error: %s", err)
36 var testCases = []struct {
41 cause: OmInterventionCause,
42 packedPdu: "000700080000010005400164",
45 cause: "PROTOCOL:transfer-syntax-error",
46 packedPdu: "000700080000010005400140",
49 cause: "transport:transport-RESOURCE-unavailable",
50 packedPdu: "000700080000010005400120",
54 cause: "radioNetwork:invalid-MME-groupid",
55 packedPdu: "00070009000001000540020680",
59 for _, tc := range testCases {
60 t.Run(tc.packedPdu, func(t *testing.T) {
62 payload, ok := KnownCausesToX2ResetPDU(tc.cause)
64 t.Errorf("want: success, got: not found.\n")
66 tmp := fmt.Sprintf("%x", payload)
67 if len(tmp) != len(tc.packedPdu) {
68 t.Errorf("want packed len:%d, got: %d\n", len(tc.packedPdu)/2, len(payload)/2)
71 if strings.Compare(tmp, tc.packedPdu) != 0 {
72 t.Errorf("\nwant :\t[%s]\n got: \t\t[%s]\n", tc.packedPdu, tmp)
79 func TestKnownCausesToX2ResetPDUFailure(t *testing.T) {
80 _, err := logger.InitLogger(logger.InfoLevel)
82 t.Errorf("failed to initialize logger, error: %s", err)
85 _, ok := KnownCausesToX2ResetPDU("xxxx")
87 t.Errorf("want: not found, got: success.\n")
91 func TestPrepareX2ResetPDUsFailure(t *testing.T) {
92 _, err := logger.InitLogger(logger.InfoLevel)
94 t.Errorf("failed to initialize logger, error: %s", err)
97 err = prepareX2ResetPDUs(1, 4096)
99 t.Errorf("want: error, got: success.\n")
102 expected := "failed to build and pack the reset message #src/asn1codec_utils.c.pack_pdu_aux - Encoded output of E2AP-PDU, is too big:"
103 if !strings.Contains(err.Error(), expected) {
104 t.Errorf("want :[%s], got: [%s]\n", expected, err)