Closed rickymohk closed 1 month ago
That bad memory access
I would say is because your value pointer is initialized based on your example you probably use that value2
(or 1) in your original function afterwards. That is why you get a bad memory access. I suggest you look at ReturnThruPtr
option of CMock to fill in those pointers.
You can run your TestFile.elf
with gdb
to see where exactly the bad memory access happens and why. It could also be stack corruption.
gdb gives Segmentation fault
at a usage afterwards
float x = (((float)(6 * (*y) * value1)/(float)value2/(float)4095));
where y
is a local variable defined a few lines before
uint16_t* y = (uint16_t*) 0x1FFF75AA;
So turns out the y
is the culprit as it is referencing a hardcoded memory address for the MCU.
Thank you for the debugging advice.
I have a function to test which calls a function from another module twice
So I write a test for this function
But it produces the following error:
When I only have one
readAdc_ExpectAnyArgsAndReturn(ADC_OK);
, it correctly executes and saysIt also has no issue if the second call returns another value other than
ADC_OK
. I also tried oneIgnoreAndReturn
instead of twoExpectAnyArgsAndReturn
call but it also produces the same issue.