oneDPL icon indicating copy to clipboard operation
oneDPL copied to clipboard

Fix tests relying on assert (release builds)

Open dmitriy-sobolev opened this issue 1 year ago • 2 comments

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 avatar Nov 21 '24 13:11 dmitriy-sobolev

@dmitriy-sobolev , can we add "#undef NDEBUG" on the "cmake level" for the all oneDPL tests?

MikeDvorskiy avatar Dec 05 '24 13:12 MikeDvorskiy

@MikeDvorskiy, see #2089. I added ReleaseWithAsserts configuration to keep Release as it is.

dmitriy-sobolev avatar Mar 03 '25 08:03 dmitriy-sobolev