Giter Site home page Giter Site logo

tianzhaotju / leam Goto Github PK

View Code? Open in Web Editor NEW
25.0 2.0 3.0 5.57 MB

We propose a novel DL-based mutation technique (LEAM), which adapts the syntax-guided encoder-decoder architecture to build two sub-models based on AST information, for better learning to represent real faults and ensuring syntactic correctness of mutation faults.

Python 100.00%
deep-learning fault-injection mutation-testing

leam's Introduction

LEAM

LEAM adapts the syntax-guided encoder-decoder architecture by extending a set of grammar rules specific to our mutation task, to guarantee syntactic correctness of constructed mutation faults. It predicts the statements to be mutated under the context of the targeted method to reduce search space, and then predicts grammar rules for mutation fault construction based on both semantic and structural features in AST.

See Zhao Tian, Junjie Chen, et al. "Learning to Construct Better Mutation Faults." The 37th IEEE/ACM International Conference on Automated Software Engineering (ASE'22).

๐Ÿ† ACM SIGSOFT Distinguished Paper Award

1. Environment

  • Python 3.7
  • PyTorch 1.3
  • Defects4J V1.0
  • Java 8

2. A Demo

Pleas find our built model at this link. Download the model and place it in folder LEAM/checkpointSearch/. (If you need, you can download the raw data from this link.) We provide a demo to generate mutation faults for JFree Chart on fiexd version.

Please run CUDA_VISIBLE_DEVICES=0,1 python3 testDefect4jV1Fixed.py Chart-1 in the LEAM/ folder directory. The generated mutation faults are saved as JSON in the LEAM/mutants/ folder directory.

(1) CUDA_VISIBLE_DEVICES=0,1: specify two available GPUs. (2) Chart-1: project name and bug id.

3. Experiment Configuration

(1) LEAM: The corresponding location files are provided under the location2/ folder, which can help LEAM locate the function that needs to be mutated. You can easily follow the given example to design the location files for your mutated files. And you can use the default settings for the other hyper-parameters.

(2) Major: --DmutOp=tutorial.mml

tutorial.mml

targetOp{
    // Define the replacements for ROR
    BIN(>)->{>=,!=,FALSE};
    BIN(<)->{<=,!=,FALSE};
    BIN(>=)->{>,==,TRUE};
    BIN(<=)->{<,==,TRUE};
    BIN(==)->{<=,>=,FALSE,LHS,RHS};
    BIN(!=)->{<,>,TRUE,LHS,RHS};
    // Define the replacements for COR
    BIN(&&)->{==,LHS,RHS,FALSE};
    BIN(||)->{!=,LHS,RHS,TRUE};
    // Define the type of statement that STD should delete
    DEL(RETURN);

    // Enable the STD, COR, and ROR mutation operators
    STD;
    COR;
    ROR;
}
// Call the defined operator group for the target method
targetOp<"triangle.Triangle::classify(int,int,int)">;

(3) PITest: Version==1.7.4, --mutators=<mutators><mutator>ALL</mutator></mutators>

4. Experimental Results

(1) Distribution of real faults by the number of involved statements

drawing


(2) Ability of representing real faults interms of adequate test suites. (a) shows the result when using all the constructed mutation faults; (b)/(c) shows the result under controlling for the number of mutation faults when considering/ignoring DeepMutation (DM)

drawing


(3) Ability of representing mutation faults constructed by other mutation techniques. (a) shows the result when using all the constructed mutation faults; (b)/(c) shows the result under controlling for the number of mutation faults when considering/ignoring DeepMutation (DM)

drawing


(4) Correlation between mutation score and real fault detection

drawing


(5) Effectiveness comparison in mutation-based TCP when ignoring/considering Closure (detailed experimental data can be found in the experiment/tcp.csv folder)

(a) Ignoring Closure
drawing
(b) Considering Closure
drawing

(6) Effectiveness comparison in mutation-based FL when ignoring/considering Closure (detailed experimental data can be found in the experiment/fl.csv folder)

(a) Ignoring Closure
drawing
(b) Considering Closure
drawing

(7) Comparison effectiveness between LEAM and its variant w/o statement prediction (SP) in mutation-based TCP (Chart, Lang, Math, Time)

drawing

(8) Comparison effectiveness between LEAM and its variant w/o statement prediction (SP) in mutation-based FL (Chart, Lang, Math, Time)

drawing

(9) The influence of the number of mutation faults, which can be controlled by beam size, on mutation-based TCP (Chart)

drawing

(10) The influence of the number of mutation faults, which can be controlled by beam size, on mutation-based FL (Chart)

drawing

4. Acknowledgement

We are very grateful that the authors of TreeGen and Recoder make their code publicly available so that we can build this repository on top of their code.

This work was partially supported by the National Natural Science Foundation of China Grant No. 62002256, and National Science Foundation under Grant Nos. CCF-2131943 and CCF-2141474.

Feel free to contact Zhao Tian (tianzhao[AT]tju[DOT]edu[DOT]cn) and Junjie Chen (junjiechen[AT]tju[DOT]edu[DOT]cn) if you have any further questions.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.