ThrowTheSwitch / CMock

CMock - Mock/stub generator for C
http://throwtheswitch.org
MIT License
672 stars 273 forks source link

strippables __syscall to mock system function #405

Closed ggau35 closed 1 year ago

ggau35 commented 2 years ago

I want to delete __syscall inside header file before cmock compute it. I try this inside configuration file :

    :strippables: 
        - '(?:__syscall)'

but it didn't work.

I need to delete __syscall because cmock doesn't mock function with definition started with it.

mvandervoord commented 2 years ago

Did you try this more basic option:

:strippables:
  - __syscall
ggau35 commented 2 years ago

Yes, I tried it and unfortunately without success

mvandervoord commented 2 years ago

Interesting. I just ran a test here and it seems to be working on my version... but maybe I have something else different going on?

Just to verify (and I apologize if this is like asking you to "turn it off and back on"), you have this in a :cmock: section, right?

:cmock:
    :strippables:
        - __syscall

Are you calling CMock from Ceedling or something else? It's getting passed the config file properly?

ggau35 commented 2 years ago

No problem, thanks for your help.

Yes, it is inside a :cmock: section, and I am sur that configuration file is use because I try lot of thing and many time it ended in cmock error. I use cmock inside cmake (with a cmock_handle)

Letme commented 2 years ago

My gut feeling would also say:

:cmock:
    :strippables:
        - '__syscall'

What do you have in a header file?

ggau35 commented 2 years ago

I try this too, without success. It is the device.h header of zephyr OS

ggau35 commented 2 years ago

For information, in this file , cmock manage to deal with __syscall (adc_read function are well mocked).

Letme commented 2 years ago

This is just purely what strippables would do, so there is something else in that header file which makes it fail. My version with quotes for sure removes other things, so I am confident it is correct.

Can you paste the result also of the mock_device.h?

ggau35 commented 2 years ago

Yes, of course :

/* AUTOGENERATED FILE. DO NOT EDIT. */
#ifndef _MOCK_DEVICE_H
#define _MOCK_DEVICE_H

#include "unity.h"
#include "device.h"

/* Ignore the following warnings, since we are copying code */
#if defined(__GNUC__) && !defined(__ICC) && !defined(__TMS470__)
#if __GNUC__ > 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ > 6 || (__GNUC_MINOR__ == 6 && __GNUC_PATCHLEVEL__ > 0)))
#pragma GCC diagnostic push
#endif
#if !defined(__clang__)
#pragma GCC diagnostic ignored "-Wpragmas"
#endif
#pragma GCC diagnostic ignored "-Wunknown-pragmas"
#pragma GCC diagnostic ignored "-Wduplicate-decl-specifier"
#endif

void mock_device_Init(void);
void mock_device_Destroy(void);
void mock_device_Verify(void);

