CARLsim
5.0.0
CARLsim: a GPU-accelerated SNN simulator
|
In order to ensure that the addition of new functionality did not compromise the existing code base, CARLsim comes with a regression suite, which relies on the Google Test framework.
The Google Test framework is included in the CARLsim package as an external dependency. If you cloned the CARLsim repo using the –recursive
flag, you already have a local copy of the Google Test codebase (see 1.2 Installation).
If you forgot to include the –recursive
flag, you might encounter an empty directory when you navigate to external/googletest
. If this is the case, you have to initialize the submodule yourself. Simply navigate to the CARLsim root directory and run the following:
Google Test can be installed with the help of CMake, per the following recipe:
build
: And done!
Once you have downloaded and compiled the Google Test framework, all CARLsim test cases can be compiled and run from the CARLsim root directory:
Similary, if you installed CARLsim without GPU support, or if you want to exclude all GPU tests from the suite, run:
results/
directory to run.This should produce output like the following, possibly all green:
If you wish to contribute a new feature to CARLsim, you are expected to provide code that appropriately tests the new functionality.
Tests are grouped into different test cases, such as Interface
, Core
, CUBA
, etc. Identify the right test case depending on the topic your new feature belongs to:
core
: All core functionality that involves running the whole CARLsim pipeline.CUBA
/COBA
: Functionality that is specific to either CUBA or COBA mode.Interface
: Everything related to the CARLsim API.SpikeMon
/ConnMon
/GroupMon
: Everything related to Spike, Connection, or Group Monitors.STDP
/STP
: Everything related to STDP or STP.Compartments
: Everything related to compartmental models.Every test is wrapped into some Google Test syntax:
where the name of your test (testName
) belongs to a certain test case (or group of tests, testCase
).
Within this code block, you can write whatever CARLsim network you want.
After a network is run, you want to make sure its output is correct. This is achieved via Google Test-provided assertions such as:
EXPECT_EQ
: Expects to variables to be equal. For example: a
to be equal to 4.EXPECT_LT
: Expects the first variable to be smaller than the second. For example: a
to be smaller than 10.All Google Test function calls are described here.
If you write tests that expect the program to die (i.e., raise an Exception) in combination with EXPECT_DEATH
, make sure the test is run in thread-safe mode by adding the following decorator:
If you are on a Linux machine, it is also fairly simple to generate a code coverage report using gcov
. It's a bit harder on Mac OS X, but it can be done.
Simply follow the following procedure:
release_nocuda_coverage
, debug_coverage
, or debug_nocuda_coverage
.nocuda
option, make sure to run test_nocuda_coverage
..gcda
files, which can now be investigated. The easiest way to do this is to use lcov
and generate a HTML report: