In this tutorial we will explain some basic use of Concuerror to analyze a few tests written for the Poolboy library.
- Setting up Concuerror, Poolboy and our first test
- Start testing!
Setting up Concuerror, Poolboy and our first test
Setting up Concuerror
The first step is to download and make Concuerror as described in the Download page.
For the rest of the tutorial we will assume that the
is in our path. For example, to get help for all of Concuerror’s options we just
Setting up Poolboy
We will be using version
1.2.2 of Poolboy.
We will be using the sample worker used in Poolboy’s own tests, so we should
make the tests as well:
We don’t care about the actual result of the tests, but we now have a
.eunit directory with
No special compilation needed
Notice that we don’t need to compile anything in a special way. Concuerror will intercept calls to any module that is in Erlang’s code path and instrument the code before our test reaches it.
Our first test
Concuerror explores all the interleavings of an arbitrary execution scenario of a program with a single entry point. We will be extracting tests from Poolboy’s own test suite.
Let’s begin with an adapted version of the start/stop test, which we save as
We don’t have to compile our test, as Concuerror can also analyze
which are instrumented and compiled before the test starts.
We are now ready to…
We now have our application code compiled and ready to go, and have written a
small test. Next, we have to tell Concuerror to compile and load our test file
-f) and then start testing from module
poolboy_tests_1, calling function
pool_startup, which must have zero
Several lines should be printed on our screen. Let’s focus on a few of them:
The output file
Concuerror mainly produces a textual log, saved by default as
concuerror_report.txt. You can specify a different filename with the
Log messages tagged as Info are standard, normal operation messages. Here, Concuerror reports that it compiled and instrumented our test file and started to run the test.
Concuerror can detect which modules are being used by the test, and instruments
them automatically. You can see a few of them listed above.
io_lib is also
included, for reasons that are not important to explain right now.
Log messages tagged as Warnings are non-critical, notifying about weak support for some feature or the use of an option that alters the output
Log messages tagged as Tips are also non-critical, notifying of a suggested refactoring or option that can be used to make testing more efficient.
The interesting bits!
By default, Concuerror will stop exploration on the first error it encounters.
In this particular case, it seems that in the very first interleaving we managed
to trigger some behavior that the tool considers problematic. If we take a look
at the output file
concuerror_report.txt, we will see something like the
-pa to add directories in Erlang’s code path
Whoops! We forgot to add the
poolboy_test_worker module to Erlang’s code
path. Concuerror uses the
--pa option for this (notice the two dashes).
Running it again…
Three tips and the same error. This time however,
contains something like:
This behavior seems to be expected within the context of the test. Find out why Concuerror reports it as problematic in the next part of this tutorial.