Giter Club home page Giter Club logo

cuter's Introduction

CutEr

This is the source tree for CutEr, a concolic unit testing tool for Erlang.

Build Status

CAUTION: This tool is still under heavy development (and not yet released!)

Licence

Copyright 2014-2015 by Aggelos Giantsios, Nikolaos Papaspyrou and Kostis Sagonas.

This program is distributed under the GPL, version 3 or later. Please see the COPYING file for details.

Dependencies

In order to use the tool, you need the following programs:

  1. Erlang/OTP

Note that using a pre-built package or binaries will not suffice if the library's modules have not been compiled with debug information. In that case, you will need to build and install Erlang/OTP from source.

Download the latest source code distribution of Erlang/OTP or clone the Erlang/OTP github repository:

    git clone https://github.com/erlang/otp.git

Then follow the instructions in INSTALL.md for building and installing Erlang/OTP.

  1. Python 2.x

Download and install the latest Python 2.x distribution.

  1. Z3 Theorem Prover

Download the latest Z3 release or clone the master branch of Z3 from its git repository:

    git clone https://github.com/Z3Prover/z3.git

To install Z3, follow the instructions in its README file. Also, make sure that Z3Py (Python Interface) is installed.

Installing

  • Download CutEr's sources or clone this repository:

      git clone https://github.com/aggelgian/cuter.git
    
  • [Optional] If you want to run the full test suite of CutEr, you will also need PropEr and meck. You can install them independently or go to CutEr's base directory and run:

      git submodule init && git submodule update
      git submodule foreach make
    
  • Configure and compile CutEr. For a default build:

      autoconf
      ./configure
      make depend
      make
    
  • [Optional] Now you can build and run the unit & functional tests with make test

  • [Optional] You can also run Dialyzer with make dialyzer

  • Add CutEr's base directory to your Erlang library path by updating the ERL_LIBS environment variable. Just add

      export ERL_LIBS=/full/path/to/cuter:$ERL_LIBS
    

    to your shell startup file (e.g. ~/.bashrc for Bash).

Usage

Let's say that you just wrote a simple module foo that just contains the exported function bar/2. The source file foo.erl is:

-module(foo).
-export([bar/2]).

-spec bar([number()], [number()]) -> number().
bar([], Ys) -> lists:sum(Ys);
bar([X|Xs], [Y|Ys]) -> X * Y + bar(Xs, Ys).

For single file tests, such as the above, the simplest way to run CutEr is to use the cuter script as follows:

./cuter foo erl '[[1], [2]]'

i.e. supply it with three arguments: the module name, the function name, and the list of arguments for the call that will act as a seed for the concolic execution of the unit under test. If there is no foo.beam file, the cuter script will automatically compile the foo.erl file and create a .beam file with debug information.

Alternatively, go to the directory of the source file and compile it with debug information:

erlc +debug_info foo.erl

CutEr can then be invoked by calling the cuter:run/3 function:

erl -noshell -eval "cuter:run(foo, bar, [[1], [2]])" -s init stop

This will report a list of inputs that lead to runtime errors, for example [1.0,2.0,0.0], [0,1].

To sum up, cuter:run/3 is called as cuter:run(M, F, As) where

  • M is the module
  • F is the function
  • As is the list of arguments of the seed input

There is also a cuter:run/4 function that takes these three arguments but also a numeric argument Depth that denotes the depth of the search (i.e. roughly the number of branches that will be explored). This depth can also be specified as an optional argument of the cuter script:

./cuter foo erl '[[1], [2]]' 42

CutEr provides more API functions that also come with options that control the concolic execution of Erlang programs. These will be explained in a set of forthcoming tutorials. In the meantime, you can find out about them by browsing the source code of CutEr.

Have fun with the tool!

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.