]> git.proxmox.com Git - mirror_frr.git/blob - pceplib/test/pcep_timers_tests.c
Merge pull request #6317 from rgirada/fix_route_dump
[mirror_frr.git] / pceplib / test / pcep_timers_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_timers_test.h"
33 #include "pcep_timers_event_loop_test.h"
34
35
36 int main(int argc, char **argv)
37 {
38 /* Unused parameters cause compilation warnings */
39 (void)argc;
40 (void)argv;
41
42 CU_initialize_registry();
43
44 /*
45 * Tests defined in pcep_timers_test.c
46 */
47 CU_pSuite test_timers_suite = CU_add_suite_with_setup_and_teardown(
48 "PCEP Timers Test Suite", NULL,
49 NULL, // suite setup and cleanup function pointers
50 NULL, pcep_timers_test_teardown); // test case setup and
51 // teardown function pointers
52 CU_add_test(test_timers_suite, "test_double_initialization",
53 test_double_initialization);
54 CU_add_test(test_timers_suite, "test_initialization_null_callback",
55 test_initialization_null_callback);
56 CU_add_test(test_timers_suite, "test_not_initialized",
57 test_not_initialized);
58 CU_add_test(test_timers_suite, "test_create_timer", test_create_timer);
59 CU_add_test(test_timers_suite, "test_cancel_timer", test_cancel_timer);
60 CU_add_test(test_timers_suite, "test_cancel_timer_invalid",
61 test_cancel_timer_invalid);
62 CU_add_test(test_timers_suite, "test_reset_timer", test_reset_timer);
63 CU_add_test(test_timers_suite, "test_reset_timer_invalid",
64 test_reset_timer_invalid);
65
66 /*
67 * Tests defined in pcep_timers_event_loop_test.c
68 */
69 CU_pSuite test_timers_event_loop_suite =
70 CU_add_suite_with_setup_and_teardown(
71 "PCEP Timers Event Loop Test Suite", NULL,
72 NULL, // suite setup and cleanup function pointers
73 pcep_timers_event_loop_test_setup, // test case setup
74 // function pointer
75 pcep_timers_event_loop_test_teardown); // test case
76 // teardown
77 // function
78 // pointer
79 CU_add_test(test_timers_event_loop_suite,
80 "test_walk_and_process_timers_no_timers",
81 test_walk_and_process_timers_no_timers);
82 CU_add_test(test_timers_event_loop_suite,
83 "test_walk_and_process_timers_timer_not_expired",
84 test_walk_and_process_timers_timer_not_expired);
85 CU_add_test(test_timers_event_loop_suite,
86 "test_walk_and_process_timers_timer_expired",
87 test_walk_and_process_timers_timer_expired);
88 CU_add_test(test_timers_event_loop_suite, "test_event_loop_null_handle",
89 test_event_loop_null_handle);
90 CU_add_test(test_timers_event_loop_suite, "test_event_loop_not_active",
91 test_event_loop_not_active);
92
93 /*
94 * Run the tests and cleanup.
95 */
96 CU_basic_set_mode(CU_BRM_VERBOSE);
97 CU_basic_run_tests();
98 CU_FailureRecord *failure_record = CU_get_failure_list();
99 if (failure_record != NULL) {
100 printf("\nFailed tests:\n\t [Suite] [Test] [File:line-number]\n");
101 do {
102 printf("\t [%s] [%s] [%s:%d]\n",
103 failure_record->pSuite->pName,
104 failure_record->pTest->pName,
105 failure_record->strFileName,
106 failure_record->uiLineNumber);
107 failure_record = failure_record->pNext;
108
109 } while (failure_record != NULL);
110 }
111
112 CU_pRunSummary run_summary = CU_get_run_summary();
113 int result = run_summary->nTestsFailed;
114 CU_cleanup_registry();
115
116 return result;
117 }