-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
da9289d
commit 0274082
Showing
261 changed files
with
233,438 additions
and
3,667 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
Checks: 'clang-diagnostic-*,clang-analyzer-*,-clang-analyzer-alpha*,*,-clang-analyzer-alpha.*,-cppcoreguidelines-pro-type-vararg,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-readability-implicit-bool-cast,-cppcoreguidelines-pro-bounds-constant-array-index,-google-runtime-reference,cppcoreguidelines-owning-memory' | ||
FormatStyle: file | ||
|
||
# Checks to use with "clang-tidy -fix": google-readability-namespace-comments,hicpp-braces-around-statements,modernize-use-equals-default,modernize-use-nullptr,llvm-include-order,modernize-redundant-void-arg,readability-implicit-bool-conversion,readability-redundant-member-init | ||
|
||
# Warnings to fix: | ||
# cppcoreguidelines-pro-type-member-init | ||
# readability-named-parameter | ||
# google-build-using-namespace | ||
# | ||
# maybe pro-bounds-pointer-arithmetic but may be required by cython |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,3 +37,5 @@ pysteps/steps/cysteps_mpi.cpp | |
.python-version | ||
|
||
.ipynb_checkpoints | ||
|
||
spconfig.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# /FindCLANG_TIDY.cmake | ||
# | ||
# This CMake script will search for clang-tidy and set the following | ||
# variables | ||
# | ||
# CLANG_TIDY_FOUND : Whether or not clang-tidy is available on the target system | ||
# CLANG_TIDY_EXECUTABLE : Fully qualified path to the clang-tidy executable | ||
# | ||
# The following variables will affect the operation of this script | ||
# CLANG_TIDY_SEARCH_PATHS : List of directories to search for clang-tidy in, | ||
# before searching any system paths. This should be | ||
# the prefix to which clang-tidy was installed, and | ||
# not the path that contains the clang-tidy binary. | ||
# Eg /opt/ not /opt/bin/ | ||
|
||
# Search for the canonical executable, then search for ones with | ||
# a version from newest to oldest. | ||
find_program(CLANG_TIDY_EXECUTABLE | ||
NAMES clang-tidy clang-tidy-6.0 clang-tidy-5.0 | ||
clang-tidy-4.0 clang-tidy-3.9 clang-tidy-3.8 | ||
clang-tidy-3.7 clang-tidy-3.6 clang-tidy-3.5 | ||
HINTS ${CLANG_TIDY_SEARCH_PATHS} | ||
) | ||
|
||
if(CLANG_TIDY_EXECUTABLE) | ||
set (CLANG_TIDY_FOUND TRUE) | ||
else() | ||
set (CLANG_TIDY_FOUND FALSE) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# - Enable Code Coverage | ||
# | ||
# Variables you may define are: | ||
# CODECOV_HTMLOUTPUTDIR - the name of the directory where HTML results are placed. Defaults to "coverage_html" | ||
# CODECOV_XMLOUTPUTFILE - the name of the directory where HTML results are placed. Defaults to "coverage.xml" | ||
# CODECOV_GCOVR_OPTIONS - additional options given to gcovr commands. | ||
# | ||
|
||
option(ENABLE_CODECOVERAGE "Enable code coverage testing support") | ||
|
||
if(ENABLE_CODECOVERAGE) | ||
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug") | ||
message(WARNING "Code coverage results with an optimised (non-Debug) build may be misleading") | ||
endif(NOT CMAKE_BUILD_TYPE STREQUAL "Debug") | ||
|
||
if(NOT DEFINED CODECOV_XMLOUTPUTFILE) | ||
set(CODECOV_XMLOUTPUTFILE coverage.xml) | ||
endif(NOT DEFINED CODECOV_XMLOUTPUTFILE) | ||
|
||
if(NOT DEFINED CODECOV_HTMLOUTPUTDIR) | ||
set(CODECOV_HTMLOUTPUTDIR coverage_html) | ||
endif(NOT DEFINED CODECOV_HTMLOUTPUTDIR) | ||
|
||
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCXX) | ||
foreach(exe gcov lcov gcovr) | ||
string(TOUPPER ${exe} exe_var) | ||
set(exe_var "CODECOV_${exe_var}") | ||
find_program(${exe_var} ${exe}) | ||
if(NOT ${exe_var}) | ||
message(SEND_ERROR "Could not find ${exe} executable") | ||
endif() | ||
endforeach() | ||
add_definitions(-fprofile-arcs -ftest-coverage) | ||
link_libraries(gcov) | ||
set(CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS} --coverage) | ||
add_custom_target( | ||
coverage_init | ||
${CODECOV_LCOV} --gcov-tool ${CODECOV_GCOV} --base-directory . | ||
--directory ${CMAKE_BINARY_DIR} --capture --initial | ||
) | ||
string(REPLACE " " ";" codecov_gcovr_opts "${CODECOV_GCOVR_OPTIONS}") | ||
set(CODECOV_GCOVR_BASECMD ${CODECOV_GCOVR} ${codecov_gcovr_opts} | ||
--gcov-executable ${CODECOV_GCOV} --root ${PROJECT_SOURCE_DIR}) | ||
add_custom_target( | ||
coverage | ||
${CODECOV_GCOVR_BASECMD} --xml --output ${CODECOV_XMLOUTPUTFILE} | ||
COMMAND mkdir -p ${CODECOV_HTMLOUTPUTDIR} | ||
COMMAND ${CODECOV_GCOVR_BASECMD} --html --html-details | ||
--output ${CODECOV_HTMLOUTPUTDIR}/index.html | ||
) | ||
endif(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCXX) | ||
endif(ENABLE_CODECOVERAGE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
# Testing | ||
|
||
This document contains the STEPS code testing guidelines. It should answer any | ||
questions you may have as an aspiring STEPS contributor. | ||
|
||
## Test suites | ||
|
||
STEPS has four test suites: | ||
|
||
* C++ unit tests located in `test/unit/cpp` | ||
* Python unit tests located in `test/unit/py` | ||
* Minimal integration tests in `test/validation` | ||
* Validation tests located in [CNS-OIST/STEPS_Validation](https://github.com/CNS-OIST/STEPS_Validation) | ||
repository. | ||
|
||
## Writing new tests | ||
|
||
Most code changes will fall into one of the following categories. | ||
|
||
### Writing tests for new features | ||
|
||
New code should be covered by unit tests. If the code is difficult to test with | ||
a unit tests then that is a good sign that it should be refactored to make it | ||
easier to reuse and maintain. | ||
|
||
### Writing tests for bug fixes | ||
|
||
Bugs fixes should include a unit test case which exercises the bug. | ||
|
||
A bug fix may also include new assertions in an existing integration tests for the | ||
API endpoint. | ||
|
||
### Validation tests | ||
|
||
FIXME: define guidelines | ||
|
||
## Running tests | ||
|
||
### Unit tests | ||
To run the unit test suite: | ||
|
||
``` | ||
cd /path/to/build/path | ||
make check | ||
``` | ||
|
||
To execute only one test: `ctest --output-on-failure -R TEST_NAME` | ||
|
||
### Integration tests | ||
|
||
To run the integration test suite, follow instructions of | ||
[CNS-OIST/STEPS_Validation](https://github.com/CNS-OIST/STEPS_Validation) | ||
repository. | ||
|
||
|
||
## Code Analysis | ||
|
||
### Code coverage | ||
|
||
Code coverage provides report to know how much the STEPS code is executed | ||
by unit tests. Analysis provides detailed reports in both HTML and XML | ||
showing the number of times every line of code is executed when running | ||
unit tests. | ||
|
||
### Requirements | ||
|
||
Following tools are required: gcov, lcov, gcovr | ||
|
||
#### Run coverage | ||
|
||
Compilation with gcc is required to perform code coverage. | ||
|
||
``` | ||
cd /path/to/STEPS | ||
mkdir _build && pushd _build | ||
cmake -DENABLE_CODECOVERAGE:BOOL=TRUE -DUSE_MPI:BOOL=False -DUSE_PETSC:BOOL=False -DCMAKE_BUILD_TYPE=Debug .. | ||
make -j all coverage_init test coverage | ||
``` | ||
|
||
Under the hood: | ||
|
||
1. `all`: compilation phase is different: every object file is attached to a .gcno file, | ||
containing information to reconstruct the basic block graphs and assign source line | ||
numbers to blocks. | ||
1. `coverage_init`: creates .gcda count data file for every .gcno, | ||
with counters reset to 0 | ||
1. `test`: counters in .gcda files are updating while executing the test suite. | ||
1. `coverage`: generate both XML and HTML reports based on .gcno and .gcda | ||
|
||
### Valgrind | ||
|
||
Valgrind is an instrumentation framework to build analysis from running applications. | ||
|
||
|
||
#### Instrument unit test suite | ||
|
||
It is strongly advise to run C++ unit-tests with valgrind memory checker activated. | ||
|
||
``` | ||
cd /path/to/STEPS | ||
mkdir _build && pushd _build | ||
cmake -DCMAKE_BUILD_TYPE=Debug -DVALGRIND=valgrind .. | ||
export VALGRIND_OPTS="--tool=memcheck --track-origins=yes --leak-check=full --show-leak-kinds=all --verbose" | ||
make test | ||
``` | ||
|
||
#### Selectively suppress errors | ||
|
||
Simply add suppression files to `test/ci/valgrind` directory with *.supp* extension | ||
to manually remove some warnings. | ||
|
||
#### Generate suppression files | ||
|
||
To generate a suppression file: | ||
1. Instrument your program with the following valgrind option: | ||
`--gen-suppressions=all --log-file=report.log` | ||
1. Extract all `{ }` sections from the log file your want to permanently ignore | ||
1. Put them in *.supp* files in `test/ci/valgrind/` directory. Typically, you should | ||
have one file per library or namespace. | ||
|
||
CMake won't detect that `test/ci/valgrind` has been modified, so it is required | ||
to run `cmake .` explicitly after adding or removing a *.supp* file. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.