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_timers_test.h"
33 #include "pcep_timers_event_loop_test.h"
36 int main(int argc
, char **argv
)
38 /* Unused parameters cause compilation warnings */
42 CU_initialize_registry();
45 * Tests defined in pcep_timers_test.c
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
);
67 * Tests defined in pcep_timers_event_loop_test.c
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
75 pcep_timers_event_loop_test_teardown
); // test case
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
);
94 * Run the tests and cleanup.
96 CU_basic_set_mode(CU_BRM_VERBOSE
);
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");
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
;
109 } while (failure_record
!= NULL
);
112 CU_pRunSummary run_summary
= CU_get_run_summary();
113 int result
= run_summary
->nTestsFailed
;
114 CU_cleanup_registry();