On Friday, 22 December 2023 08:33:08 CET Andreas Schneider wrote:
On Wednesday, 20 December 2023 15:49:44 CET Thomas Brinker wrote:
Dear CMocka-Team,
Hi Thomas,
Ping! :-)
we use the cmocka framework in unit-testing of our opensource tools and
found some things that would be very useful as extensions for it: thank you very much for reaching out!
* Mocking can be turned on on runtime * Differentiation of wrap and weak mocking * Handling of static and shared linking * Macros to convenient create mocks * Macros to create setup-, teardown- and test function-prototypes in a consistent & convenient way for a given function. * some additional convenient macros (see. https://github.com/Elektrobit/cmocka_extensions/blob/main/src/cmocka_exten si ons/include/cmocka_extensions/cmocka_extensions.h)
like
`will_set_parameter` for output parameter or `will_set_errno`. * ...
I'd like to invite you to have look at
https://github.com/Elektrobit/cmocka_extensions especially https://github.com/Elektrobit/cmocka_extensions/blob/main/documentation/do cu mentation.md
Do you expect this to be useful? Is this something that should become part of cmocka or stay as a separate extension?
I always want to improve cmocka and the best is if people using cmocka contribute code back!
First, please take a look at the master branch. It has some big changes to always use uintmax_t (C99) and other integer types.
I'm happy to discuss integrating the stuff you created. If you want we can have a phone call beforehand. The way to go is to create *small* merge requests on gitlab: https://gitlab.com/cmocka/cmocka
We can then integrate things step by step and improve them on the way if needed. Note that cmocka is unit-testing library. So each feature being added needs to be covered by unit tests.
I just had a quick look. We could add nearly everything from cmocka_extensions.h. However it needs to be cleaned up, protected and probably documented.
Just something catched my eye:
assert_non_null_msg(void *ptr, const char *msg) calls free on a NULL pointer. Why?
Additionally to these extensions we have created some mocks for jsonc, libc, libmnl, openssl. Which can be found here:
I will take a look.
Same questions as above apply.
Best regards
Andreas
Kind regards Thomas Brinker
-- Andreas Schneider asn@cryptomilk.org GPG-ID: 8DFF53E18F2ABC8D8F3C92237EE0FC4DCC014E3D