Skip to content

Commit 1dfc476

Browse files
Merge pull request diffblue#2789 from owen-jones-diffblue/doc/compilation-and-development
Update compilation and development docs
2 parents ef7e55b + 3f9d01f commit 1dfc476

File tree

2 files changed

+157
-57
lines changed

2 files changed

+157
-57
lines changed

COMPILING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,9 @@ helpful for GUI-based tasks, e.g., the class viewer, debugging, etc., and can
202202
be used for building with MSBuild. Note that you still need to run flex/bison
203203
using "make generated_files" before opening the project.
204204
205-
# WORKING WITH CMAKE (EXPERIMENTAL)
205+
# WORKING WITH CMAKE
206206
207-
There is an experimental build based on CMake instead of hand-written
207+
There is also a build based on CMake instead of hand-written
208208
makefiles. It should work on a wider variety of systems than the standard
209209
makefile build, and can integrate better with IDEs and static-analysis tools.
210210
On Windows, the CMake build does not depend on Cygwin or MinGW, and doesn't
Lines changed: 155 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,149 @@
11
\ingroup module_hidden
22
\page compilation-and-development Compilation and Development
33

4-
\author Martin Brain, Peter Schrammel
4+
\author Martin Brain, Peter Schrammel, Owen Jones
55

6-
## Makefiles ##
6+
\section compilation-and-development-section-compilation Compilation
77

