]>
Commit | Line | Data |
---|---|---|
acddc0ed | 1 | // SPDX-License-Identifier: LGPL-2.1-or-later |
74971473 JG |
2 | /* |
3 | * This file is part of the PCEPlib, a PCEP protocol library. | |
4 | * | |
5 | * Copyright (C) 2020 Volta Networks https://voltanet.io/ | |
6 | * | |
74971473 JG |
7 | * Author : Brady Johnson <brady@voltanet.io> |
8 | * | |
9 | */ | |
10 | ||
11 | ||
1f8031f7 DL |
12 | #ifdef HAVE_CONFIG_H |
13 | #include "config.h" | |
14 | #endif | |
15 | ||
74971473 JG |
16 | #include <CUnit/Basic.h> |
17 | #include <CUnit/CUnit.h> | |
18 | #include <CUnit/TestDB.h> | |
19 | ||
20 | #include "pcep_timers_test.h" | |
21 | #include "pcep_timers_event_loop_test.h" | |
22 | ||
23 | ||
24 | int main(int argc, char **argv) | |
25 | { | |
26 | /* Unused parameters cause compilation warnings */ | |
27 | (void)argc; | |
28 | (void)argv; | |
29 | ||
30 | CU_initialize_registry(); | |
31 | ||
32 | /* | |
33 | * Tests defined in pcep_timers_test.c | |
34 | */ | |
35 | CU_pSuite test_timers_suite = CU_add_suite_with_setup_and_teardown( | |
36 | "PCEP Timers Test Suite", NULL, | |
37 | NULL, // suite setup and cleanup function pointers | |
38 | NULL, pcep_timers_test_teardown); // test case setup and | |
39 | // teardown function pointers | |
40 | CU_add_test(test_timers_suite, "test_double_initialization", | |
41 | test_double_initialization); | |
42 | CU_add_test(test_timers_suite, "test_initialization_null_callback", | |
43 | test_initialization_null_callback); | |
44 | CU_add_test(test_timers_suite, "test_not_initialized", | |
45 | test_not_initialized); | |
46 | CU_add_test(test_timers_suite, "test_create_timer", test_create_timer); | |
47 | CU_add_test(test_timers_suite, "test_cancel_timer", test_cancel_timer); | |
48 | CU_add_test(test_timers_suite, "test_cancel_timer_invalid", | |
49 | test_cancel_timer_invalid); | |
50 | CU_add_test(test_timers_suite, "test_reset_timer", test_reset_timer); | |
51 | CU_add_test(test_timers_suite, "test_reset_timer_invalid", | |
52 | test_reset_timer_invalid); | |
53 | ||
54 | /* | |
55 | * Tests defined in pcep_timers_event_loop_test.c | |
56 | */ | |
57 | CU_pSuite test_timers_event_loop_suite = | |
58 | CU_add_suite_with_setup_and_teardown( | |
59 | "PCEP Timers Event Loop Test Suite", NULL, | |
60 | NULL, // suite setup and cleanup function pointers | |
61 | pcep_timers_event_loop_test_setup, // test case setup | |
62 | // function pointer | |
63 | pcep_timers_event_loop_test_teardown); // test case | |
64 | // teardown | |
65 | // function | |
66 | // pointer | |
67 | CU_add_test(test_timers_event_loop_suite, | |
68 | "test_walk_and_process_timers_no_timers", | |
69 | test_walk_and_process_timers_no_timers); | |
70 | CU_add_test(test_timers_event_loop_suite, | |
71 | "test_walk_and_process_timers_timer_not_expired", | |
72 | test_walk_and_process_timers_timer_not_expired); | |
73 | CU_add_test(test_timers_event_loop_suite, | |
74 | "test_walk_and_process_timers_timer_expired", | |
75 | test_walk_and_process_timers_timer_expired); | |
76 | CU_add_test(test_timers_event_loop_suite, "test_event_loop_null_handle", | |
77 | test_event_loop_null_handle); | |
78 | CU_add_test(test_timers_event_loop_suite, "test_event_loop_not_active", | |
79 | test_event_loop_not_active); | |
80 | ||
81 | /* | |
82 | * Run the tests and cleanup. | |
83 | */ | |
84 | CU_basic_set_mode(CU_BRM_VERBOSE); | |
85 | CU_basic_run_tests(); | |
86 | CU_FailureRecord *failure_record = CU_get_failure_list(); | |
87 | if (failure_record != NULL) { | |
88 | printf("\nFailed tests:\n\t [Suite] [Test] [File:line-number]\n"); | |
89 | do { | |
90 | printf("\t [%s] [%s] [%s:%d]\n", | |
91 | failure_record->pSuite->pName, | |
92 | failure_record->pTest->pName, | |
93 | failure_record->strFileName, | |
94 | failure_record->uiLineNumber); | |
95 | failure_record = failure_record->pNext; | |
96 | ||
97 | } while (failure_record != NULL); | |
98 | } | |
99 | ||
100 | CU_pRunSummary run_summary = CU_get_run_summary(); | |
101 | int result = run_summary->nTestsFailed; | |
102 | CU_cleanup_registry(); | |
103 | ||
104 | return result; | |
105 | } |