add option to skip death tests for use with valgrind checking of unit tests
This commit is contained in:
@ -153,7 +153,12 @@ development headers to compile (if those are not found locally a recent
|
||||
version of that library will be downloaded and compiled along with
|
||||
LAMMPS and the test programs) and will download and compile a specific
|
||||
version of the `GoogleTest <https://github.com/google/googletest/>`_ C++
|
||||
test framework that is used to implement the tests.
|
||||
test framework that is used to implement the tests. Those unit tests
|
||||
may be combined with memory access and leak checking with valgrind
|
||||
(see below for how to enabled it). In that case, running so-called
|
||||
death tests will create a lot of false positives and thus they can be
|
||||
disabled by configuring compilation with the additional setting
|
||||
``-D SKIP_DEATH_TESTS=on``.
|
||||
|
||||
.. admonition:: Software version and LAMMPS configuration requirements
|
||||
:class: note
|
||||
|
||||
@ -28,6 +28,11 @@ add_library(GTest::GMock ALIAS gmock)
|
||||
add_library(GTest::GTestMain ALIAS gtest_main)
|
||||
add_library(GTest::GMockMain ALIAS gmock_main)
|
||||
|
||||
option(SKIP_DEATH_TESTS "Do not run 'death tests' to reduce false positives in valgrind" OFF)
|
||||
mark_as_advanced(SKIP_DEATH_TESTS)
|
||||
if(SKIP_DEATH_TESTS)
|
||||
add_compile_definitions(LAMMPS_SKIP_DEATH_TESTS)
|
||||
endif()
|
||||
# import
|
||||
foreach(_FLAG ${CMAKE_TUNE_FLAGS})
|
||||
add_compile_options(${_FLAG})
|
||||
|
||||
@ -32,6 +32,12 @@ using LAMMPS_NS::LAMMPSException;
|
||||
|
||||
using ::testing::ContainsRegex;
|
||||
|
||||
#if defined(LAMMPS_SKIP_DEATH_TESTS)
|
||||
#define TEST_FAILURE(errmsg, ...) \
|
||||
{ \
|
||||
; \
|
||||
}
|
||||
#else
|
||||
#define TEST_FAILURE(errmsg, ...) \
|
||||
{ \
|
||||
::testing::internal::CaptureStdout(); \
|
||||
@ -39,6 +45,7 @@ using ::testing::ContainsRegex;
|
||||
auto mesg = ::testing::internal::GetCapturedStdout(); \
|
||||
ASSERT_THAT(mesg, ContainsRegex(errmsg)); \
|
||||
}
|
||||
#endif
|
||||
|
||||
// whether to print verbose output (i.e. not capturing LAMMPS screen output).
|
||||
extern bool verbose;
|
||||
|
||||
Reference in New Issue
Block a user