-
Notifications
You must be signed in to change notification settings - Fork 250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing header in mocked version #982
Comments
Using previous Ceedling there was no Module_private.h on test/mocks/ something strange is that this file now contains a single header
If I disable prepocessor on my configuration, only Module.h is now included in this test/mocks/Module_private.h but my STATIC functions are not parsed to remove the static keyword. |
I did a small example to reproduce this if you want to give it a try. On this example there is no more clock.h but the only header included in test/mocks/Timer_private.h is MyTypes.h instead of Timer.h |
I've tried a lot with different configurations and haven't found a solution, if anyone uses a similar module structure and you have a tip I'm interested =) |
Hi, @JuPrgn. Thank you for this report. I suspect it is largely related to the Ceedling issue you cited. I confess that I am having a little trouble following your report. The code structure and conventions you are using seem sensible and smart. I'm struggling to follow where the header files and other details that were previously working are no longer working. Could you kindly provide the following? (I apologize that this is not necessarily a small request.)
Ultimately, I suspect that you were getting “lucky” with 0.31. We've been on a winding path of finding the right way to do things with 1.0.0 that supports as many advanced scenarios as possible while also fixing a number of bugs in 0.31. In particular, we unknowingly regressed on |
Hi @mkarlesky, thanks for your interest in my problem. I hope I understood your requests, I removed the .hex and the artifacts folder in build, please let me know if I can provide something else or modify if I forgot something. You will find a folder with the project configured for version 0.31.0 I left the script folder with the command line that I execute through my Docker image (also available in the folder if needed). You will also find the same thing configured with version 1.0.0-9fc30fb. And below, following, the compilation outputs with verbosity at 4 for both projects: 0.31.0 Output :
1.0.0 Output :
It complains about : I noticed that in the generated I hope I was clearer, please let me know if I can help ! 2024-11-22_SimpleTest_0_31_0.zip |
Happy new year ! Just retested this simple project with latest release 2.6.0 but I still get Generated
Original
Output complains about unknown type Any hint on this ? Where could I find the generation of this header on Cmock sources or commits related to this change please ? |
Hi @JuPrgn -- I AM able to reproduce your problem. I'm digging into it. |
Hi again @JuPrgn . (1) I've fixed the bug that you were running into. The root problem is that the regex that was in charge of stripping out the paths from the header files was too greedy. If there were multiple consecutive includes with paths, it was clobbering all but the last. Yikes! You can find the fix here: 65ce792 Once this is fixed, there's a problem with "duplicate definitions" of some symbols. This one's on you. In your attached example, you have functions defined in Timer.h... and then you're mocking those same functions in the private header file. Once linked together, you have both versions. One way of fixing this is to replace
For tests, all your inline functions are defined as non-inline weak functions, allowing your mocks to replace them when linking. During release, they're normal inline functions. Let me know if you have further issues! |
Thank you very much @mvandervoord, I tested the first part and it works very well! Ultimately it was Ceedling's side and not Cmock. Okay for the second part I have quite a bit of code which uses this principle which worked well on the previous version of ceedling, the two parts were tested separately and I still obtain complete coverage with gcov of the two test files combined for the same source .c. I will adapt the structure of my projects to get the same functionalities with 1.0.0. Thanks for all the work you've done, the new version looks awesome and thanks for your great support! |
Hm. That's interesting that it worked in the previous release. I'm a little unclear how that could have been... I don't believe we were stripping inlines from the C file itself? The slicing of files into smaller testable parts is something we'd like to push further into (not just for inlines, but for static functions, etc). This entire idea will be getting more attention, but it's outside the scope of this issue. Thanks for helping us debug and improve! |
To answer your question, @JuPrgn, yes, the multiple |
@mvandervoord I did not know this was not a feature of Ceedling when I used it like that but this was working very well and then structured almost all my projects since to use this pseudo 2 abstraction layers for complex modules (some project features are already refactored in multiple submodules and I did not want to add another abstraction layer for functions that could be inlined as "private"). I will check how is it possible that this was working. @mkarlesky Thanks for the clarification. 😊 |
Hi,
I am currently switching from Ceedling 0.31 to 1.0.0 on a project that is already fully tested.
Usually my modules are arranged like that :
Module.c includes both Module.h and Module_private.h
Module_private.h include Module.h to get specific typedef
On my test files test_Module.c include Module.h and mock Module_private.h
This configurations was working with previous versions but on latest CMock (2.6.0) Module.h is not included in the mocked Module_private.h and the compiler complains about some types that are not defined (typedef structs from Module.h).
I generated a new project with latestCeedling pre-release to get default configuration yaml and then applied my old configuration following new documentation, maybe I missed something there ? Or this is no more achievable and there is now a better way to do it ?
The text was updated successfully, but these errors were encountered: