Mocking Opaque Types

Hi guys, another question here regarding Cmock and opaque types. I am currently trying to mock a function with an argument that contains the type "struct bt_conn". However when building this mock, I get the following error:

In file included from c:\nordicsemi\v2.5.0\test\cmock\vendor\unity\src\unity.h:21,
                 from c:\nordicsemi\v2.5.0\test\cmock\src\cmock_internals.h:10,
                 from c:\nordicsemi\v2.5.0\test\cmock\src\cmock.h:10,
                 from C:/PP_Unit_Tests/twister/ProPatch_test/unity.example_test/mocks/LWservice/cmock_lwl_service_support.c:4:
C:/PP_Unit_Tests/twister/ProPatch_test/unity.example_test/mocks/LWservice/cmock_lwl_service_support.c: In function '__cmock_on_sent':
C:/PP_Unit_Tests/twister/ProPatch_test/unity.example_test/mocks/LWservice/cmock_lwl_service_support.c:187:113: error: invalid application of 'sizeof' to incomplete type 'const struct bt_conn'
  187 |       { UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY((void*)(cmock_call_instance->Expected_conn), (void*)(conn), sizeof(const struct bt_conn), cmock_call_instance->Expected_conn_Depth, cmock_line, CMockStringMismatch); }
      |                                                                                                                 ^~~~~
c:\nordicsemi\v2.5.0\test\cmock\vendor\unity\src\unity_internals.h:941:198: note: in definition of macro 'UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY'
  941 | #define UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY(expected, actual, len, num_elements, line, message) UnityAssertEqualMemory((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(len), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_ARRAY)
      |                                                                                                                                                                                                      ^~~

 After doing some digging, it looks like struct bt_conn is an opaque type (I know very little about opaque types). Is there any way I can mock this function despite the use of an opaque type?

Parents
  • Hello Jesse,

    Thanks for providing the update; it's good to hear that you've made some progress. Let me know if I need to escalate this issue to get an expert opinion, as I am not an expert on this topic. Please note that there might be some delay in getting an update due to the summer vacation period in Norway.

    Kind regards,

    Abhijith

Reply
  • Hello Jesse,

    Thanks for providing the update; it's good to hear that you've made some progress. Let me know if I need to escalate this issue to get an expert opinion, as I am not an expert on this topic. Please note that there might be some delay in getting an update due to the summer vacation period in Norway.

    Kind regards,

    Abhijith

Children
No Data
Related