mull-project / mull

Practical mutation testing and fault injection for C and C++
https://mull.readthedocs.io
Apache License 2.0
751 stars 74 forks source link

No mutation for negate operator #842

Open ligurio opened 3 years ago

ligurio commented 3 years ago

Description

Mull supports mutations for negate operator. (see https://mull.readthedocs.io/en/latest/SupportedMutations.html)

$ cat example.c

int main() {
    int a = 2;
    if (!a)
        a = 4;

    return 0;
}

$ clang -fembed-bitcode -g example.c -o example $ mull-cxx ./example [info] Extracting bitcode from executable (threads: 1) [################################] 1/1. Finished in 0ms [info] Loading bitcode files (threads: 1) [################################] 1/1. Finished in 10ms [info] Sanity check run (threads: 1) [################################] 1/1. Finished in 4ms [info] Gathering functions under test (threads: 1) [################################] 1/1. Finished in 0ms [info] Applying function filter: no debug info (threads: 2) [################################] 2/2. Finished in 1ms [info] Applying function filter: file path (threads: 1) [################################] 1/1. Finished in 10ms [info] Instruction selection (threads: 1) [################################] 1/1. Finished in 1ms [info] Searching mutants across functions (threads: 1) [################################] 1/1. Finished in 10ms [info] Applying filter: no debug info (threads: 1) [################################] 1/1. Finished in 0ms [info] Applying filter: file path (threads: 1) [################################] 1/1. Finished in 0ms [info] Applying filter: junk (threads: 1) [################################] 1/1. Finished in 11ms [info] Deduplicate mutants (threads: 1) [################################] 1/1. Finished in 0ms [info] No mutants found. Mutation score: infinitely high [info] Total execution time: 50ms $

Version

sergeyb@pony:~/sources/mull_testing$ mull-cxx --version Mull: LLVM-based mutation testing https://github.com/mull-project/mull Version: 0.10.0-trunk1 Commit: 296ee8e Date: 10 Mar 2021 LLVM: 11.0.0

m42e commented 3 years ago

Well this seems like there is no not happening here. Clang just reverses the order of the branches in its bitcode:

if(!a)

becomes

br i1 %4, label %6, label %5, !dbg !18

See https://godbolt.org/z/1rT8Wrqrz

and

if(a)

becomes

br i1 %4, label %5, label %6, !dbg !18

It may be possible to add a "switch branch mutator".