-
Notifications
You must be signed in to change notification settings - Fork 74
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
Mull cannot run CTest's tests #794
Comments
In upcoming cmake release it will be possible to run all testcases in a single test run Kitware/CMake@3f6ff4b (I think it will be helpful if Mull's authors will decide to support tests generated by CMake.) |
What is the correct way to use mull with cmake/ctest? If for example this ok:
It is not clear if the subsequent call to
( and neither I understand if when I run on individual files, the reports are relevant, since only one test at a time is being checked instead of all at the same time. https://gitlab.com/correaa/boost-multi/-/jobs/8455957522#L1519 In particular I don't understand what happens when the test to a library are distributed across several .cpp/execuable files. |
Hi @correaa, thank you for the feedback and questions!
There is no easy way to integrate Mull into ctest seamlessly.
No, at this point ctest runs the test targets just as normal programs and Mull is not involved in any way. I just implemented a standalone reporter tool which works with an SQLite report, and which enables use cases like ctest and multiple test targets. You can find a usage example #1073 I'll release a new version with proper packages later this week, but if you want to give it a try you can pick one of the nightly builds. General idea is as follows:
Each I hope it helps, please do not hesitate to reach out if you have any questions/feedback. |
Added a short tutorial here https://mull.readthedocs.io/en/0.24.0/tutorials/CTestIntegration.html Feel free to reopen or create a new issue if there is a better way to integrate Mull into CTest. |
Thanks Alex for adding this material. I am wondering if there is a flaw in the way you show how integrate with Ctest. I have a template library and it seems that the mutations that are generated for each executable (each test) depend only the part of the code that is being tested. I am very confused, but this is what I am doing now and seem to be working: This is probably doing more work than needed (the number of executions is n^2), but I think it covers more (all?) mutations, also a key is to execute Maybe I am compiling in the wrong way, or maybe there something else to take into account for libraries that use template code? |
I haven't looked into your setup deeply yet, but it sounds like your understanding and observations are correct.
Could you please expand a bit on which part is confusing? |
I was just trying to say that I wasn't sure if I was doing something technical wrong (command line options) or if my logic was flawed. It is not intuitive yet to me to think in terms of mutation testing, because it is like talking in "double negatives" :) |
This is the full setup:
https://gitlab.com/correaa/boost-multi/-/blob/clang17-mull/.gitlab-ci.yml?ref_type=heads#L228-232 |
Yeah, it makes sense this way. Can you run an individual test binary instead of using Something like |
ok, I am doing that already. What about the rest of the line? (
|
You don't need It should work with I hope it makes sense, sorry if that's still confusing 🙌 |
What I am finding is that if I don't run ctest for each executable then I get a lot surviving mutants. I think this is because each executable individually doesn't test the whole library. Can you help me confirm this? Maybe there is something wrong with my setup also. |
The diagnosis is fairly simple, with my library, if I run this naive line I get surviving mutants, (ls test/*.x | xargs -n 1 sh -c 'echo $0 && ((mull-runner-16 $0) || exit 255)')
But if I run this line instead there are no survivors,
My interpretation is that each executable test is informed by the runner of only some of the mutants, but all the test still need to be run for each set of mutations associated with a single executable, and no single executable is testing all the mutants. This is the full configuration: git clone https://github.com/correaa/boost-multi.git
cd boost-multi
mkdir -p .build.clang++.mull
cd .build.clang++.mull
CXX=clang++-16 cmake .. -DCMAKE_CXX_FLAGS="-O1 -fpass-plugin=/usr/lib/mull-ir-frontend-16 -g -grecord-command-line -fprofile-instr-generate -fcoverage-mapping"
cmake --build .
ls test/*.x | xargs -n 1 sh -c 'echo $0 && ((mull-runner-16 $0 -test-program=ctest -- -j2 --stop-on-failure) || exit 255)') Please advise. |
@correaa, this is precisely what's happening there. You can still run things separately, collect intermediate results, and then run analysis, like in this example https://mull.readthedocs.io/en/0.24.0/tutorials/MultipleTestTargets.html |
ok, I am going to try it. What I am trying to figure out is how to "decorate" the run commands executed by ctest, so to call with the mull-runner. I couldn't make that work. It is not simple: https://stackoverflow.com/questions/79207944/adding-a-prefix-command-to-all-ctest-executions |
I am afraid I am not doing things correctly to use the database method, I still get surviving mutants, even after aggregating the results: https://gitlab.com/correaa/boost-multi/-/jobs/8743460604#L5351 This is the old method that works (although it is N^2 and slower) https://gitlab.com/correaa/boost-multi/-/jobs/8743460603 Could the fact that the code makes use of heavy templating the cause of this problem? |
This certainly deserves a closer look, I'll dig into it to see where the problem is coming from. It could very well be a bug with Mull, the aggregating results is a very new feature, so it wasn't heavily exercized yet. @correaa thank you for all the feedback, this is greatly appreciated! |
I just picked a random surviving mutant from https://gitlab.com/correaa/boost-multi/-/jobs/8743460604#L5414, applied it manually and all the tests passes: diff --git a/include/boost/multi/detail/layout.hpp b/include/boost/multi/detail/layout.hpp
index 5aa94da0..0faa9bfb 100644
--- a/include/boost/multi/detail/layout.hpp
+++ b/include/boost/multi/detail/layout.hpp
@@ -377,7 +377,7 @@ template<> struct extensions_t<1> : tuple<multi::index_extension> {
idx = get<0>(this->base()).back();
return true;
}
- --idx;
+ ++idx;
return false;
} It could be that the ctest runs show the wrong results and the mutants you are seeing now are actually survived/not detected.
Perhaps I should turn the warning into an actual error to prevent this confusion, sorry about that! 😅 |
ups, I shared the CI link before it finished. Now neither of the two methods works. It worked before: https://gitlab.com/correaa/boost-multi/-/jobs/8734666344 I am afraid there is indeterminism in these tests, maybe because of the timeouts. |
CMake allows to generate binaries with unit tests from a C functions and these tests supports special protocol to run testcases [1].
To run a single testcase one need to execute a binary and choose a number of testcase:
or run specify arbitrary name of testcase to run:
Also there was a MR to run all testcases at once [2], but it was not merged to a master though.
FreeRDP project actively uses tests written to run with CTest. Test failed with timeout when running using Mull because Mull don't know that test expects an input with a number of testcase.
The text was updated successfully, but these errors were encountered: