Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add NDEBUG test - add build_test target - fix asserts #2721

Merged
merged 58 commits into from
Nov 29, 2023

Conversation

tbeltzun
Copy link
Contributor

@tbeltzun tbeltzun commented Sep 28, 2023

addition of a NDEBUG test

Add a test for the HDF5 propagated flags as explained in #2631 and #2699 or GEOS-DEV/thirdPartyLibs#248.

In Debug CMake configuration, if the DNDEBUG flag is propagated by any dependencies from the TPLs, this test should fail.

addition of a build_test target

It is well known (CMake limitation) that running make test doesn't build the tests and only tries to run them (see here).

There is no dedicated target to enable building all the unitests executables at once apart from running make all (which I want to avoid because it builds targets that I don't need from the C++ side).

This PR add a build_test target such that running make geosx build_test test builds geosx, the unitests, and runs the test suite.

remove erroneous assertion

Authored by @Algiane.

Description duplicated from #2699:

Note that this erroneous assertion is not detected by the ci due to the transfer of the NDEBUG flag of the hdf5 build toward the geos compilation flags through Conduit (see TPL PR #243 and Geos PR #2700 where the assertion is executed .)

Fixes #2700. Closes #2631.

enhance CMakeLists.txt consistency

  • correct indentation and spaces (inconsistent within a file);
  • replace set(dependencyList ${dependencyList} geosx_core) patterns with list(APPEND dependencyList geosx_core), which is more concise;
  • use unset(something) instead of set(something), for clarity;
  • remove tabs in CMakeLists.txt.

@tbeltzun tbeltzun self-assigned this Sep 28, 2023
@tbeltzun tbeltzun added type: bug Something isn't working ci: run CUDA builds Allows to triggers (costly) CUDA jobs flag: ready for review labels Sep 28, 2023
@tbeltzun tbeltzun force-pushed the bugfix/tbeltzun/ndebug branch from da06b90 to b3bfdfa Compare September 28, 2023 13:30
@tbeltzun tbeltzun changed the title add NDEBUG test - add unitests target add NDEBUG test - add unittests target Sep 28, 2023
@tbeltzun tbeltzun force-pushed the bugfix/tbeltzun/ndebug branch from b3bfdfa to f1860ef Compare September 28, 2023 14:29
@tbeltzun tbeltzun requested a review from wrtobin October 6, 2023 09:05
@tbeltzun tbeltzun removed the ci: run CUDA builds Allows to triggers (costly) CUDA jobs label Oct 6, 2023
Copy link
Collaborator

@wrtobin wrtobin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These both seem like sensible additions, and a good way to test against erroneous NDEBUG symbol propagation.

@wrtobin wrtobin added type: build system Build system issue ci: run CUDA builds Allows to triggers (costly) CUDA jobs and removed flag: ready for review labels Oct 6, 2023
@tbeltzun
Copy link
Contributor Author

tbeltzun commented Oct 9, 2023

CI is still behaving weirdly though, because according to #2631 (comment), this test should not pass at the moment (GEOS-DEV/thirdPartyLibs#243 / #2700 would be needed).

EDIT: it seems that the spurious -DNDEBUG preprocessor definition appears when building GEOS, but not when building the unit tests:

[1251/1254] /usr/bin/g++-10 -DDIY_NO_THREADS -DGTEST_HAS_DEATH_TEST=1 -DMPICH_SKIP_MPICXX -DMPI_NO_CPPBIND -DOMPI_SKIP_MPICXX -D_MPICC_H -Dkiss_fft_scalar=double -DtestNDEBUG_EXPORTS -I/tmp/build/include -I/tmp/GEOSX/src/coreComponents -I/opt/GEOS/GEOS_TPL-238-63-3c52641/pugixml/include -I/opt/GEOS/GEOS_TPL-238-63-3c52641/conduit/include -I/opt/GEOS/GEOS_TPL-238-63-3c52641/conduit/include/conduit -I/tmp/GEOSX/src/coreComponents/denseLinearAlgebra -I/tmp/GEOSX/src/coreComponents/constitutive/PVTPackage/PVTPackage/source -I/tmp/GEOSX/src/coreComponents/linearAlgebra -isystem /tmp/GEOSX/src/cmake/blt/thirdparty_builtin/googletest/googletest/include -isystem /usr/lib/x86_64-linux-gnu/openmpi/include/openmpi -isystem /usr/lib/x86_64-linux-gnu/openmpi/include -isystem /opt/GEOS/GEOS_TPL-238-63-3c52641/adiak/include -isystem /opt/GEOS/GEOS_TPL-238-63-3c52641/raja/include -isystem /opt/GEOS/GEOS_TPL-238-63-3c52641/chai/include -isystem /opt/GEOS/GEOS_TPL-238-63-3c52641/fmt/include -isystem /opt/GEOS/GEOS_TPL-238-63-3c52641/caliper/include -isystem /tmp/GEOSX/src/thirdparty/fast_float/include -isystem /opt/GEOS/GEOS_TPL-238-63-3c52641/mathpresso/include -isystem /opt/GEOS/GEOS_TPL-238-63-3c52641/parmetis/include -isystem /opt/GEOS/GEOS_TPL-238-63-3c52641/metis/include -isystem /opt/GEOS/GEOS_TPL-238-63-3c52641/scotch/include -isystem /opt/GEOS/GEOS_TPL-238-63-3c52641/vtk/include/vtk-9.2 -isystem /opt/GEOS/GEOS_TPL-238-63-3c52641/suitesparse/include -isystem /opt/GEOS/GEOS_TPL-238-63-3c52641/superlu_dist/include -isystem /opt/GEOS/GEOS_TPL-238-63-3c52641/trilinos/include -isystem /opt/GEOS/GEOS_TPL-238-63-3c52641/silo/include -isystem /opt/GEOS/GEOS_TPL-238-63-3c52641/hdf5/include -isystem /tmp/GEOSX/src/thirdparty/optionparser/src -Wall -Wextra       -Werror  -Wall -Wextra -Wpedantic -pedantic-errors -Wshadow -Wfloat-equal -Wcast-align -Wcast-qual   -fdiagnostics-color=always  -g -Wno-unused-parameter -Wno-unused-variable  -fPIE -pthread -std=c++17 -MD -MT coreComponents/unitTests/toolchain/CMakeFiles/testNDEBUG.dir/testNDEBUG.cpp.o -MF coreComponents/unitTests/toolchain/CMakeFiles/testNDEBUG.dir/testNDEBUG.cpp.o.d -o coreComponents/unitTests/toolchain/CMakeFiles/testNDEBUG.dir/testNDEBUG.cpp.o -c /tmp/GEOSX/src/coreComponents/unitTests/toolchain/testNDEBUG.cpp
[1252/1254] : && /usr/bin/g++-10 -Wall -Wextra       -Werror  -Wall -Wextra -Wpedantic -pedantic-errors -Wshadow -Wfloat-equal -Wcast-align -Wcast-qual   -fdiagnostics-color=always  -g -Wno-unused-parameter -Wno-unused-variable -Wl,--export-dynamic -rdynamic  -pthread coreComponents/unitTests/toolchain/CMakeFiles/testNDEBUG.dir/testNDEBUG.cpp.o -o tests/testNDEBUG  -Wl,-rpath,/tmp/build/lib:/usr/lib/x86_64-linux-gnu/openmpi/lib:/opt/GEOS/GEOS_TPL-238-63-3c52641/caliper/lib:/opt/GEOS/GEOS_TPL-238-63-3c52641/vtk/lib:/opt/GEOS/GEOS_TPL-238-63-3c52641/suitesparse/lib:/opt/GEOS/GEOS_TPL-238-63-3c52641/superlu_dist/lib  lib/libgtest_main.a  lib/libgtest.a  -lpthread  lib/libgeosx_core.so  /usr/lib/x86_64-linux-gnu/openmpi/lib/libmpi_cxx.so  -lpthread  /opt/GEOS/GEOS_TPL-238-63-3c52641/caliper/lib/libcaliper.so.2.10.0  /opt/GEOS/GEOS_TPL-238-63-3c52641/mathpresso/lib/libmathpresso.a  /opt/GEOS/GEOS_TPL-238-63-3c52641/vtk/lib/libvtkFiltersParallelDIY2-9.2.so.9.2.6  /opt/GEOS/GEOS_TPL-238-63-3c52641/vtk/lib/libvtkFiltersParallel-9.2.so.9.2.6  /opt/GEOS/GEOS_TPL-238-63-3c52641/vtk/lib/libvtkFiltersExtraction-9.2.so.9.2.6  /opt/GEOS/GEOS_TPL-238-63-3c52641/vtk/lib/libvtkFiltersHybrid-9.2.so.9.2.6  /opt/GEOS/GEOS_TPL-238-63-3c52641/vtk/lib/libvtkFiltersModeling-9.2.so.9.2.6  /opt/GEOS/GEOS_TPL-238-63-3c52641/vtk/lib/libvtkFiltersSources-9.2.so.9.2.6  /opt/GEOS/GEOS_TPL-238-63-3c52641/vtk/lib/libvtkFiltersTexture-9.2.so.9.2.6  /opt/GEOS/GEOS_TPL-238-63-3c52641/vtk/lib/libvtkParallelDIY-9.2.so.9.2.6  /opt/GEOS/GEOS_TPL-238-63-3c52641/vtk/lib/libvtkFiltersGeneral-9.2.so.9.2.6  /opt/GEOS/GEOS_TPL-238-63-3c52641/vtk/lib/libvtkFiltersGeometry-9.2.so.9.2.6  /opt/GEOS/GEOS_TPL-238-63-3c52641/vtk/lib/libvtkFiltersCore-9.2.so.9.2.6  /opt/GEOS/GEOS_TPL-238-63-3c52641/vtk/lib/libvtkIOParallelXML-9.2.so.9.2.6  /opt/GEOS/GEOS_TPL-238-63-3c52641/vtk/lib/libvtkParallelMPI-9.2.so.9.2.6  /opt/GEOS/GEOS_TPL-238-63-3c52641/vtk/lib/libvtkParallelCore-9.2.so.9.2.6  /opt/GEOS/GEOS_TPL-238-63-3c52641/vtk/lib/libvtkIOLegacy-9.2.so.9.2.6  /usr/lib/x86_64-linux-gnu/openmpi/lib/libmpi.so  /opt/GEOS/GEOS_TPL-238-63-3c52641/suitesparse/lib/libumfpack.so  /opt/GEOS/GEOS_TPL-238-63-3c52641/superlu_dist/lib/libsuperlu_dist.so  /opt/GEOS/GEOS_TPL-238-63-3c52641/vtk/lib/libvtkIOXML-9.2.so.9.2.6  /opt/GEOS/GEOS_TPL-238-63-3c52641/vtk/lib/libvtkIOXMLParser-9.2.so.9.2.6  /opt/GEOS/GEOS_TPL-238-63-3c52641/vtk/lib/libvtkIOCore-9.2.so.9.2.6  /opt/GEOS/GEOS_TPL-238-63-3c52641/vtk/lib/libvtkCommonExecutionModel-9.2.so.9.2.6  /opt/GEOS/GEOS_TPL-238-63-3c52641/vtk/lib/libvtkCommonDataModel-9.2.so.9.2.6  /opt/GEOS/GEOS_TPL-238-63-3c52641/vtk/lib/libvtkCommonTransforms-9.2.so.9.2.6  /opt/GEOS/GEOS_TPL-238-63-3c52641/vtk/lib/libvtkCommonMisc-9.2.so.9.2.6  /opt/GEOS/GEOS_TPL-238-63-3c52641/vtk/lib/libvtkCommonMath-9.2.so.9.2.6  /opt/GEOS/GEOS_TPL-238-63-3c52641/vtk/lib/libvtkkissfft-9.2.so.9.2.6  /opt/GEOS/GEOS_TPL-238-63-3c52641/vtk/lib/libvtkCommonSystem-9.2.so.9.2.6  /opt/GEOS/GEOS_TPL-238-63-3c52641/vtk/lib/libvtkCommonCore-9.2.so.9.2.6  -pthread  /opt/GEOS/GEOS_TPL-238-63-3c52641/vtk/lib/libvtksys-9.2.so.9.2.6  -ldl  -Wl,-rpath-link,/opt/GEOS/GEOS_TPL-238-63-3c52641/vtk/lib && :

EDIT: this is now fixed, and the tests now errors as expected.

@tbeltzun tbeltzun removed the ci: run CUDA builds Allows to triggers (costly) CUDA jobs label Oct 9, 2023
@tbeltzun tbeltzun force-pushed the bugfix/tbeltzun/ndebug branch 2 times, most recently from edd78c2 to cfdfabf Compare October 12, 2023 12:39
@tbeltzun tbeltzun force-pushed the bugfix/tbeltzun/ndebug branch from cfdfabf to e192b62 Compare October 12, 2023 12:39
@tbeltzun tbeltzun force-pushed the bugfix/tbeltzun/ndebug branch from a9a03c4 to 39833f4 Compare October 12, 2023 12:45
@tbeltzun tbeltzun requested a review from TotoGaz November 16, 2023 15:08
@Algiane Algiane self-requested a review November 16, 2023 15:10
@Algiane
Copy link
Contributor

Algiane commented Nov 16, 2023

Thanks for all the work that you have done on this PR @tbeltzun ;-).

Comment on lines 22 to 23
* instead, we always check that this test fails in CMake Debug mode, whilst it should always
* pass in RelWithDebInfo or Release builds.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test is compact and readable

No, this current test is not compact: it spans two files to be understood.
Both testToolChain.cpp and the corresponding CMakeLists.txt are involved in the pattern.
(Plus the "negate" pattern that will negate all the tests in the folder, not only this one).

Is the code below equivalent to the full logic on the test?

bool constexpr isDebug = std::string_view( GEOSX_CMAKE_BUILD_TYPE ) == std::string_view( "Debug" );

#ifdef NDEBUG 
bool constexpr hasNDEBUG = true;
#else
bool constexpr hasNDEBUG = false;
#endif

ASSERT_EQ( !isDebug, hasNDEBUG );  // or static_assert(...)

scripts/ci_build_and_test.sh Outdated Show resolved Hide resolved
.github/workflows/ci_tests.yml Outdated Show resolved Hide resolved
@tbeltzun
Copy link
Contributor Author

Ready on my side.

@rrsettgast
Copy link
Member

@TotoGaz Are you ok with this ?

Copy link
Contributor

@TotoGaz TotoGaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you for your dedication and fruitful discussion @tbeltzun @Algiane !
I feel disappointed that we have to buy a bigger machine for the build, but I guess it is what it is, we'll have to figure how to improve the situation!

@tbeltzun tbeltzun force-pushed the bugfix/tbeltzun/ndebug branch from dd84565 to 209c066 Compare November 20, 2023 14:49
@tbeltzun tbeltzun added the flag: requires updated TPL(s) Needs a specific TPL PR label Nov 21, 2023
@tbeltzun tbeltzun force-pushed the bugfix/tbeltzun/ndebug branch 2 times, most recently from 335af4c to 924ee83 Compare November 28, 2023 10:40
@tbeltzun tbeltzun force-pushed the bugfix/tbeltzun/ndebug branch from 924ee83 to 753f192 Compare November 28, 2023 11:49
@TotoGaz TotoGaz linked an issue Nov 29, 2023 that may be closed by this pull request
2 tasks
@CusiniM CusiniM merged commit 5a72966 into develop Nov 29, 2023
21 checks passed
@CusiniM CusiniM deleted the bugfix/tbeltzun/ndebug branch November 29, 2023 21:52
ouassimkh pushed a commit that referenced this pull request Feb 16, 2024
* add `DNDEBUG` test case

* add `build_unittests` to build all the test targets

* implement `geos_add_test`

* enforce `CMake` consistency (tests)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci: run CUDA builds Allows to triggers (costly) CUDA jobs flag: requires updated TPL(s) Needs a specific TPL PR type: bug Something isn't working type: build system Build system issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Failing ci tests in Debug mode potential incorrect application of NDEBUG
7 participants