#define __wrap_device_handle_get_IgnoreAndReturn(cmock_retval) __wrap_device_handle_get_CMockIgnoreAndReturn(__LINE__, cmock_retval)
void __wrap_device_handle_get_CMockIgnoreAndReturn(UNITY_LINE_TYPE cmock_line, device_handle_t cmock_to_return);
#define __wrap_device_handle_get_StopIgnore() __wrap_device_handle_get_CMockStopIgnore()
void __wrap_device_handle_get_CMockStopIgnore(void);
#define __wrap_device_handle_get_ExpectAnyArgsAndReturn(cmock_retval) __wrap_device_handle_get_CMockExpectAnyArgsAndReturn(__LINE__, cmock_retval)
void __wrap_device_handle_get_CMockExpectAnyArgsAndReturn(UNITY_LINE_TYPE cmock_line, device_handle_t cmock_to_return);
#define __wrap_device_handle_get_ExpectAndReturn(dev, cmock_retval) __wrap_device_handle_get_CMockExpectAndReturn(__LINE__, dev, cmock_retval)
void __wrap_device_handle_get_CMockExpectAndReturn(UNITY_LINE_TYPE cmock_line, const struct device* dev, device_handle_t cmock_to_return);
typedef device_handle_t (* CMOCK___wrap_device_handle_get_CALLBACK)(const struct device* dev, int cmock_num_calls);
void __wrap_device_handle_get_AddCallback(CMOCK___wrap_device_handle_get_CALLBACK Callback);
void __wrap_device_handle_get_Stub(CMOCK___wrap_device_handle_get_CALLBACK Callback);
#define __wrap_device_handle_get_StubWithCallback __wrap_device_handle_get_AddCallback
#define __wrap_device_handle_get_ExpectWithArrayAndReturn(dev, dev_Depth, cmock_retval) __wrap_device_handle_get_CMockExpectWithArrayAndReturn(__LINE__, dev, dev_Depth, cmock_retval)
void __wrap_device_handle_get_CMockExpectWithArrayAndReturn(UNITY_LINE_TYPE cmock_line, const struct device* dev, int dev_Depth, device_handle_t cmock_to_return);
#define __wrap_device_handle_get_IgnoreArg_dev() __wrap_device_handle_get_CMockIgnoreArg_dev(__LINE__)
void __wrap_device_handle_get_CMockIgnoreArg_dev(UNITY_LINE_TYPE cmock_line);
#define __wrap_device_from_handle_IgnoreAndReturn(cmock_retval) __wrap_device_from_handle_CMockIgnoreAndReturn(__LINE__, cmock_retval)
void __wrap_device_from_handle_CMockIgnoreAndReturn(UNITY_LINE_TYPE cmock_line, const struct device* cmock_to_return);
#define __wrap_device_from_handle_StopIgnore() __wrap_device_from_handle_CMockStopIgnore()
void __wrap_device_from_handle_CMockStopIgnore(void);
#define __wrap_device_from_handle_ExpectAnyArgsAndReturn(cmock_retval) __wrap_device_from_handle_CMockExpectAnyArgsAndReturn(__LINE__, cmock_retval)
void __wrap_device_from_handle_CMockExpectAnyArgsAndReturn(UNITY_LINE_TYPE cmock_line, const struct device* cmock_to_return);
#define __wrap_device_from_handle_ExpectAndReturn(dev_handle, cmock_retval) __wrap_device_from_handle_CMockExpectAndReturn(__LINE__, dev_handle, cmock_retval)
void __wrap_device_from_handle_CMockExpectAndReturn(UNITY_LINE_TYPE cmock_line, device_handle_t dev_handle, const struct device* cmock_to_return);
typedef const struct device* (* CMOCK___wrap_device_from_handle_CALLBACK)(device_handle_t dev_handle, int cmock_num_calls);
void __wrap_device_from_handle_AddCallback(CMOCK___wrap_device_from_handle_CALLBACK Callback);
void __wrap_device_from_handle_Stub(CMOCK___wrap_device_from_handle_CALLBACK Callback);
#define __wrap_device_from_handle_StubWithCallback __wrap_device_from_handle_AddCallback
#define __wrap_device_from_handle_IgnoreArg_dev_handle() __wrap_device_from_handle_CMockIgnoreArg_dev_handle(__LINE__)
void __wrap_device_from_handle_CMockIgnoreArg_dev_handle(UNITY_LINE_TYPE cmock_line);
#define __wrap_device_required_handles_get_IgnoreAndReturn(cmock_retval) __wrap_device_required_handles_get_CMockIgnoreAndReturn(__LINE__, cmock_retval)
void __wrap_device_required_handles_get_CMockIgnoreAndReturn(UNITY_LINE_TYPE cmock_line, const device_handle_t* cmock_to_return);
#define __wrap_device_required_handles_get_StopIgnore() __wrap_device_required_handles_get_CMockStopIgnore()
void __wrap_device_required_handles_get_CMockStopIgnore(void);
#define __wrap_device_required_handles_get_ExpectAnyArgsAndReturn(cmock_retval) __wrap_device_required_handles_get_CMockExpectAnyArgsAndReturn(__LINE__, cmock_retval)
void __wrap_device_required_handles_get_CMockExpectAnyArgsAndReturn(UNITY_LINE_TYPE cmock_line, const device_handle_t* cmock_to_return);
#define __wrap_device_required_handles_get_ExpectAndReturn(dev, count, cmock_retval) __wrap_device_required_handles_get_CMockExpectAndReturn(__LINE__, dev, count, cmock_retval)
void __wrap_device_required_handles_get_CMockExpectAndReturn(UNITY_LINE_TYPE cmock_line, const struct device* dev, size_t* count, const device_handle_t* cmock_to_return);
typedef const device_handle_t* (* CMOCK___wrap_device_required_handles_get_CALLBACK)(const struct device* dev, size_t* count, int cmock_num_calls);
void __wrap_device_required_handles_get_AddCallback(CMOCK___wrap_device_required_handles_get_CALLBACK Callback);
void __wrap_device_required_handles_get_Stub(CMOCK___wrap_device_required_handles_get_CALLBACK Callback);
#define __wrap_device_required_handles_get_StubWithCallback __wrap_device_required_handles_get_AddCallback
#define __wrap_device_required_handles_get_ExpectWithArrayAndReturn(dev, dev_Depth, count, count_Depth, cmock_retval) __wrap_device_required_handles_get_CMockExpectWithArrayAndReturn(__LINE__, dev, dev_Depth, count, count_Depth, cmock_retval)
void __wrap_device_required_handles_get_CMockExpectWithArrayAndReturn(UNITY_LINE_TYPE cmock_line, const struct device* dev, int dev_Depth, size_t* count, int count_Depth, const device_handle_t* cmock_to_return);
#define __wrap_device_required_handles_get_ReturnThruPtr_count(count) __wrap_device_required_handles_get_CMockReturnMemThruPtr_count(__LINE__, count, sizeof(size_t))
#define __wrap_device_required_handles_get_ReturnArrayThruPtr_count(count, cmock_len) __wrap_device_required_handles_get_CMockReturnMemThruPtr_count(__LINE__, count, cmock_len * sizeof(*count))
#define __wrap_device_required_handles_get_ReturnMemThruPtr_count(count, cmock_size) __wrap_device_required_handles_get_CMockReturnMemThruPtr_count(__LINE__, count, cmock_size)
void __wrap_device_required_handles_get_CMockReturnMemThruPtr_count(UNITY_LINE_TYPE cmock_line, size_t* count, size_t cmock_size);
#define __wrap_device_required_handles_get_IgnoreArg_dev() __wrap_device_required_handles_get_CMockIgnoreArg_dev(__LINE__)
void __wrap_device_required_handles_get_CMockIgnoreArg_dev(UNITY_LINE_TYPE cmock_line);
#define __wrap_device_required_handles_get_IgnoreArg_count() __wrap_device_required_handles_get_CMockIgnoreArg_count(__LINE__)
void __wrap_device_required_handles_get_CMockIgnoreArg_count(UNITY_LINE_TYPE cmock_line);
#define __wrap_device_supported_handles_get_IgnoreAndReturn(cmock_retval) __wrap_device_supported_handles_get_CMockIgnoreAndReturn(__LINE__, cmock_retval)
void __wrap_device_supported_handles_get_CMockIgnoreAndReturn(UNITY_LINE_TYPE cmock_line, const device_handle_t* cmock_to_return);
#define __wrap_device_supported_handles_get_StopIgnore() __wrap_device_supported_handles_get_CMockStopIgnore()
void __wrap_device_supported_handles_get_CMockStopIgnore(void);
#define __wrap_device_supported_handles_get_ExpectAnyArgsAndReturn(cmock_retval) __wrap_device_supported_handles_get_CMockExpectAnyArgsAndReturn(__LINE__, cmock_retval)
void __wrap_device_supported_handles_get_CMockExpectAnyArgsAndReturn(UNITY_LINE_TYPE cmock_line, const device_handle_t* cmock_to_return);
#define __wrap_device_supported_handles_get_ExpectAndReturn(dev, count, cmock_retval) __wrap_device_supported_handles_get_CMockExpectAndReturn(__LINE__, dev, count, cmock_retval)
void __wrap_device_supported_handles_get_CMockExpectAndReturn(UNITY_LINE_TYPE cmock_line, const struct device* dev, size_t* count, const device_handle_t* cmock_to_return);
typedef const device_handle_t* (* CMOCK___wrap_device_supported_handles_get_CALLBACK)(const struct device* dev, size_t* count, int cmock_num_calls);
void __wrap_device_supported_handles_get_AddCallback(CMOCK___wrap_device_supported_handles_get_CALLBACK Callback);
void __wrap_device_supported_handles_get_Stub(CMOCK___wrap_device_supported_handles_get_CALLBACK Callback);
#define __wrap_device_supported_handles_get_StubWithCallback __wrap_device_supported_handles_get_AddCallback
#define __wrap_device_supported_handles_get_ExpectWithArrayAndReturn(dev, dev_Depth, count, count_Depth, cmock_retval) __wrap_device_supported_handles_get_CMockExpectWithArrayAndReturn(__LINE__, dev, dev_Depth, count, count_Depth, cmock_retval)
void __wrap_device_supported_handles_get_CMockExpectWithArrayAndReturn(UNITY_LINE_TYPE cmock_line, const struct device* dev, int dev_Depth, size_t* count, int count_Depth, const device_handle_t* cmock_to_return);
#define __wrap_device_supported_handles_get_ReturnThruPtr_count(count) __wrap_device_supported_handles_get_CMockReturnMemThruPtr_count(__LINE__, count, sizeof(size_t))
#define __wrap_device_supported_handles_get_ReturnArrayThruPtr_count(count, cmock_len) __wrap_device_supported_handles_get_CMockReturnMemThruPtr_count(__LINE__, count, cmock_len * sizeof(*count))
#define __wrap_device_supported_handles_get_ReturnMemThruPtr_count(count, cmock_size) __wrap_device_supported_handles_get_CMockReturnMemThruPtr_count(__LINE__, count, cmock_size)
void __wrap_device_supported_handles_get_CMockReturnMemThruPtr_count(UNITY_LINE_TYPE cmock_line, size_t* count, size_t cmock_size);
#define __wrap_device_supported_handles_get_IgnoreArg_dev() __wrap_device_supported_handles_get_CMockIgnoreArg_dev(__LINE__)
void __wrap_device_supported_handles_get_CMockIgnoreArg_dev(UNITY_LINE_TYPE cmock_line);
#define __wrap_device_supported_handles_get_IgnoreArg_count() __wrap_device_supported_handles_get_CMockIgnoreArg_count(__LINE__)
void __wrap_device_supported_handles_get_CMockIgnoreArg_count(UNITY_LINE_TYPE cmock_line);
#define __wrap_device_required_foreach_IgnoreAndReturn(cmock_retval) __wrap_device_required_foreach_CMockIgnoreAndReturn(__LINE__, cmock_retval)
void __wrap_device_required_foreach_CMockIgnoreAndReturn(UNITY_LINE_TYPE cmock_line, int cmock_to_return);
#define __wrap_device_required_foreach_StopIgnore() __wrap_device_required_foreach_CMockStopIgnore()
void __wrap_device_required_foreach_CMockStopIgnore(void);
#define __wrap_device_required_foreach_ExpectAnyArgsAndReturn(cmock_retval) __wrap_device_required_foreach_CMockExpectAnyArgsAndReturn(__LINE__, cmock_retval)
void __wrap_device_required_foreach_CMockExpectAnyArgsAndReturn(UNITY_LINE_TYPE cmock_line, int cmock_to_return);
#define __wrap_device_required_foreach_ExpectAndReturn(dev, visitor_cb, context, cmock_retval) __wrap_device_required_foreach_CMockExpectAndReturn(__LINE__, dev, visitor_cb, context, cmock_retval)
void __wrap_device_required_foreach_CMockExpectAndReturn(UNITY_LINE_TYPE cmock_line, const struct device* dev, device_visitor_callback_t visitor_cb, void* context, int cmock_to_return);
typedef int (* CMOCK___wrap_device_required_foreach_CALLBACK)(const struct device* dev, device_visitor_callback_t visitor_cb, void* context, int cmock_num_calls);
void __wrap_device_required_foreach_AddCallback(CMOCK___wrap_device_required_foreach_CALLBACK Callback);
void __wrap_device_required_foreach_Stub(CMOCK___wrap_device_required_foreach_CALLBACK Callback);
#define __wrap_device_required_foreach_StubWithCallback __wrap_device_required_foreach_AddCallback
#define __wrap_device_required_foreach_ExpectWithArrayAndReturn(dev, dev_Depth, visitor_cb, context, context_Depth, cmock_retval) __wrap_device_required_foreach_CMockExpectWithArrayAndReturn(__LINE__, dev, dev_Depth, visitor_cb, context, context_Depth, cmock_retval)
void __wrap_device_required_foreach_CMockExpectWithArrayAndReturn(UNITY_LINE_TYPE cmock_line, const struct device* dev, int dev_Depth, device_visitor_callback_t visitor_cb, void* context, int context_Depth, int cmock_to_return);
#define __wrap_device_required_foreach_ReturnThruPtr_context(context) __wrap_device_required_foreach_CMockReturnMemThruPtr_context(__LINE__, context, sizeof(void))
#define __wrap_device_required_foreach_ReturnArrayThruPtr_context(context, cmock_len) __wrap_device_required_foreach_CMockReturnMemThruPtr_context(__LINE__, context, cmock_len * sizeof(*context))
#define __wrap_device_required_foreach_ReturnMemThruPtr_context(context, cmock_size) __wrap_device_required_foreach_CMockReturnMemThruPtr_context(__LINE__, context, cmock_size)
void __wrap_device_required_foreach_CMockReturnMemThruPtr_context(UNITY_LINE_TYPE cmock_line, void* context, size_t cmock_size);
#define __wrap_device_required_foreach_IgnoreArg_dev() __wrap_device_required_foreach_CMockIgnoreArg_dev(__LINE__)
void __wrap_device_required_foreach_CMockIgnoreArg_dev(UNITY_LINE_TYPE cmock_line);
#define __wrap_device_required_foreach_IgnoreArg_visitor_cb() __wrap_device_required_foreach_CMockIgnoreArg_visitor_cb(__LINE__)
void __wrap_device_required_foreach_CMockIgnoreArg_visitor_cb(UNITY_LINE_TYPE cmock_line);
#define __wrap_device_required_foreach_IgnoreArg_context() __wrap_device_required_foreach_CMockIgnoreArg_context(__LINE__)
void __wrap_device_required_foreach_CMockIgnoreArg_context(UNITY_LINE_TYPE cmock_line);
#define __wrap_device_supported_foreach_IgnoreAndReturn(cmock_retval) __wrap_device_supported_foreach_CMockIgnoreAndReturn(__LINE__, cmock_retval)
void __wrap_device_supported_foreach_CMockIgnoreAndReturn(UNITY_LINE_TYPE cmock_line, int cmock_to_return);
#define __wrap_device_supported_foreach_StopIgnore() __wrap_device_supported_foreach_CMockStopIgnore()
void __wrap_device_supported_foreach_CMockStopIgnore(void);
#define __wrap_device_supported_foreach_ExpectAnyArgsAndReturn(cmock_retval) __wrap_device_supported_foreach_CMockExpectAnyArgsAndReturn(__LINE__, cmock_retval)
void __wrap_device_supported_foreach_CMockExpectAnyArgsAndReturn(UNITY_LINE_TYPE cmock_line, int cmock_to_return);
#define __wrap_device_supported_foreach_ExpectAndReturn(dev, visitor_cb, context, cmock_retval) __wrap_device_supported_foreach_CMockExpectAndReturn(__LINE__, dev, visitor_cb, context, cmock_retval)
void __wrap_device_supported_foreach_CMockExpectAndReturn(UNITY_LINE_TYPE cmock_line, const struct device* dev, device_visitor_callback_t visitor_cb, void* context, int cmock_to_return);
typedef int (* CMOCK___wrap_device_supported_foreach_CALLBACK)(const struct device* dev, device_visitor_callback_t visitor_cb, void* context, int cmock_num_calls);
void __wrap_device_supported_foreach_AddCallback(CMOCK___wrap_device_supported_foreach_CALLBACK Callback);
void __wrap_device_supported_foreach_Stub(CMOCK___wrap_device_supported_foreach_CALLBACK Callback);
#define __wrap_device_supported_foreach_StubWithCallback __wrap_device_supported_foreach_AddCallback
#define __wrap_device_supported_foreach_ExpectWithArrayAndReturn(dev, dev_Depth, visitor_cb, context, context_Depth, cmock_retval) __wrap_device_supported_foreach_CMockExpectWithArrayAndReturn(__LINE__, dev, dev_Depth, visitor_cb, context, context_Depth, cmock_retval)
void __wrap_device_supported_foreach_CMockExpectWithArrayAndReturn(UNITY_LINE_TYPE cmock_line, const struct device* dev, int dev_Depth, device_visitor_callback_t visitor_cb, void* context, int context_Depth, int cmock_to_return);
#define __wrap_device_supported_foreach_ReturnThruPtr_context(context) __wrap_device_supported_foreach_CMockReturnMemThruPtr_context(__LINE__, context, sizeof(void))
#define __wrap_device_supported_foreach_ReturnArrayThruPtr_context(context, cmock_len) __wrap_device_supported_foreach_CMockReturnMemThruPtr_context(__LINE__, context, cmock_len * sizeof(*context))
#define __wrap_device_supported_foreach_ReturnMemThruPtr_context(context, cmock_size) __wrap_device_supported_foreach_CMockReturnMemThruPtr_context(__LINE__, context, cmock_size)
void __wrap_device_supported_foreach_CMockReturnMemThruPtr_context(UNITY_LINE_TYPE cmock_line, void* context, size_t cmock_size);
#define __wrap_device_supported_foreach_IgnoreArg_dev() __wrap_device_supported_foreach_CMockIgnoreArg_dev(__LINE__)
void __wrap_device_supported_foreach_CMockIgnoreArg_dev(UNITY_LINE_TYPE cmock_line);
#define __wrap_device_supported_foreach_IgnoreArg_visitor_cb() __wrap_device_supported_foreach_CMockIgnoreArg_visitor_cb(__LINE__)
void __wrap_device_supported_foreach_CMockIgnoreArg_visitor_cb(UNITY_LINE_TYPE cmock_line);
#define __wrap_device_supported_foreach_IgnoreArg_context() __wrap_device_supported_foreach_CMockIgnoreArg_context(__LINE__)
void __wrap_device_supported_foreach_CMockIgnoreArg_context(UNITY_LINE_TYPE cmock_line);
#define __wrap_z_device_get_all_static_IgnoreAndReturn(cmock_retval) __wrap_z_device_get_all_static_CMockIgnoreAndReturn(__LINE__, cmock_retval)
void __wrap_z_device_get_all_static_CMockIgnoreAndReturn(UNITY_LINE_TYPE cmock_line, size_t cmock_to_return);
#define __wrap_z_device_get_all_static_StopIgnore() __wrap_z_device_get_all_static_CMockStopIgnore()
void __wrap_z_device_get_all_static_CMockStopIgnore(void);
#define __wrap_z_device_get_all_static_ExpectAnyArgsAndReturn(cmock_retval) __wrap_z_device_get_all_static_CMockExpectAnyArgsAndReturn(__LINE__, cmock_retval)
void __wrap_z_device_get_all_static_CMockExpectAnyArgsAndReturn(UNITY_LINE_TYPE cmock_line, size_t cmock_to_return);
#define __wrap_z_device_get_all_static_ExpectAndReturn(devices, cmock_retval) __wrap_z_device_get_all_static_CMockExpectAndReturn(__LINE__, devices, cmock_retval)
void __wrap_z_device_get_all_static_CMockExpectAndReturn(UNITY_LINE_TYPE cmock_line, const struct device** devices, size_t cmock_to_return);
typedef size_t (* CMOCK___wrap_z_device_get_all_static_CALLBACK)(const struct device** devices, int cmock_num_calls);
void __wrap_z_device_get_all_static_AddCallback(CMOCK___wrap_z_device_get_all_static_CALLBACK Callback);
void __wrap_z_device_get_all_static_Stub(CMOCK___wrap_z_device_get_all_static_CALLBACK Callback);
#define __wrap_z_device_get_all_static_StubWithCallback __wrap_z_device_get_all_static_AddCallback
#define __wrap_z_device_get_all_static_ExpectWithArrayAndReturn(devices, devices_Depth, cmock_retval) __wrap_z_device_get_all_static_CMockExpectWithArrayAndReturn(__LINE__, devices, devices_Depth, cmock_retval)
void __wrap_z_device_get_all_static_CMockExpectWithArrayAndReturn(UNITY_LINE_TYPE cmock_line, const struct device** devices, int devices_Depth, size_t cmock_to_return);
#define __wrap_z_device_get_all_static_ReturnThruPtr_devices(devices) __wrap_z_device_get_all_static_CMockReturnMemThruPtr_devices(__LINE__, devices, sizeof(const struct device*))
#define __wrap_z_device_get_all_static_ReturnArrayThruPtr_devices(devices, cmock_len) __wrap_z_device_get_all_static_CMockReturnMemThruPtr_devices(__LINE__, devices, cmock_len * sizeof(*devices))
#define __wrap_z_device_get_all_static_ReturnMemThruPtr_devices(devices, cmock_size) __wrap_z_device_get_all_static_CMockReturnMemThruPtr_devices(__LINE__, devices, cmock_size)
void __wrap_z_device_get_all_static_CMockReturnMemThruPtr_devices(UNITY_LINE_TYPE cmock_line, const struct device** devices, size_t cmock_size);
#define __wrap_z_device_get_all_static_IgnoreArg_devices() __wrap_z_device_get_all_static_CMockIgnoreArg_devices(__LINE__)
void __wrap_z_device_get_all_static_CMockIgnoreArg_devices(UNITY_LINE_TYPE cmock_line);
#define __wrap_z_device_is_ready_IgnoreAndReturn(cmock_retval) __wrap_z_device_is_ready_CMockIgnoreAndReturn(__LINE__, cmock_retval)
void __wrap_z_device_is_ready_CMockIgnoreAndReturn(UNITY_LINE_TYPE cmock_line, bool cmock_to_return);
#define __wrap_z_device_is_ready_StopIgnore() __wrap_z_device_is_ready_CMockStopIgnore()
void __wrap_z_device_is_ready_CMockStopIgnore(void);
#define __wrap_z_device_is_ready_ExpectAnyArgsAndReturn(cmock_retval) __wrap_z_device_is_ready_CMockExpectAnyArgsAndReturn(__LINE__, cmock_retval)
void __wrap_z_device_is_ready_CMockExpectAnyArgsAndReturn(UNITY_LINE_TYPE cmock_line, bool cmock_to_return);
#define __wrap_z_device_is_ready_ExpectAndReturn(dev, cmock_retval) __wrap_z_device_is_ready_CMockExpectAndReturn(__LINE__, dev, cmock_retval)
void __wrap_z_device_is_ready_CMockExpectAndReturn(UNITY_LINE_TYPE cmock_line, const struct device* dev, bool cmock_to_return);
typedef bool (* CMOCK___wrap_z_device_is_ready_CALLBACK)(const struct device* dev, int cmock_num_calls);
void __wrap_z_device_is_ready_AddCallback(CMOCK___wrap_z_device_is_ready_CALLBACK Callback);
void __wrap_z_device_is_ready_Stub(CMOCK___wrap_z_device_is_ready_CALLBACK Callback);
#define __wrap_z_device_is_ready_StubWithCallback __wrap_z_device_is_ready_AddCallback
#define __wrap_z_device_is_ready_ExpectWithArrayAndReturn(dev, dev_Depth, cmock_retval) __wrap_z_device_is_ready_CMockExpectWithArrayAndReturn(__LINE__, dev, dev_Depth, cmock_retval)
void __wrap_z_device_is_ready_CMockExpectWithArrayAndReturn(UNITY_LINE_TYPE cmock_line, const struct device* dev, int dev_Depth, bool cmock_to_return);
#define __wrap_z_device_is_ready_IgnoreArg_dev() __wrap_z_device_is_ready_CMockIgnoreArg_dev(__LINE__)
void __wrap_z_device_is_ready_CMockIgnoreArg_dev(UNITY_LINE_TYPE cmock_line);
#define __wrap_z_impl_device_is_ready_IgnoreAndReturn(cmock_retval) __wrap_z_impl_device_is_ready_CMockIgnoreAndReturn(__LINE__, cmock_retval)
void __wrap_z_impl_device_is_ready_CMockIgnoreAndReturn(UNITY_LINE_TYPE cmock_line, bool cmock_to_return);
#define __wrap_z_impl_device_is_ready_StopIgnore() __wrap_z_impl_device_is_ready_CMockStopIgnore()
void __wrap_z_impl_device_is_ready_CMockStopIgnore(void);
#define __wrap_z_impl_device_is_ready_ExpectAnyArgsAndReturn(cmock_retval) __wrap_z_impl_device_is_ready_CMockExpectAnyArgsAndReturn(__LINE__, cmock_retval)
void __wrap_z_impl_device_is_ready_CMockExpectAnyArgsAndReturn(UNITY_LINE_TYPE cmock_line, bool cmock_to_return);
#define __wrap_z_impl_device_is_ready_ExpectAndReturn(dev, cmock_retval) __wrap_z_impl_device_is_ready_CMockExpectAndReturn(__LINE__, dev, cmock_retval)
void __wrap_z_impl_device_is_ready_CMockExpectAndReturn(UNITY_LINE_TYPE cmock_line, const struct device* dev, bool cmock_to_return);
typedef bool (* CMOCK___wrap_z_impl_device_is_ready_CALLBACK)(const struct device* dev, int cmock_num_calls);
void __wrap_z_impl_device_is_ready_AddCallback(CMOCK___wrap_z_impl_device_is_ready_CALLBACK Callback);
void __wrap_z_impl_device_is_ready_Stub(CMOCK___wrap_z_impl_device_is_ready_CALLBACK Callback);
#define __wrap_z_impl_device_is_ready_StubWithCallback __wrap_z_impl_device_is_ready_AddCallback
#define __wrap_z_impl_device_is_ready_ExpectWithArrayAndReturn(dev, dev_Depth, cmock_retval) __wrap_z_impl_device_is_ready_CMockExpectWithArrayAndReturn(__LINE__, dev, dev_Depth, cmock_retval)
void __wrap_z_impl_device_is_ready_CMockExpectWithArrayAndReturn(UNITY_LINE_TYPE cmock_line, const struct device* dev, int dev_Depth, bool cmock_to_return);
#define __wrap_z_impl_device_is_ready_IgnoreArg_dev() __wrap_z_impl_device_is_ready_CMockIgnoreArg_dev(__LINE__)
void __wrap_z_impl_device_is_ready_CMockIgnoreArg_dev(UNITY_LINE_TYPE cmock_line);
#define __wrap_z_device_usable_check_IgnoreAndReturn(cmock_retval) __wrap_z_device_usable_check_CMockIgnoreAndReturn(__LINE__, cmock_retval)
void __wrap_z_device_usable_check_CMockIgnoreAndReturn(UNITY_LINE_TYPE cmock_line, int cmock_to_return);
#define __wrap_z_device_usable_check_StopIgnore() __wrap_z_device_usable_check_CMockStopIgnore()
void __wrap_z_device_usable_check_CMockStopIgnore(void);
#define __wrap_z_device_usable_check_ExpectAnyArgsAndReturn(cmock_retval) __wrap_z_device_usable_check_CMockExpectAnyArgsAndReturn(__LINE__, cmock_retval)
void __wrap_z_device_usable_check_CMockExpectAnyArgsAndReturn(UNITY_LINE_TYPE cmock_line, int cmock_to_return);
#define __wrap_z_device_usable_check_ExpectAndReturn(dev, cmock_retval) __wrap_z_device_usable_check_CMockExpectAndReturn(__LINE__, dev, cmock_retval)
void __wrap_z_device_usable_check_CMockExpectAndReturn(UNITY_LINE_TYPE cmock_line, const struct device* dev, int cmock_to_return);
typedef int (* CMOCK___wrap_z_device_usable_check_CALLBACK)(const struct device* dev, int cmock_num_calls);
void __wrap_z_device_usable_check_AddCallback(CMOCK___wrap_z_device_usable_check_CALLBACK Callback);
void __wrap_z_device_usable_check_Stub(CMOCK___wrap_z_device_usable_check_CALLBACK Callback);
#define __wrap_z_device_usable_check_StubWithCallback __wrap_z_device_usable_check_AddCallback
#define __wrap_z_device_usable_check_ExpectWithArrayAndReturn(dev, dev_Depth, cmock_retval) __wrap_z_device_usable_check_CMockExpectWithArrayAndReturn(__LINE__, dev, dev_Depth, cmock_retval)
void __wrap_z_device_usable_check_CMockExpectWithArrayAndReturn(UNITY_LINE_TYPE cmock_line, const struct device* dev, int dev_Depth, int cmock_to_return);
#define __wrap_z_device_usable_check_IgnoreArg_dev() __wrap_z_device_usable_check_CMockIgnoreArg_dev(__LINE__)
void __wrap_z_device_usable_check_CMockIgnoreArg_dev(UNITY_LINE_TYPE cmock_line);
#define __wrap_device_usable_check_IgnoreAndReturn(cmock_retval) __wrap_device_usable_check_CMockIgnoreAndReturn(__LINE__, cmock_retval)
void __wrap_device_usable_check_CMockIgnoreAndReturn(UNITY_LINE_TYPE cmock_line, int cmock_to_return);
#define __wrap_device_usable_check_StopIgnore() __wrap_device_usable_check_CMockStopIgnore()
void __wrap_device_usable_check_CMockStopIgnore(void);
#define __wrap_device_usable_check_ExpectAnyArgsAndReturn(cmock_retval) __wrap_device_usable_check_CMockExpectAnyArgsAndReturn(__LINE__, cmock_retval)
void __wrap_device_usable_check_CMockExpectAnyArgsAndReturn(UNITY_LINE_TYPE cmock_line, int cmock_to_return);
#define __wrap_device_usable_check_ExpectAndReturn(dev, cmock_retval) __wrap_device_usable_check_CMockExpectAndReturn(__LINE__, dev, cmock_retval)
void __wrap_device_usable_check_CMockExpectAndReturn(UNITY_LINE_TYPE cmock_line, const struct device* dev, int cmock_to_return);
typedef int (* CMOCK___wrap_device_usable_check_CALLBACK)(const struct device* dev, int cmock_num_calls);
void __wrap_device_usable_check_AddCallback(CMOCK___wrap_device_usable_check_CALLBACK Callback);
void __wrap_device_usable_check_Stub(CMOCK___wrap_device_usable_check_CALLBACK Callback);
#define __wrap_device_usable_check_StubWithCallback __wrap_device_usable_check_AddCallback
#define __wrap_device_usable_check_ExpectWithArrayAndReturn(dev, dev_Depth, cmock_retval) __wrap_device_usable_check_CMockExpectWithArrayAndReturn(__LINE__, dev, dev_Depth, cmock_retval)
void __wrap_device_usable_check_CMockExpectWithArrayAndReturn(UNITY_LINE_TYPE cmock_line, const struct device* dev, int dev_Depth, int cmock_to_return);
#define __wrap_device_usable_check_IgnoreArg_dev() __wrap_device_usable_check_CMockIgnoreArg_dev(__LINE__)
void __wrap_device_usable_check_CMockIgnoreArg_dev(UNITY_LINE_TYPE cmock_line);

