]> git.proxmox.com Git - mirror_frr.git/blob - pceplib/test/pcep_pcc_api_tests.c
doc: Add `show ipv6 rpf X:X::X:X` command to docs
[mirror_frr.git] / pceplib / test / pcep_pcc_api_tests.c
1 /*
2 * This file is part of the PCEPlib, a PCEP protocol library.
3 *
4 * Copyright (C) 2020 Volta Networks https://voltanet.io/
5 *
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.
10 *
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.
15 *
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/>.
18 *
19 * Author : Brady Johnson <brady@voltanet.io>
20 *
21 */
22
23
24 #ifdef HAVE_CONFIG_H
25 #include "config.h"
26 #endif
27
28 #include <CUnit/Basic.h>
29 #include <CUnit/CUnit.h>
30 #include <CUnit/TestDB.h>
31
32 #include "pcep_pcc_api_test.h"
33
34 int main(int argc, char **argv)
35 {
36 /* Unused parameters cause compilation warnings */
37 (void)argc;
38 (void)argv;
39
40 CU_initialize_registry();
41
42 /*
43 * Tests defined in pcep_socket_comm_test.c
44 */
45 CU_pSuite test_pcc_api_suite = CU_add_suite_with_setup_and_teardown(
46 "PCEP PCC API Test Suite",
47 pcep_pcc_api_test_suite_setup, // suite setup and cleanup
48 // function pointers
49 pcep_pcc_api_test_suite_teardown,
50 pcep_pcc_api_test_setup, // test case setup function pointer
51 pcep_pcc_api_test_teardown); // test case teardown function
52 // pointer
53
54 CU_add_test(test_pcc_api_suite, "test_initialize_pcc",
55 test_initialize_pcc);
56 CU_add_test(test_pcc_api_suite, "test_connect_pce", test_connect_pce);
57 CU_add_test(test_pcc_api_suite, "test_connect_pce_ipv6",
58 test_connect_pce_ipv6);
59 CU_add_test(test_pcc_api_suite, "test_connect_pce_with_src_ip",
60 test_connect_pce_with_src_ip);
61 CU_add_test(test_pcc_api_suite, "test_disconnect_pce",
62 test_disconnect_pce);
63 CU_add_test(test_pcc_api_suite, "test_send_message", test_send_message);
64 CU_add_test(test_pcc_api_suite, "test_event_queue", test_event_queue);
65 CU_add_test(test_pcc_api_suite, "test_get_event_type_str",
66 test_get_event_type_str);
67
68 /*
69 * Run the tests and cleanup.
70 */
71 CU_basic_set_mode(CU_BRM_VERBOSE);
72 CU_basic_run_tests();
73 CU_FailureRecord *failure_record = CU_get_failure_list();
74 if (failure_record != NULL) {
75 printf("\nFailed tests:\n\t [Suite] [Test] [File:line-number]\n");
76 do {
77 printf("\t [%s] [%s] [%s:%d]\n",
78 failure_record->pSuite->pName,
79 failure_record->pTest->pName,
80 failure_record->strFileName,
81 failure_record->uiLineNumber);
82 failure_record = failure_record->pNext;
83
84 } while (failure_record != NULL);
85 }
86
87 CU_pRunSummary run_summary = CU_get_run_summary();
88 int result = run_summary->nTestsFailed;
89 CU_cleanup_registry();
90
91 return result;
92 }