Skip to content

Add Support for Applying Mutations Only at Given Mutation IDs #213

Open
@JonathanFoo0523

Description

The current implementation of Dredd applies all possible mutations to the entire C/C++ file. This could significantly impact the runtime performance of the program built from the mutated file, as there are substantial increases in branching and the invocation of dredd functions. This problem is magnified in large files.

We would like a Dredd mode that applies mutations only at specified IDs. For instance, when applying Dredd to the following C file with the command dredd sample.c --mutation-info-file temp.json

int main() {
    int foo = 0;
    foo = 1;
    foo += 2;
    return 0;
}

The mutated main function will be

int main() {
    int foo = __dredd_replace_expr_int_zero(0, 0);
    if (!__dredd_enabled_mutation(15)) { __dredd_replace_binary_operator_Assign_arg1_int_arg2_int(&(foo) , __dredd_replace_expr_int_one(1, 2), 5); }
    if (!__dredd_enabled_mutation(31)) { __dredd_replace_binary_operator_AddAssign_arg1_int_arg2_int(&(foo) , __dredd_replace_expr_int_constant(2, 16), 21); }
    if (!__dredd_enabled_mutation(34)) { return __dredd_replace_expr_int_zero(0, 32); }
}

We want a dredd mode which could be called with something like dredd sample.c --mutation-info-file temp.json --made-available-mutation="0, 15, 34" to produce mutated file with main as

int main() {
    int foo = __dredd_replace_expr_int_zero(0, 0);
    if (!__dredd_enabled_mutation(15)) {  foo = 1; }
    foo += 2;
    if (!__dredd_enabled_mutation(34)) { return 0; }
}

Note that mutation id 1 is made available too as a side effect.

@afd suggest this could be implemented by:

  • first does a "dry run" pass where it works out all the mutations that it could apply, and possibly even produces the output .json file with the mutation tree, but does not actually apply any mutations to the source code
  • second, does a "really mutate" pass where it reads from a file the ids of all mutants that should be made available, and then does its thing, but skipping any mutants with ids not on the list.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions