[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: chef_wrap run issue, VS2010


Hello Daniel

Where is the test case that is calling chef_cook?

Looks kind of dangerous what you are doing. I would expect when passing a pointer to a pointer it is to modify the pointer that is pointed to. To modify what is being pointed at you would only need to pass the pointer. Passing the length too would be a good idea for safety.

If you wrote a test case and them minimized your example, and grew it slowly, you might better understand what is happening

James

--------------------------------------------------------------------------
James Grenning - Author of TDD for Embedded C - wingman-sw.com/tddec
wingman-sw.com
wingman-sw.com/blog
twitter.com/jwgrenning
facebook.com/wingman.sw
[![wingman software](http://www.wingman-sw.com/images/wingman.png)](http://wingman-sw.com)
On 23 Feb 2016, at 16:42, Daniel Miller wrote:

I think I see what's going on... the string "allocation" is supposed to be accomplished by strdup(), in __wrap_chef_cook() ... However, that function is not getting invoked. All the calls to chef_cook() are actually going to chef_cook(). When I build the project, I get the following warning from VS2010; I suspect this is MS's way of saying "whatever you are trying to
do, it isn't going to work..."

LINK : warning LNK4044: unrecognized option '/Wl,--wrap=chef_cook'; ignored
[C:\Users\dmiller\Downloads\cmocka-master\example\che
f_wrap\waiter_test_wrap.vcxproj]

On Tue, Feb 23, 2016 at 1:40 PM, Daniel Miller <dmiller@xxxxxxxxxxxxxxxx>
wrote:

I'm new to cmocka, and am trying to run the chef_wrap example.
We use Visual Studio 2010 here.
I used CMake to prepare the project, then (after several difficulties) got
it to build, however I cannot get it to run successfully.

The core issue appears to be that dish_out in chef_cook() is not valid; I
modified it as such:

int chef_cook(const char *order, char **dish_out)
{
 puts("in chef_cook");
 if (order == NULL || dish_out == NULL) return EINVAL;
 printf("order=%s\n", order);
 if (strcmp(order, "hotdog") == 0)
 {
   printf("dish=%08X, pdish=%08X\n", (unsigned) dish_out, (unsigned)
*dish_out) ;
   sprintf(*dish_out, "hotdog");
   return 0 ;
 }
 return -ENOSYS; //  -40
}

and when I run, I see:
[==========] Running 2 test(s).
[ RUN      ] test_order_hotdog
in chef_cook
order=hotdog
dish=003FF964, pdish=CCCCCCCC
EXCEPTION_ACCESS_VIOLATION occurred at 72BA29FE.

Where is dish_out supposed to get created? And why isn't that working? It appears to be getting allocated somewhere in cmocka.c, but haven't yet quite figured it out... and to be honest, I was hoping it would just work,
since it's the core cmocka library module.

Dan Miller




References:
chef_wrap run issue, VS2010Daniel Miller <dmiller@xxxxxxxxxxxxxxxx>
Re: chef_wrap run issue, VS2010Daniel Miller <dmiller@xxxxxxxxxxxxxxxx>