#if defined(__GNUC__) && !defined(__ICC) && !defined(__TMS470__)
#if __GNUC__ > 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ > 6 || (__GNUC_MINOR__ == 6 && __GNUC_PATCHLEVEL__ > 0)))
#pragma GCC diagnostic pop
#endif
#endif

#endif
Letme commented 2 years ago

My search tells me there is no __syscall in the MOCK_DEVICE_H, so I guess strippables work...

ggau35 commented 2 years ago

The problem is that device_get_bindingfunction, which has in its definition the prefix __syscall, doesn't appears inside the file generated by cmock.

The file to mock is device.h Inside this file, you can find __syscall const struct device *device_get_binding(const char *name); function definition. This function is not found inside mock_device.h. It is the same behavior if I have strippables option or not inside configuration file. But if il delete __syscall, device_get_binding appears inside mock_device.h.

Letme commented 2 years ago

Strange. I tried with latest CMock to mock the device.h and it did produce a device_get_binding (see below).

Here is my Cmock config (some additional crap inside, since I was just using my current project - i use postfixes for files)

:cmock:
    :framework: :unity
    :plugins:
        - 'expect'
        - 'ignore'
        - 'ignore_arg'
        - 'return_thru_ptr'
    :includes_c_pre_header:
        - 'config.h'
    :includes_h_pre_orig_header:
        - 'unity.h'
        - 'config.h'
    :treat_externs: :include
    :when_no_prototypes: :warning
    :enforce_strict_ordering: false
    :mock_path: 'unit_test/mockcomponents'
    :mock_prefix: ''
    :mock_suffix: '_mock'
    :strippables:
        - 'STATIC'
        - 'INLINE'
        - 'NOINLINE'
        - 'INTERRUPT'
        - 'NO_RETURN'
        - '__inline__'
        - '__syscall'
    :attributes:
        - 'always_inline'
    :weak: '__attribute__((weak))'

