This is the source tree for CutEr, a concolic unit testing tool for Erlang.
CAUTION: This tool is still under heavy development (and not yet released!)
In order to use the tool, you need the following programs:
- 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 Erlang/OTP source code or clone the Erlang/OTP github repository:
git clone https://github.com/erlang/otp.git
Then follow the instructions in INSTALL.md on building and installing Erlang/OTP.
- Python 2.x
Download and install the latest Python 2.x distribution.
- Z3 Theorem Prover
Download the latest Z3 stable distribution or clone the master branch of the source git repository:
git clone https://github.com/Z3Prover/z3.git
To install Z3, follow the instructions in the README file. Also, make sure that Z3Py (Python Interface) is installed.
[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
-
Download CutEr's sources or clone this repository:
git clone https://github.com/aggelgian/cuter.git -
Configure and compile CutEr. For a default build:
autoconf ./configure make depend make -
Optionally build and run the unit tests with
make utestand run Dialyzer withmake dialyzer -
Add CutEr's base directory to your Erlang library path by updating the
ERL_LIBSenvironment variable. Just addexport ERL_LIBS=/full/path/to/cuter:$ERL_LIBSto your shell startup file (e.g.
~/.bashrcfor Bash).
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).Go to the directory of the source file and compile it with debug information:
erlc +debug_info foo.erl
In order to test foo:bar/2 with CutEr, you will need a well-formed input that will act as a seed.
Let that be foo:bar([1], [2]).
CutEr can be invoked by calling the cuter:run/3 function, that is:
erl -noshell -eval "cuter:run(foo, bar, [[1], [2]])" -s init stop
and it reports 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
Mis the moduleFis the functionAsis the list of arguments of the seed input (indirectly denotes the arity ofF)
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!