oneDPL
oneDPL copied to clipboard
Fix tests relying on assert (release builds)
Describe the Bug:
Some tests rely on assert for issuing errors, but there is no any handling of NDEBUG e.g. on CMake side. That may result in a worse test coverage for release builds.
To Reproduce: The steps to reproduce the behavior (Windows as an example):
# Comment line in test_config.h to trigger an error:
// #define _PSTL_TEST_COMPLEX_OP_BROKEN (_MSVC_STL_VERSION && _MSVC_STL_VERSION <= _PSTL_TEST_LATEST_MSVC_STL_VERSION)
# The error is detected in the debug build
cmake -GNinja -DCMAKE_CXX_COMPILER=icx -DCMAKE_BUILD_TYPE=debug -DONEDPL_DEVICE_TYPE=CPU path\to\oneDPL
ninja run-asin.pass
1/1 Test #468: asin.pass ........................Exit code 0xc0000409
***Exception: 0.99 sec
Assertion failed: std::isinf(r.imag()), file C:\repos\oneDPL\test\xpu_api\numerics\complex.number\complex.transcendentals\asin.pass.cpp, line 89
# The error is overlooked in the release build
cmake -GNinja -DCMAKE_CXX_COMPILER=icx -DCMAKE_BUILD_TYPE=release -DONEDPL_DEVICE_TYPE=CPU C:\repos\oneDPL
ninja run-asin.pass
1/1 Test #468: asin.pass ........................ Passed 0.84 sec
# Adding "#undef NDEBUG" to the top of asin.pass.cpp results in the triggering of the assertion in the release build as well.
Expected Behavior: The tests are equally covered in the release and debug builds.
@dmitriy-sobolev , can we add "#undef NDEBUG" on the "cmake level" for the all oneDPL tests?
@MikeDvorskiy, see #2089. I added ReleaseWithAsserts configuration to keep Release as it is.