Skip to content

Code quality and memory

Besides the numerical results, the testbench checks the code itself.

Check What it does Fails on
build warnings every case is built with -Wall; the build output is checked any compiler warning
FORMAT clang-format check of src/ against .clang-format, and a check for CRLF line endings an unformatted file, CRLF line endings, clang-format missing
TIDY clang-tidy analysis of src/ against a reviewed baseline a finding that is not in the baseline
VALGRIND valgrind memcheck of two DEM runs (optional) a memory error or leak

Zero-warning builds

Every case of the testbench is a fresh Debug build, and a build with a single compiler warning is reported as WARNINGS in RESULTS.txt and counts as a failure. The warnings are listed per case and configuration in MAKE-ISSUES.txt. Because the cases are built with different compile options and libraries, this covers many configurations of the code. A build without MFTL2 is checked by the non-front-tracking cases; to check it on its own, use testcases/TESTS/check_nomftl_build.sh.

FORMAT: source formatting

A read-only check that every file under src/ matches the formatting rules in .clang-format, and that no tracked text file has Windows (CRLF) line endings. The diffs are written to ISSUES.txt and the names of the unformatted files to AFFECTED-FILES.txt. To format these files, run testcases/TESTS/fix_clang_formatting.sh by hand (it rewrites the files; the testbench itself never does). The result can depend on the version of clang-format.

TIDY: static analysis

clang-tidy analyses every source file of src/ with the checks of the repository's .clang-tidy, in two configurations: without the optional libraries, and with MFTL2 and IRL (clang-tidy only sees the code that a configuration compiles). Nothing is built. The findings are compared with testcases/TESTS/clang-tidy-baseline.txt, a reviewed list of accepted findings (mostly false positives of the analyser). Any other finding fails the case and is listed in TIDY-ISSUES.txt; findings of the baseline that have disappeared are reported as a NOTE, so that the baseline can be reduced.

A new finding is to be fixed, or reviewed and found to be a false positive, before it is added to the baseline.

VALGRIND: memory checks

Two DEM runs of 10 time-steps under valgrind (memcheck):

  • the multi-sphere case on 1 rank (bodies, STL walls, rolling resistance, wear, the removal of bodies);
  • the sphere case on 2 ranks (migration of particles between processors, ghost exchange).

The runs fail on any memory error (invalid read or write, use of an uninitialised value, invalid or mismatched free) and on any definitely or indirectly lost memory block, except the blocks allocated by the initialisation of MPI and PETSc. MultiFlow runs with -malloc_debug false, so that a leaked PetscMalloc block is reported by valgrind instead of being kept on PETSc's list.

This check is optional. It needs valgrind and a PETSc build for it: the arch given by VALGRIND_PETSC_ARCH, or a PETSc arch whose name ends in valgrind (built with -O0 and without AVX-512, which valgrind does not support). Without them, the case is recorded as SKIPPED.