5

I need an open source tool (even a relatively primitive one will do) which performs Mutation Testing on C++ code. I require it to be open source as I require to modify it in a proof of concept experiment.

I tried Googling it but did not come up with open source tools, I came up with this question, but the suggested tools in the answers are either not open source or do not mutate C++.

Community
  • 1
  • 1
cachiama
  • 590
  • 3
  • 19

2 Answers2

2

I presume that by "C++ code" you mean something that mutates the source code itself rather than a compiled version? Source code mutation is far harder to implement than intermediate code mutation (e.g. Java bytecode or .NET IL). Because of this, I strongly suspect that you won't find an open source one.

The challenge is to parse the source code into some form of syntax tree, a hard problem in C++, which will then allow you to identify mutation points and make the source code changes you need. You might like to take a look at GCCXML as an open source starting point for parsing - adding the mutation is actually the more straightforward part of the problem.

The open source NinjaTurtles (disclaimer: I am lead developer on this) will mutate assemblies compiled from .NET managed C++ code, but I suspect that won't be any good to you?

David M
  • 71,481
  • 13
  • 158
  • 186
  • I require to modify directly compiled C++ assemblies, so I doubt [NinjaTurtles](http://www.mutation-testing.net/) is adequate for me. I am willing to write the mutator myself but as a last resort (as apart from the relative high learning curve, I'm sure someone else has already done a better job). I have already implemented mutation on Java bytecode using the [BCEL library](http://commons.apache.org/bcel/) so I'm quite familiar with the process. Should I have to implemented the mutator myself, I would appreciate if I could get a couple of links to libraries which manipulate compiled C++ code. – cachiama Jul 04 '12 at 13:24
  • Fair enough, I suspected IL-level wasn't what you were after. Good luck! – David M Jul 04 '12 at 14:09
2

Have you looked into the Clang rewriter engine or their AST matchers? You can search for certain spots in the source code semantically, then apply transformations and recompile. It was designed for generic source to source tools and analysis.

It's a bit roll your own, but I think it is definitely workable.

Tim Seguine
  • 2,887
  • 25
  • 38