]> git.proxmox.com Git - mirror_frr.git/blobdiff - pceplib/test/pcep_session_logic_test.c
*: auto-convert to SPDX License IDs
[mirror_frr.git] / pceplib / test / pcep_session_logic_test.c
index 66db4fbaea78615311b28c599764a461cb92a26f..c5b2bb3e2675912f14bf6faafa351ea72e72347f 100644 (file)
@@ -1,26 +1,19 @@
+// SPDX-License-Identifier: LGPL-2.1-or-later
 /*
  * This file is part of the PCEPlib, a PCEP protocol library.
  *
  * Copyright (C) 2020 Volta Networks https://voltanet.io/
  *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program.  If not, see <https://www.gnu.org/licenses/>.
- *
  * Author : Brady Johnson <brady@voltanet.io>
  *
  */
 
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <assert.h>
 #include <stdlib.h>
 #include <string.h>
 #include <time.h>
@@ -130,6 +123,7 @@ void test_create_destroy_pcep_session()
        CU_ASSERT_PTR_NOT_NULL(encoded_msg);
        struct pcep_message *open_msg = pcep_decode_message(encoded_msg);
        CU_ASSERT_PTR_NOT_NULL(open_msg);
+       assert(open_msg != NULL);
        /* Should be an Open, with no TLVs: length = 12 */
        CU_ASSERT_EQUAL(open_msg->msg_header->type, PCEP_TYPE_OPEN);
        CU_ASSERT_EQUAL(open_msg->encoded_message_length, 12);
@@ -162,6 +156,7 @@ void test_create_destroy_pcep_session_ipv6()
        mock_info->send_message_save_message = true;
        session = create_pcep_session_ipv6(&config, &pce_ip);
        CU_ASSERT_PTR_NOT_NULL(session);
+       assert(session != NULL);
        CU_ASSERT_TRUE(session->socket_comm_session->is_ipv6);
        /* What gets saved in the mock is the msg byte buffer. The msg struct
         * was deleted when it was sent. Instead of inspecting the msg byte
@@ -171,6 +166,7 @@ void test_create_destroy_pcep_session_ipv6()
        CU_ASSERT_PTR_NOT_NULL(encoded_msg);
        struct pcep_message *open_msg = pcep_decode_message(encoded_msg);
        CU_ASSERT_PTR_NOT_NULL(open_msg);
+       assert(open_msg != NULL);
        /* Should be an Open, with no TLVs: length = 12 */
        CU_ASSERT_EQUAL(open_msg->msg_header->type, PCEP_TYPE_OPEN);
        CU_ASSERT_EQUAL(open_msg->encoded_message_length, 12);
@@ -211,14 +207,17 @@ void test_create_pcep_session_open_tlvs()
        CU_ASSERT_PTR_NOT_NULL(encoded_msg);
        open_msg = pcep_decode_message(encoded_msg);
        CU_ASSERT_PTR_NOT_NULL(open_msg);
+       assert(open_msg != NULL);
        /* Get and verify the Open Message objects */
        CU_ASSERT_PTR_NOT_NULL(open_msg->obj_list);
+       assert(open_msg->obj_list != NULL);
        CU_ASSERT_TRUE(open_msg->obj_list->num_entries > 0);
        /* Get and verify the Open object */
        open_obj = pcep_obj_get(open_msg->obj_list, PCEP_OBJ_CLASS_OPEN);
        CU_ASSERT_PTR_NOT_NULL(open_obj);
        /* Get and verify the Open object TLVs */
        CU_ASSERT_PTR_NOT_NULL(open_obj->tlv_list);
+       assert(open_obj->tlv_list != NULL);
        CU_ASSERT_EQUAL(open_obj->tlv_list->num_entries, 1);
        CU_ASSERT_EQUAL(((struct pcep_object_tlv_header *)
                                 open_obj->tlv_list->head->data)
@@ -246,12 +245,14 @@ void test_create_pcep_session_open_tlvs()
        CU_ASSERT_PTR_NOT_NULL(open_msg);
        /* Get and verify the Open Message objects */
        CU_ASSERT_PTR_NOT_NULL(open_msg->obj_list);
+       assert(open_msg != NULL);
        CU_ASSERT_TRUE(open_msg->obj_list->num_entries > 0);
        /* Get and verify the Open object */
        open_obj = pcep_obj_get(open_msg->obj_list, PCEP_OBJ_CLASS_OPEN);
        CU_ASSERT_PTR_NOT_NULL(open_obj);
        /* Get and verify the Open object TLVs */
        CU_ASSERT_PTR_NOT_NULL(open_obj->tlv_list);
+       assert(open_obj->tlv_list != NULL);
        CU_ASSERT_EQUAL(open_obj->tlv_list->num_entries, 2);
        CU_ASSERT_EQUAL(((struct pcep_object_tlv_header *)
                                 open_obj->tlv_list->head->data)
@@ -283,14 +284,17 @@ void test_create_pcep_session_open_tlvs()
        CU_ASSERT_PTR_NOT_NULL(encoded_msg);
        open_msg = pcep_decode_message(encoded_msg);
        CU_ASSERT_PTR_NOT_NULL(open_msg);
+       assert(open_msg != NULL);
        /* Get and verify the Open Message objects */
        CU_ASSERT_PTR_NOT_NULL(open_msg->obj_list);
+       assert(open_msg->obj_list != NULL);
        CU_ASSERT_TRUE(open_msg->obj_list->num_entries > 0);
        /* Get and verify the Open object */
        open_obj = pcep_obj_get(open_msg->obj_list, PCEP_OBJ_CLASS_OPEN);
        CU_ASSERT_PTR_NOT_NULL(open_obj);
        /* Get and verify the Open object TLVs */
        CU_ASSERT_PTR_NOT_NULL(open_obj->tlv_list);
+       assert(open_obj->tlv_list != NULL);
        CU_ASSERT_EQUAL(open_obj->tlv_list->num_entries, 3);
        double_linked_list_node *tlv_node = open_obj->tlv_list->head;
        CU_ASSERT_EQUAL(((struct pcep_object_tlv_header *)tlv_node->data)->type,
@@ -320,16 +324,21 @@ void test_create_pcep_session_open_tlvs()
        /* Get and verify the Open Message */
        encoded_msg = dll_delete_first_node(mock_info->sent_message_list);
        CU_ASSERT_PTR_NOT_NULL(encoded_msg);
+       assert(encoded_msg != NULL);
        open_msg = pcep_decode_message(encoded_msg);
        CU_ASSERT_PTR_NOT_NULL(open_msg);
+       assert(open_msg != NULL);
        /* Get and verify the Open Message objects */
        CU_ASSERT_PTR_NOT_NULL(open_msg->obj_list);
+       assert(open_msg->obj_list != NULL);
        CU_ASSERT_TRUE(open_msg->obj_list->num_entries > 0);
        /* Get and verify the Open object */
        open_obj = pcep_obj_get(open_msg->obj_list, PCEP_OBJ_CLASS_OPEN);
        CU_ASSERT_PTR_NOT_NULL(open_obj);
+       assert(open_obj != NULL);
        /* Get and verify the Open object TLVs */
        CU_ASSERT_PTR_NOT_NULL(open_obj->tlv_list);
+       assert(open_obj->tlv_list != NULL);
        CU_ASSERT_EQUAL(open_obj->tlv_list->num_entries, 4);
        tlv_node = open_obj->tlv_list->head;
        CU_ASSERT_EQUAL(((struct pcep_object_tlv_header *)tlv_node->data)->type,