I'm just starting out with Cmocka, I've been stuck on this issue for a while now. I have a cmocka project that I'm trying to build. I'm seeing the error when I try to use 'make'.
[ ERROR ] --- No entries for symbol __wrap_i2c_read.
Also I'm seeing an error in the mock_i2c.c file at the line where I call mock()
Could not get value to mock function __wrap_i2c_read.
Right now I'm just trying to mock a true/false value to get it working. So my mock looks like
bool __wrap_i2c_read(void)
{
return (mock());
}
I checked that in my test I'm calling will_return(__wrap_i2c_read, true);
In my Makefile I have LDFLAGS += -Wl,--wrap=i2c_read
I have cmocka.h
included in the mock_i2c.c file.
This doesn't seem to be a problem specifically for this mock function because if I don't use it, I get the same error for other mock functions in that file. I'm not sure what other info is needed, please let me know. Anyone know what this means/seen this before?
Thanks.
Edit: So I think I've figured out why I'm getting this error. I have a for
loop in the function I'm testing. The mocked functions are called from this function. Once I remove the loop, the error goes away. Might this have something to do with how/when the will_return
queues the mock values? And the for
loop is getting in the way?
Edit2: Ok, so it seems I was just not queuing enough mock values.