Skip to content

Commit

Permalink
Tests: Added test for recursive function
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick Pedersen <[email protected]>
  • Loading branch information
CTXz committed Jun 24, 2024
1 parent 8db03a6 commit edc4e75
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
13 changes: 13 additions & 0 deletions tests/_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ void unused_function(void) {
}
}

void unused_function_with_fptr(void) {
void (*function_ptr)(void) = &unused_function;
for (int i = 0; i < UNUSED_CONSTANT; i++) {
function_ptr();
}
}

void used_function_sub(void) {
for (int i = 0; i < USED_CONSTANT; i++) {
__asm__("nop");
Expand Down Expand Up @@ -81,6 +88,10 @@ static void local_function(void) {
local_function_sub();
}

void recursive_function(void) {
recursive_function();
}

void _main(void) {
used_function();
local_function();
Expand All @@ -95,4 +106,6 @@ void _main(void) {
for (uint8_t i = 0; i < external_const_array_ptr[1]; i++) {
external_function_ptr();
}

recursive_function();
}
13 changes: 11 additions & 2 deletions tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,13 @@ def create_all_functions(output_dir):
)
+ create_asmsyms(
[
"unused_function",
"_main",
"used_function_sub",
"used_function",
"unused_function",
"unused_function_with_fptr",
"function_used_by_ptr_sub",
"recursive_function",
"function_used_by_ptr",
"excluded_function_sub",
"excluded_function",
Expand All @@ -83,7 +86,6 @@ def create_all_functions(output_dir):
"function_expected_by_module",
"function_expected_by_module_sub",
"local_function",
"_main",
],
"_main.c",
output_dir,
Expand Down Expand Up @@ -324,6 +326,7 @@ def test_general_optimization(self):
"local_function",
"function_used_by_ptr",
"function_used_by_ptr_sub",
"recursive_function",
],
"_main.c",
self.dce_output_dir,
Expand Down Expand Up @@ -423,6 +426,7 @@ def test_irq_optimization(self):
"local_function",
"function_used_by_ptr",
"function_used_by_ptr_sub",
"recursive_function",
],
"_main.c",
self.dce_output_dir,
Expand Down Expand Up @@ -523,6 +527,7 @@ def test_exclusion(self):
"local_function",
"function_used_by_ptr",
"function_used_by_ptr_sub",
"recursive_function",
"excluded_function",
"excluded_function_sub",
"local_excluded_function",
Expand Down Expand Up @@ -665,6 +670,7 @@ def test_alternative_entry_point(self):
"local_function",
"function_used_by_ptr",
"function_used_by_ptr_sub",
"recursive_function",
],
"_main.c",
self.dce_output_dir,
Expand Down Expand Up @@ -755,6 +761,7 @@ def test_rel(self):
"local_function",
"function_used_by_ptr",
"function_used_by_ptr_sub",
"recursive_function",
"function_expected_by_module",
"function_expected_by_module_sub",
],
Expand Down Expand Up @@ -879,6 +886,7 @@ def test_lib(self):
"local_function",
"function_used_by_ptr",
"function_used_by_ptr_sub",
"recursive_function",
"function_expected_by_module",
"function_expected_by_module_sub",
],
Expand Down Expand Up @@ -990,6 +998,7 @@ def test_custom_codeconstseg(self):
"local_function",
"function_used_by_ptr",
"function_used_by_ptr_sub",
"recursive_function",
],
"_main.c",
self.dce_output_dir,
Expand Down

0 comments on commit edc4e75

Please sign in to comment.