Closed yusufso closed 2 months ago
Tests are run on simulator, target or on PC?
Very likely, it's something AFTER this mock gets called in your function under test which is causing the problem. Without an Ignore/Expect call, this test aborts as soon as it reaches this function. WITH an Ignore/Expect call, it can proceed from there.
"No final test results" is almost always a memory issue... so a pointer which isn't initialized or is pointing at something that has been freed... referencing a register by address, when you're not on a simulator, etc. etc.
You were correct. There was a pointer later on in the function that was causing it. Thanks for your help. You replied quick.
Note: this is an STM32 microcontroller project.
I am writing a unit test for a function inside of a file called flapjuice.c. The function in question calls several hardware abstraction layer functions. So, I would need to mock these functions. The problem is, there is one mock function (HAL_ADC_DeInit()) where if I don't put it in, Ceedling runs the test but it fails because the function was "Called more times than expected" but if I do put it in, "No tests executed" due to "bad memory access". HAL_ADC_Init() and HAL_ADC_DeInit() are near-identical but the mocks with only the former are successful.
I am using the latest Ceedling docker container too.
Here is the test file. `
ifdef TEST
include "unity.h"
include "flapjuice.h"
include "mock_main.h"
include "mock_stm32wlxx_hal_adc.h"
include "mock_stm32wlxx_hal_adc_ex.h"
void setUp(void) { }
void tearDown(void) { }
void test_flapjuice_Dummy(void) { TEST_ASSERT_EQUAL(1, 1); }
void test_flapjuice_GetValue(void) { // Mocks for setting up and cleaning up. HAL_ADC_Init_IgnoreAndReturn(0); // !!! This is the mock function in question. !!! HAL_ADC_DeInit_IgnoreAndReturn(0); HAL_ADC_ConfigChannel_IgnoreAndReturn(0); HAL_ADCEx_Calibration_Start_IgnoreAndReturn(0);
}
endif // TEST
`
Here is the Ceedling output when I do put the mock function in ` Linking test_flapjuice.out... Running test_flapjuice.out...
ERROR: Test executable "test_flapjuice.out" failed.
rake aborted!
/usr/local/bundle/gems/ceedling-0.31.1/lib/ceedling/generator_helper.rb:36:in'
Tasks: TOP => build/test/results/test_flapjuice.pass
(See full trace by running task with --trace)
test_results_error_handler' /usr/local/bundle/gems/ceedling-0.31.1/lib/ceedling/generator.rb:173:in
generate_test_results' /usr/local/bundle/gems/ceedling-0.31.1/lib/ceedling/rules_tests.rake:55:inblock in <top (required)>' /usr/local/bundle/gems/ceedling-0.31.1/lib/ceedling/task_invoker.rb:107:in
invoke_test_results' /usr/local/bundle/gems/ceedling-0.31.1/lib/ceedling/test_invoker.rb:125:inblock in setup_and_invoke' /usr/local/bundle/gems/ceedling-0.31.1/lib/ceedling/test_invoker.rb:51:in
setup_and_invoke' /usr/local/bundle/gems/ceedling-0.31.1/lib/ceedling/tasks_tests.rake:13:inblock (2 levels) in <top (required)>' /usr/local/bundle/gems/ceedling-0.31.1/bin/ceedling:345:in
block in <top (required)>' /usr/local/bundle/gems/ceedling-0.31.1/bin/ceedling:332:in<top (required)>' /usr/local/bundle/bin/ceedling:23:in
load' /usr/local/bundle/bin/ceedling:23:in `OVERALL TEST SUMMARY
No tests executed. `