:'######:::'#######::'########::'##::: ##:'########:'##:::::::'####:'##::::'##::'######::
:##... ##:'##.... ##: ##.... ##: ###:: ##: ##.....:: ##:::::::. ##:: ##:::: ##:'##... ##:
:##:::..:: ##:::: ##: ##:::: ##: ####: ##: ##::::::: ##:::::::: ##:: ##:::: ##: ##:::..::
:##::::::: ##:::: ##: ########:: ## ## ##: ######::: ##:::::::: ##:: ##:::: ##:. ######::
:##::::::: ##:::: ##: ##.. ##::: ##. ####: ##...:::: ##:::::::: ##:: ##:::: ##::..... ##:
:##::: ##: ##:::: ##: ##::. ##:: ##:. ###: ##::::::: ##:::::::: ##:: ##:::: ##:'##::: ##:
:'######::. #######:: ##:::. ##: ##::. ##: ########: ########:'####:. #######::. ######::
:......::::.......:::..:::::..::..::::..::........::........::....:::.......::::......:::
Cornelius is an equivalent mutant detection framework for Java. Cornelius uses the egg Egraph framework to efficiently detect equivalent and redundant mutants. Cornelius is currently outfitted to work automatically with the Major mutation framework.
To install Cornelius you'll need an up to date version of
cargo
and
Java 8 (Java 8 is required for Major which generates mutants. If mutants are
already generated, you can ignore this dependency).
Once you have cargo
installed, run ./init.sh
from the root of the directory.
This will build a release version of Cornelius and set up the framework/
directory with various libraries that Cornelius needs for mutation and
serialization:
-
The Major mutation framework: Cornelius uses Major to mutate Java sources
-
Java AST Regularizer: This regularizes a Java AST. This means that control flow is simplified so that
- There is exactly one return per method
- There are no break or continue statements
- Null checks are done explicitly
So far not all of these are implemented in the regularizer yet (but will be soon). Also, Cornelius will eventually do implicit regularization since explicitly constructing the AST seems to be expensive.
-
Serialization serializes a regularized AST into a PEG and outputs it to a file
To invoke the Cornelius framework on a Java source file, run
JAVA_HOME=/path/to/java-8-home ./cornelius.sh path/to/File.java
. This will:
- create a temporary directory
- invoke Major to mutate the Java file
- regularize and serialize the original program and each of its mutants
- run a rewrite system to detect equivalent and redundant mutants
- output discovered equivalence classes to disk
Each method in the input file is treated as its own subject.
Cornelius has several sample input programs in serializer/tests/subjects/
.
$ ./cornelius.sh serializer/tests/subjects/triangle/Triangle.java
Created temp working directory /var/folders/90/zz7ry2qd3m12wlsvjwr37kvh0000gn/T/cornelius-.2fh5oVQV
Generating mutants for /private/var/folders/90/zz7ry2qd3m12wlsvjwr37kvh0000gn/T/cornelius-.2fh5oVQV/Triangle.java
Generated 116 mutants (147 ms)
Regularizing subject /private/var/folders/90/zz7ry2qd3m12wlsvjwr37kvh0000gn/T/cornelius-.2fh5oVQV/Triangle.java to /private/var/folders/90/zz7ry2qd3m12wlsvjwr37kvh0000gn/T/cornelius-.2fh5oVQV/regularized
....................................................................................................................
================================================================================
[+] Visiting method signature: Triangle@classify(int,int,int)
[+] Source file: Triangle.java
[+] Name: classify(int,int,int)
Done creating XML File at: /Users/benku/Projects/cornelius/framework/scripts/subjects.xml
Serialized subjects file: /var/folders/90/zz7ry2qd3m12wlsvjwr37kvh0000gn/T/cornelius-.2fh5oVQV/Triangle.xml
Finished release [optimized] target(s) in 0.23s
Reading from path /var/folders/90/zz7ry2qd3m12wlsvjwr37kvh0000gn/T/cornelius-.2fh5oVQV/Triangle.xml
Equiv Classes:
Writing equivalence classes to /var/folders/90/zz7ry2qd3m12wlsvjwr37kvh0000gn/T/cornelius-.2fh5oVQV/equiv-classes:
/var/folders/90/zz7ry2qd3m12wlsvjwr37kvh0000gn/T/cornelius-.2fh5oVQV/equiv-classes/Triangle@classify(int,int,int).equiv-class
base: /Users/benku/Projects/cornelius
Linking to equivalence classes: /Users/benku/Projects/cornelius/Triangle-equiv-classes
To list the discovered equivalence classes, run:
$ cat Triangle-equiv-classes/Triangle@classify\(int,int,int\).equiv-class | grep " "
21 22 24 25
105 111 113 116
91 97 99
48 54 58 64 68
77 83 85
28 32
35 39
3 6 10 13 17
Each of these numbers corresponds to the mutant id generated by Major, and each line corresponds to a set of mutants discovered to be equivalent to one another. Thus, the first line means that mutants 21, 22, 23, and 24 are all semantically equivalent to one another. This means that Cornelius has discovered them to be in the same redundancy class.
A mutant id of 0 is reserved for the original program: the set of discovered
equivalent mutants are those mutants on the same line as the original program's
mutant id, 0
. The above run did not discover any equivalent mutants.
Triangle, as well as several of the other programs in
serializer/tests/subjects/
, have ground truth computed by hand in a gt
file.
Triangle's ground truth is:
$ cat serializer/tests/subjects/triangle/gt | grep " "
0 40 69 75 104
103 115
105 107 108 111 113 116
21 22 24 25
23 77 79 80 83 85 88
28 29 32
3 6 10 13 17
35 38 39
42 44 45 48 50 51 54 58 60 61 64 68 70
73 74
76 87
91 93 94 97 99 102