]> git.proxmox.com Git - mirror_frr.git/blobdiff - pceplib/test/pcep_session_logic_loop_test.c
*: auto-convert to SPDX License IDs
[mirror_frr.git] / pceplib / test / pcep_session_logic_loop_test.c
index d68b2005498b0f68143b90f8e08dcdb043ca507f..0f74cff31ec234906680e9660220ac003abf94af 100644 (file)
@@ -1,21 +1,9 @@
+// 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>
  *
  */
@@ -25,6 +13,7 @@
 #include "config.h"
 #endif
 
+#include <assert.h>
 #include <pthread.h>
 #include <stdlib.h>
 #include <string.h>
@@ -139,14 +128,14 @@ void test_session_logic_msg_ready_handler()
        /* Read from an empty file should return 0, thus
         * session_logic_msg_ready_handler returns -1 */
        mode_t oldumask;
-       oldumask = umask(S_IXUSR|S_IXGRP|S_IWOTH|S_IROTH|S_IXOTH);
+       oldumask = umask(S_IXUSR | S_IXGRP | S_IWOTH | S_IROTH | S_IXOTH);
        /* Set umask before anything for security */
        umask(0027);
        char tmpfile[] = "/tmp/pceplib_XXXXXX";
        int fd = mkstemp(tmpfile);
        umask(oldumask);
-       if (fd == -1){
-               CU_ASSERT_TRUE(fd>=0);
+       if (fd == -1) {
+               CU_ASSERT_TRUE(fd >= 0);
                return;
        }
        pcep_session session;
@@ -161,6 +150,7 @@ void test_session_logic_msg_ready_handler()
        pcep_session_event *socket_event = (pcep_session_event *)queue_dequeue(
                session_logic_handle_->session_event_queue);
        CU_ASSERT_PTR_NOT_NULL(socket_event);
+       assert(socket_event != NULL);
        CU_ASSERT_TRUE(socket_event->socket_closed);
        pceplib_free(PCEPLIB_INFRA, socket_event);
 
@@ -179,6 +169,7 @@ void test_session_logic_msg_ready_handler()
        socket_event = (pcep_session_event *)queue_dequeue(
                session_logic_handle_->session_event_queue);
        CU_ASSERT_PTR_NOT_NULL(socket_event);
+       assert(socket_event != NULL);
        CU_ASSERT_FALSE(socket_event->socket_closed);
        CU_ASSERT_PTR_EQUAL(socket_event->session, &session);
        CU_ASSERT_EQUAL(socket_event->expired_timer_id, TIMER_ID_NOT_SET);
@@ -188,6 +179,7 @@ void test_session_logic_msg_ready_handler()
        destroy_pcep_versioning(versioning);
        pceplib_free(PCEPLIB_INFRA, socket_event);
        close(fd);
+       unlink(tmpfile);
 }
 
 
@@ -206,6 +198,7 @@ void test_session_logic_conn_except_notifier()
        pcep_session_event *socket_event = (pcep_session_event *)queue_dequeue(
                session_logic_handle_->session_event_queue);
        CU_ASSERT_PTR_NOT_NULL_FATAL(socket_event);
+       assert(socket_event != NULL);
        CU_ASSERT_TRUE(socket_event->socket_closed);
        CU_ASSERT_PTR_EQUAL(socket_event->session, &session);
        CU_ASSERT_EQUAL(socket_event->expired_timer_id, TIMER_ID_NOT_SET);
@@ -230,6 +223,7 @@ void test_session_logic_timer_expire_handler()
        pcep_session_event *socket_event = (pcep_session_event *)queue_dequeue(
                session_logic_handle_->session_event_queue);
        CU_ASSERT_PTR_NOT_NULL_FATAL(socket_event);
+       assert(socket_event != NULL);
        CU_ASSERT_FALSE(socket_event->socket_closed);
        CU_ASSERT_PTR_EQUAL(socket_event->session, &session);
        CU_ASSERT_EQUAL(socket_event->expired_timer_id, 42);