Skip to content

Testing

Wesley Shillingford edited this page Jun 25, 2019 · 5 revisions

Testing

There are a number test binaries built when the -DNANO_TEST=ON CMake variable is set:

core_test - The majority of core functionality is tested here.
slow_test - Tests which operate on a large amount of data and so may take a while. Not currently tested by CI
rpc_test - This tests all RPC commands

To run all tests in a binary just launch it:
./core_test

To check a specific subset of tests, gtest filtering can be used (with optional wildcards):
./core_test --gtest_filter=confirmation_height.single
./rpc_test --gtest_filter=rpc.*

load_test - Launches many nodes and checks sending/receiving works with simultaneous calls. Example to send 150 blocks
./load_test -s 150

Sanitiziers

Nano supports 3 different CMake sanitizer options: NANO_ASAN_INT, NANO_TSAN and NANO_ASAN. They cannot be used in conjunction with each other

Thread sanitizer

Use -DNANO_TSAN=ON as an extra CMake option. When using the clang compiler this should be all that is necessary. When using gcc however the following environment variable should be set:
export TSAN_OPTIONS="suppressions=../tsan_suppressions"
tsan_suppressions should be a path to the file in the root nano directory. You must set this or see a lot of errors relating to the mdb library. The reason it is not needed with clang is that it supports -fsanitize-blacklist compiler option which we use with tsan_clang_blacklist via CMake.

Address sanitizer

Use the CMake variable -DNANO_ASAN=ON or -DNANO_ASAN_INT=ON before running a nano executable

Valgrind

Valgrind can be used to find other issues such as memory leaks. We have a valgrind suppressions file to remove some warnings. Valgrind can be run like so (there are many options available):
valgrind --leak-check=full --track-origins=yes --suppressions=../valgrind.supp ./core_test

You can’t perform that action at this time.