2 * This file is part of the PCEPlib, a PCEP protocol library.
4 * Copyright (C) 2020 Volta Networks https://voltanet.io/
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 * Author : Brady Johnson <brady@voltanet.io>
28 #include <CUnit/Basic.h>
29 #include <CUnit/CUnit.h>
30 #include <CUnit/TestDB.h>
32 #include "pcep_socket_comm_loop_test.h"
33 #include "pcep_socket_comm_test.h"
36 int main(int argc
, char **argv
)
38 /* Unused parameters cause compilation warnings */
42 CU_initialize_registry();
45 * Tests defined in pcep_socket_comm_test.c
47 CU_pSuite test_socket_comm_suite
= CU_add_suite_with_setup_and_teardown(
48 "PCEP Socket Comm Test Suite", NULL
,
49 NULL
, // suite setup and cleanup function pointers
50 pcep_socket_comm_test_setup
, // test case setup function pointer
51 pcep_socket_comm_test_teardown
); // test case teardown function
54 CU_add_test(test_socket_comm_suite
, "test_pcep_socket_comm_initialize",
55 test_pcep_socket_comm_initialize
);
56 CU_add_test(test_socket_comm_suite
,
57 "test_pcep_socket_comm_initialize_ipv6",
58 test_pcep_socket_comm_initialize_ipv6
);
59 CU_add_test(test_socket_comm_suite
,
60 "test_pcep_socket_comm_initialize_with_src",
61 test_pcep_socket_comm_initialize_with_src
);
62 CU_add_test(test_socket_comm_suite
,
63 "test_pcep_socket_comm_initialize_with_src_ipv6",
64 test_pcep_socket_comm_initialize_with_src_ipv6
);
65 CU_add_test(test_socket_comm_suite
,
66 "test_pcep_socket_comm_initialize_tcpmd5",
67 test_pcep_socket_comm_initialize_tcpmd5
);
68 CU_add_test(test_socket_comm_suite
,
69 "test_pcep_socket_comm_initialize_ipv6_tcpmd5",
70 test_pcep_socket_comm_initialize_ipv6_tcpmd5
);
71 CU_add_test(test_socket_comm_suite
,
72 "test_pcep_socket_comm_initialize_handlers",
73 test_pcep_socket_comm_initialize_handlers
);
74 CU_add_test(test_socket_comm_suite
,
75 "test_pcep_socket_comm_session_not_initialized",
76 test_pcep_socket_comm_session_not_initialized
);
77 CU_add_test(test_socket_comm_suite
,
78 "test_pcep_socket_comm_session_destroy",
79 test_pcep_socket_comm_session_destroy
);
82 * Tests defined in pcep_socket_comm_loop_test.c
84 CU_pSuite test_socket_comm_loop_suite
=
85 CU_add_suite_with_setup_and_teardown(
86 "PCEP Socket Comm Loop Test Suite", NULL
, NULL
,
87 pcep_socket_comm_loop_test_setup
, // suite setup
89 pcep_socket_comm_loop_test_teardown
); // suite cleanup
93 CU_add_test(test_socket_comm_loop_suite
,
94 "test_socket_comm_loop_null_handle",
95 test_socket_comm_loop_null_handle
);
96 CU_add_test(test_socket_comm_loop_suite
,
97 "test_socket_comm_loop_not_active",
98 test_socket_comm_loop_not_active
);
99 CU_add_test(test_socket_comm_loop_suite
, "test_handle_reads_no_read",
100 test_handle_reads_no_read
);
101 CU_add_test(test_socket_comm_loop_suite
,
102 "test_handle_reads_read_message",
103 test_handle_reads_read_message
);
104 CU_add_test(test_socket_comm_loop_suite
,
105 "test_handle_reads_read_message_close",
106 test_handle_reads_read_message_close
);
109 * Run the tests and cleanup.
111 CU_basic_set_mode(CU_BRM_VERBOSE
);
112 CU_basic_run_tests();
113 CU_FailureRecord
*failure_record
= CU_get_failure_list();
114 if (failure_record
!= NULL
) {
115 printf("\nFailed tests:\n\t [Suite] [Test] [File:line-number]\n");
117 printf("\t [%s] [%s] [%s:%d]\n",
118 failure_record
->pSuite
->pName
,
119 failure_record
->pTest
->pName
,
120 failure_record
->strFileName
,
121 failure_record
->uiLineNumber
);
122 failure_record
= failure_record
->pNext
;
124 } while (failure_record
!= NULL
);
127 CU_pRunSummary run_summary
= CU_get_run_summary();
128 int result
= run_summary
->nTestsFailed
;
129 CU_cleanup_registry();