8-
First off, read the \ref cbmc-user-manual "CBMC User Manual". It describes
9-
how to get, build and use CBMC. This document covers the
10-
internals of the system and how to get started on development.
8+
The CBMC source code is available on
9+
[its GitHub page](https://github.com/diffblue/cbmc).
1110

12-
## CMake files ##
1311

14-
To be documented.
12+
\subsection compilation-and-development-subsection-makefiles Makefiles
1513

16-
## Personal configuration: config.inc, macro DEBUG ##
14+
Instructions for compiling CBMC using makefiles are
15+
available in
16+
[COMPILING.md](https://github.com/diffblue/cbmc/blob/develop/COMPILING.md#what-architecture)
17+
in the root of the CBMC repository. They cover Linux, Solaris 11,
18+
FreeBSD 11, MacOS X and Windows.
1719

18-
To be documented.
1920

20-
## Running tests ##
21+
\subsection compilation-and-development-subsection-cmake-files CMake files
2122

22-
### Regression tests ###
23+
There is also support for compiling using CMake. Instructions are
24+
available in
25+
[COMPILING.md](https://github.com/diffblue/cbmc/blob/develop/COMPILING.md#working-with-cmake-experimental)
26+
in the root of the CBMC repository.
2327

24-
The regression tests are contained in the `regression/` folder.
25-
They are grouped into directories for each of the tools/modules.
26-
Each of these contains multiple directories, each of which contains
27-
input files and one or more `.desc` files that describe what command
28-
to run, what output is expected and so on. There is a Perl script,
29-
`test.pl` that is used to invoke the tests as:
3028

31-
../test.pl -c PATH_TO_CBMC
29+
\subsection compilation-and-development-subsection-personal-configuration Personal configuration
3230

33-
The `–help` option gives instructions for use and the
34-
format of the description files.
31+
\subsubsection compilation-and-development-subsubsection-config-inc config.inc
3532

36-
To be documented further.
33+
Two files,
34+
[config.inc](https://github.com/diffblue/cbmc/blob/develop/src/config.inc) and
35+
[common](https://github.com/diffblue/cbmc/blob/develop/src/common), are
36+
included in every makefile.
37+
[config.inc](https://github.com/diffblue/cbmc/blob/develop/src/config.inc)
38+
contains configuration options
39+
relating to compilation so that they can be conveniently edited in one place.
40+
[common](https://github.com/diffblue/cbmc/blob/develop/src/common)
41+
contains commands that are needed in every makefile but which the
42+
developer is not expected to edit. (There is also
43+
[another config.inc](https://github.com/diffblue/cbmc/blob/develop/jbmc/src/config.inc)
44+
which is also included in every makefile in the `jbmc` folder.)
3745

38-
### Unit tests ###
46+
Note, these files are not involved in the CMake build.
47+
3948

40-
To be documented.
49+
\subsubsection compilation-and-development-subsubsection-macro-debug Macro DEBUG
4150

42-
## Documentation ##
51+
If the macro `DEBUG` is defined during compilation of CBMC (for example by
52+
using a compiler flag) then extra debug code will be included. This includes
53+
print statements and code checking that data structures are as expected.
54+
55+
56+
\section compilation-and-development-section-running-tests Running tests
57+
58+
\subsection compilation-and-development-subsection-regression-tests Regression tests
59+
60+
The regression tests are contained in `regression/` and `jbmc/regression/`.
61+
Inside these folders there is a directory for each of the tools/modules. Each
62+
of these contains multiple test directories, with names describing
63+
what they test. When there are multiple tests in a test directory then
64+
they should all test very similar aspects of the program's behaviour. Each
65+
test directory contains input files and one or more test description files,
66+
which have the ending `.desc`. The test description files describe what command
67+
to run, what output is expected and so on. The test framework is a
68+
Perl script,
69+
[test.pl](https://github.com/diffblue/cbmc/blob/develop/regression/test.pl),
70+
located in `regression/test.pl`.
71+
72+
The `--help` option to `test.pl` outlines the
73+
format of the test description files. Most importantly, the first word in a
74+
test description file is its level, which is one of: `CORE` (should be run in
75+
CI, should succeed), `THOROUGH` (takes too long to be run in CI, should
76+
succeed), `FUTURE` (will succeed when a planned feature is added) or
77+
`KNOWNBUG` (will succeed when a bug is fixed).
78+
79+
\subsubsection compilation-and-development-subsubsection-running-regression-tests-with-make Running regression tests with `make`
80+
81+
If you have compiled using `make` then you can run the regression tests
82+
using `make test`. Run it from `regression/` to run all the regression tests,
83+
or any of its subfolders to just run the tests in that subfolder.
84+
85+
If you have not compiled using `make` then this won't work, because the
86+
makefile is expecting to find binaries like `cbmc` and `jbmc` in the source
87+
folders.
88+
89+
\subsubsection compilation-and-development-subsubsection-running-regression-tests-with-ctest Running regression tests with `ctest`
90+
91+
If you have compiled using CMake then you can run the regression tests (and
92+
the unit tests) using CTest.
93+
94+
Here are two example commands, to be run from the build directory:
95+
96+
ctest -V -L CORE -R cpp
97+
ctest -V -L CORE -R cpp -E cbmc-cpp
98+
99+
`-V` makes it print out more
100+
useful output. `-L CORE` makes it only run tests that have been tagged
101+
`CORE`. `-R regular_expression` can be used to limit which tests are run to
102+
those which match the given regular expression, and `-E regex` excludes tests
103+
to those which match the given regular expression.
104+
So the first command will run all the CORE tests in `regression/cbmc/cpp` and
105+
`regression/cbmc/cbmc-cpp`, and the second will run all the CORE tests in
106+
`regression/cbmc/cpp` only. Another useful option is `-N`, which makes CTest
107+
list which tests it will run without actually running them.
108+
109+
110+
\subsubsection compilation-and-development-subsubsection-running-regression-tests-directly-with-test-pl Running regression tests directly with `test.pl`
111+
112+
In a directory corresponding to a tool or module, you can directly run a
113+
test directory as follows:
114+
115+
../test.pl -c PATH_TO_CBMC_FROM_DESC_FILE TEST_DIR
116+
117+
Note that `PATH_TO_CBMC_FROM_DESC_FILE` should either be absolute or be
118+
relative to the location of the test description files. If `TEST_DIR` is
119+
not provided then all test directories are run.
120+
121+
122+
\subsection compilation-and-development-subsection-unit-tests Unit tests
123+
124+
The unit tests are contained in the `unit/` folder. They are written using the
125+
[Catch](https://github.com/philsquared/Catch) unit test framework.
126+
127+
To run the unit tests for CBMC, go to `unit/` and run
128+
129+
../<build-folder>/bin/unit
130+
131+
To run the unit tests for JBMC, go to `jbmc/unit/` and run
132+
133+
../../<build-folder>/bin/java-unit
134+
135+
The unit tests are also included in CTest as `unit` and `java-unit`.
136+
137+
Note that some tests run which are expected to fail - see the summary at
138+
the end of the run to see how many tests passed, how many failed which were
139+
expected to and how many tests failed which were not expected to.
140+
141+
For more information on the structure of `unit/` and how to tag tests, see
142+
[the section on unit tests in `Compiling.md` in the root of the CBMC
143+
repository](https://github.com/diffblue/cbmc/blob/develop/CODING_STANDARD.md#unit-tests)
144+
145+
146+
\section compilation-and-development-section-documentation Documentation
43147

44148
Apart from the (user-orientated) CBMC user manual and this document, most
45149
of the rest of the documentation is inline in the code as `doxygen` and
@@ -48,35 +152,31 @@ contained in the `doc/` directory and gives some options for these
48152
tools. All of these could be improved and patches are very welcome. In
49153
some cases the algorithms used are described in the relevant papers.
50154

51-
## Accessing doxygen documentation ##
52-
53155
The doxygen documentation can be [accessed online](http://cprover.diffblue.com).
54-
To build it locally, run `doxygen` in `/src`. HTML output will be created in
55-
`/doc/html`. The index page is `/doc/html/index.html`.
56-
57-
## Coding standards ##
58-
59-
See <a
60-
href="https://github.com/diffblue/cbmc/blob/master/CODING_STANDARD.md">
61-
`CODING_STANDARD.md`</a> file in the root of the CBMC repository.
62-
63-
CPROVER is written in a fairly minimalist subset of C++; templates and
64-
meta-programming are avoided except where necessary.
65-
External library dependencies are avoided (only STL and a SAT solver
66-
are required). Boost is not used. The `util` directory contains many
67-
utilities that are not (yet) in the standard library.
68-
69-
Patches should be formatted so that code is indented with two space
70-
characters, not tab and wrapped to 80 columns. Headers for doxygen
71-
should be given (and preferably filled!) and the author will be the
72-
person who first created the file. Add doxygen comments to
73-
undocumented functions as you touch them. Coding standards
74-
and doxygen comments are enforced by CI before a patch can be
75-
merged by running `clang-format` and `cpplint`.
76-
77-
Identifiers should be lower case with underscores to separate words.
78-
Types (classes, structures and typedefs) names must end with a `t`.
79-
Types that model types (i.e. C types in the program that is being
80-
interpreted) are named with `_typet`. For example `ui_message_handlert`
81-
rather than `UI_message_handlert` or `UIMessageHandler` and
82-
`union_typet`.
156+
To build it locally, run `doxygen` in `src/`. HTML output will be created in
157+
`doc/html/`. The index page is `doc/html/index.html`.
158+
159+
160+
\section compilation-and-development-section-formatting Formatting
161+
162+
The <a
163+
href="https://github.com/diffblue/cbmc/blob/develop/CODING_STANDARD.md">
164+
`CODING_STANDARD.md`</a> file in the root of the CBMC repository contains
165+
guidance on how to write code for the CBMC repository. This includes
166+
which language features can be used and formatting rules.
167+
168+
C++ code can be automatically reformatted in the correct way by running
169+
`clang-format`. There are more details in
170+
[CODING_STANDARD.md](https://github.com/diffblue/cbmc/blob/develop/CODING_STANDARD.md#using-clang-format).
171+
172+
173+
\section compilation-and-development-section-linting Linting
174+
175+
There is also a linting script, `scripts/cpplint.py`. There is a wrapper
176+
script to run `cpplint.py` only on lines that differ from another
177+
branch, e.g. to run it on lines that have been changed from `develop`:
178+
179+
scripts/run_lint.sh develop
180+
181+
There are also instructions for adding this as a git pre-commit hook in
182+
[CODING_STANDARD.md](https://github.com/diffblue/cbmc/blob/develop/CODING_STANDARD.md#pre-commit-hook-to-run-cpplint-locally).

0 commit comments

Comments
 (0)