device_mock.h:

/* AUTOGENERATED FILE. DO NOT EDIT. */
#ifndef _DEVICE_MOCK_H
#define _DEVICE_MOCK_H

#include "unity.h"
#include "unity.h"
#include "config.h"
#include "device.h"

/* Ignore the following warnings, since we are copying code */
#if defined(__GNUC__) && !defined(__ICC) && !defined(__TMS470__)
#if __GNUC__ > 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ > 6 || (__GNUC_MINOR__ == 6 && __GNUC_PATCHLEVEL__ > 0)))
#pragma GCC diagnostic push
#endif
#if !defined(__clang__)
#pragma GCC diagnostic ignored "-Wpragmas"
#endif
#pragma GCC diagnostic ignored "-Wunknown-pragmas"
#pragma GCC diagnostic ignored "-Wduplicate-decl-specifier"
#endif

void device_mock_Init(void);
void device_mock_Destroy(void);
void device_mock_Verify(void);

#define device_required_foreach_IgnoreAndReturn(cmock_retval) device_required_foreach_CMockIgnoreAndReturn(__LINE__, cmock_retval)
void device_required_foreach_CMockIgnoreAndReturn(UNITY_LINE_TYPE cmock_line, int cmock_to_return);
#define device_required_foreach_StopIgnore() device_required_foreach_CMockStopIgnore()
void device_required_foreach_CMockStopIgnore(void);
#define device_required_foreach_ExpectAndReturn(dev, visitor_cb, context, cmock_retval) device_required_foreach_CMockExpectAndReturn(__LINE__, dev, visitor_cb, context, cmock_retval)
void device_required_foreach_CMockExpectAndReturn(UNITY_LINE_TYPE cmock_line, const struct device* dev, device_visitor_callback_t visitor_cb, void* context, int cmock_to_return);
#define device_required_foreach_ReturnThruPtr_context(context) device_required_foreach_CMockReturnMemThruPtr_context(__LINE__, context, sizeof(void))
#define device_required_foreach_ReturnArrayThruPtr_context(context, cmock_len) device_required_foreach_CMockReturnMemThruPtr_context(__LINE__, context, cmock_len * sizeof(*context))
#define device_required_foreach_ReturnMemThruPtr_context(context, cmock_size) device_required_foreach_CMockReturnMemThruPtr_context(__LINE__, context, cmock_size)
void device_required_foreach_CMockReturnMemThruPtr_context(UNITY_LINE_TYPE cmock_line, void* context, size_t cmock_size);
#define device_required_foreach_IgnoreArg_dev() device_required_foreach_CMockIgnoreArg_dev(__LINE__)
void device_required_foreach_CMockIgnoreArg_dev(UNITY_LINE_TYPE cmock_line);
#define device_required_foreach_IgnoreArg_visitor_cb() device_required_foreach_CMockIgnoreArg_visitor_cb(__LINE__)
void device_required_foreach_CMockIgnoreArg_visitor_cb(UNITY_LINE_TYPE cmock_line);
#define device_required_foreach_IgnoreArg_context() device_required_foreach_CMockIgnoreArg_context(__LINE__)
void device_required_foreach_CMockIgnoreArg_context(UNITY_LINE_TYPE cmock_line);
#define device_supported_foreach_IgnoreAndReturn(cmock_retval) device_supported_foreach_CMockIgnoreAndReturn(__LINE__, cmock_retval)
void device_supported_foreach_CMockIgnoreAndReturn(UNITY_LINE_TYPE cmock_line, int cmock_to_return);
#define device_supported_foreach_StopIgnore() device_supported_foreach_CMockStopIgnore()
void device_supported_foreach_CMockStopIgnore(void);
#define device_supported_foreach_ExpectAndReturn(dev, visitor_cb, context, cmock_retval) device_supported_foreach_CMockExpectAndReturn(__LINE__, dev, visitor_cb, context, cmock_retval)
void device_supported_foreach_CMockExpectAndReturn(UNITY_LINE_TYPE cmock_line, const struct device* dev, device_visitor_callback_t visitor_cb, void* context, int cmock_to_return);
#define device_supported_foreach_ReturnThruPtr_context(context) device_supported_foreach_CMockReturnMemThruPtr_context(__LINE__, context, sizeof(void))
#define device_supported_foreach_ReturnArrayThruPtr_context(context, cmock_len) device_supported_foreach_CMockReturnMemThruPtr_context(__LINE__, context, cmock_len * sizeof(*context))
#define device_supported_foreach_ReturnMemThruPtr_context(context, cmock_size) device_supported_foreach_CMockReturnMemThruPtr_context(__LINE__, context, cmock_size)
void device_supported_foreach_CMockReturnMemThruPtr_context(UNITY_LINE_TYPE cmock_line, void* context, size_t cmock_size);
#define device_supported_foreach_IgnoreArg_dev() device_supported_foreach_CMockIgnoreArg_dev(__LINE__)
void device_supported_foreach_CMockIgnoreArg_dev(UNITY_LINE_TYPE cmock_line);
#define device_supported_foreach_IgnoreArg_visitor_cb() device_supported_foreach_CMockIgnoreArg_visitor_cb(__LINE__)
void device_supported_foreach_CMockIgnoreArg_visitor_cb(UNITY_LINE_TYPE cmock_line);
#define device_supported_foreach_IgnoreArg_context() device_supported_foreach_CMockIgnoreArg_context(__LINE__)
void device_supported_foreach_CMockIgnoreArg_context(UNITY_LINE_TYPE cmock_line);
#define device_get_binding_IgnoreAndReturn(cmock_retval) device_get_binding_CMockIgnoreAndReturn(__LINE__, cmock_retval)
void device_get_binding_CMockIgnoreAndReturn(UNITY_LINE_TYPE cmock_line, const struct device* cmock_to_return);
#define device_get_binding_StopIgnore() device_get_binding_CMockStopIgnore()
void device_get_binding_CMockStopIgnore(void);
#define device_get_binding_ExpectAndReturn(name, cmock_retval) device_get_binding_CMockExpectAndReturn(__LINE__, name, cmock_retval)
void device_get_binding_CMockExpectAndReturn(UNITY_LINE_TYPE cmock_line, const char* name, const struct device* cmock_to_return);
#define device_get_binding_IgnoreArg_name() device_get_binding_CMockIgnoreArg_name(__LINE__)
void device_get_binding_CMockIgnoreArg_name(UNITY_LINE_TYPE cmock_line);
#define z_device_get_all_static_IgnoreAndReturn(cmock_retval) z_device_get_all_static_CMockIgnoreAndReturn(__LINE__, cmock_retval)
void z_device_get_all_static_CMockIgnoreAndReturn(UNITY_LINE_TYPE cmock_line, size_t cmock_to_return);
#define z_device_get_all_static_StopIgnore() z_device_get_all_static_CMockStopIgnore()
void z_device_get_all_static_CMockStopIgnore(void);
#define z_device_get_all_static_ExpectAndReturn(devices, cmock_retval) z_device_get_all_static_CMockExpectAndReturn(__LINE__, devices, cmock_retval)
void z_device_get_all_static_CMockExpectAndReturn(UNITY_LINE_TYPE cmock_line, const struct device** devices, size_t cmock_to_return);
#define z_device_get_all_static_ReturnThruPtr_devices(devices) z_device_get_all_static_CMockReturnMemThruPtr_devices(__LINE__, devices, sizeof(const struct device*))
#define z_device_get_all_static_ReturnArrayThruPtr_devices(devices, cmock_len) z_device_get_all_static_CMockReturnMemThruPtr_devices(__LINE__, devices, cmock_len * sizeof(*devices))
#define z_device_get_all_static_ReturnMemThruPtr_devices(devices, cmock_size) z_device_get_all_static_CMockReturnMemThruPtr_devices(__LINE__, devices, cmock_size)
void z_device_get_all_static_CMockReturnMemThruPtr_devices(UNITY_LINE_TYPE cmock_line, const struct device** devices, size_t cmock_size);
#define z_device_get_all_static_IgnoreArg_devices() z_device_get_all_static_CMockIgnoreArg_devices(__LINE__)
void z_device_get_all_static_CMockIgnoreArg_devices(UNITY_LINE_TYPE cmock_line);
#define z_device_is_ready_IgnoreAndReturn(cmock_retval) z_device_is_ready_CMockIgnoreAndReturn(__LINE__, cmock_retval)
void z_device_is_ready_CMockIgnoreAndReturn(UNITY_LINE_TYPE cmock_line, bool cmock_to_return);
#define z_device_is_ready_StopIgnore() z_device_is_ready_CMockStopIgnore()
void z_device_is_ready_CMockStopIgnore(void);
#define z_device_is_ready_ExpectAndReturn(dev, cmock_retval) z_device_is_ready_CMockExpectAndReturn(__LINE__, dev, cmock_retval)
void z_device_is_ready_CMockExpectAndReturn(UNITY_LINE_TYPE cmock_line, const struct device* dev, bool cmock_to_return);
#define z_device_is_ready_IgnoreArg_dev() z_device_is_ready_CMockIgnoreArg_dev(__LINE__)
void z_device_is_ready_CMockIgnoreArg_dev(UNITY_LINE_TYPE cmock_line);
#define device_is_ready_IgnoreAndReturn(cmock_retval) device_is_ready_CMockIgnoreAndReturn(__LINE__, cmock_retval)
void device_is_ready_CMockIgnoreAndReturn(UNITY_LINE_TYPE cmock_line, bool cmock_to_return);
#define device_is_ready_StopIgnore() device_is_ready_CMockStopIgnore()
void device_is_ready_CMockStopIgnore(void);
#define device_is_ready_ExpectAndReturn(dev, cmock_retval) device_is_ready_CMockExpectAndReturn(__LINE__, dev, cmock_retval)
void device_is_ready_CMockExpectAndReturn(UNITY_LINE_TYPE cmock_line, const struct device* dev, bool cmock_to_return);
#define device_is_ready_IgnoreArg_dev() device_is_ready_CMockIgnoreArg_dev(__LINE__)
void device_is_ready_CMockIgnoreArg_dev(UNITY_LINE_TYPE cmock_line);

#if defined(__GNUC__) && !defined(__ICC) && !defined(__TMS470__)
#if __GNUC__ > 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ > 6 || (__GNUC_MINOR__ == 6 && __GNUC_PATCHLEVEL__ > 0)))
#pragma GCC diagnostic pop
#endif
#endif

#endif

My ruby command is (again project specifics, as I have cmock in tools/unittestframework/tools/cmock etc.:

ruby ./tools/unittestframework/tools/cmock/lib/cmock.rb --mock_path=unit_test/mockcomponents -otools/CMockConfig.yml template/device.h 

I see you have a lot of __wrap prefixes in your mock_device.h, so I am now kinda thinking how did that get in (because it is not in my file).

mvandervoord commented 1 year ago

cannot reproduce. :(