Skip to content

Commit

Permalink
add DNDEBUG test case
Browse files Browse the repository at this point in the history
  • Loading branch information
tbeltzun committed Sep 28, 2023
1 parent cbc417d commit 6c1cb39
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/coreComponents/unitTests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ add_subdirectory( fileIOTests )
add_subdirectory( fluidFlowTests )
add_subdirectory( wellsTests )
add_subdirectory( wavePropagationTests )
add_subdirectory( toolchain )
34 changes: 34 additions & 0 deletions src/coreComponents/unitTests/toolchain/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#
# Specify list of tests
#

set( gtest_geosx_tests
testDebug.cpp )

set( dependencyList ${parallelDeps} gtest )

if ( GEOSX_BUILD_SHARED_LIBS )
set (dependencyList ${dependencyList} geosx_core )
else()
set (dependencyList ${dependencyList} ${geosx_core_libs} )
endif()

#
# Add gtest C++ based tests
#
foreach(test ${gtest_geosx_tests})
get_filename_component( test_name ${test} NAME_WE )

blt_add_executable( NAME ${test_name}
SOURCES ${test}
OUTPUT_DIR ${TEST_OUTPUT_DIRECTORY}
DEPENDS_ON ${dependencyList} )

blt_add_test( NAME ${test_name}
COMMAND ${test_name} )

if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set_tests_properties(${test_name} PROPERTIES WILL_FAIL TRUE)
endif()

endforeach()
29 changes: 29 additions & 0 deletions src/coreComponents/unitTests/toolchain/testDebug.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* ------------------------------------------------------------------------------------------------------------
* SPDX-License-Identifier: LGPL-2.1-only
*
* Copyright (c) 2018-2020 Lawrence Livermore National Security LLC
* Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University
* Copyright (c) 2018-2020 Total, S.A
* Copyright (c) 2020- GEOS Contributors
* All right reserved
*
* See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details.
* ------------------------------------------------------------------------------------------------------------
*/

int main( int, char * * )
{
/*
* This test guards against spurious propagation of -DNDEBUG preprocessor flag (HDF5 in our case),
* which has the effect of disabling LvArray assertions:
* instead, we always check that this test fails in CMake Debug mode, whilst it should always
* pass in RelWithDebInfo or Release builds.
*/
#ifdef NDEBUG
return 0;
#else
return 1;
#endif

}

0 comments on commit 6c1cb39

Please sign in to comment.