diff --git a/host/srcs/function_footprint/function_footprint.c b/host/srcs/function_footprint/function_footprint.c index 4859d94..643aeb6 100644 --- a/host/srcs/function_footprint/function_footprint.c +++ b/host/srcs/function_footprint/function_footprint.c @@ -20,6 +20,7 @@ #include #include "../events/event_utils.h" #include "../backtrace/backtrace.h" +#include "../functions_test/functions_test.h" define_btree_functions(t_allocation, cmp_t_allocation); define_btree_functions(t_function_call_footprint, cmp_t_function_call_footprint); @@ -131,9 +132,9 @@ void remove_allocation(btree_t_function_call_footprint **function_tree, void *pt */ static size_t count_tests(t_function_call_footprint *test_elem) { - if (test_elem->should_test) - return 1; - return 0; + if (!test_elem->should_test) + return 0; + return REQUIRED_ITERATIONS(test_elem); } /** diff --git a/host/srcs/functions_test/functions_test.c b/host/srcs/functions_test/functions_test.c index 9231342..88c2680 100644 --- a/host/srcs/functions_test/functions_test.c +++ b/host/srcs/functions_test/functions_test.c @@ -305,7 +305,8 @@ static void function_test_callback(t_function_call_footprint *function_info) { if (!function_info->should_test) return; - _function_test_count++; + int to_increment = REQUIRED_ITERATIONS(function_info); + _function_test_count += to_increment; function_test(function_info, 0); if (function_info->call_count > 1) function_test(function_info, 1); diff --git a/host/srcs/functions_test/functions_test.h b/host/srcs/functions_test/functions_test.h index ed483f2..fa4f728 100644 --- a/host/srcs/functions_test/functions_test.h +++ b/host/srcs/functions_test/functions_test.h @@ -21,6 +21,9 @@ #include "../functions_fetch/functions_fetch.h" #include "../time/time.h" +// 2 iterations are required to test a function that has been called at least twice +#define REQUIRED_ITERATIONS(function_info) (function_info->call_count > 1) ? 2 : 1 + typedef struct { size_t nb_total_tests;