Repository: opencv
Issue: Test cases failed while building OpenCV 4.10.0 version
Labels: bug,needs investigation

### System Information

**System Information**
Opencv version: 4.10.0
Operating system : Ubuntu 24.04
Compiler version: GCC 13.2.0



### Detailed description

Detailed description
I have been building opencv from source with following parameter
 ```
 cmake ../opencv  -DBUILD_DOCS=OFF -DBUILD_EXAMPLE=OFF -DBUILD_TESTS=ON -DBUILD_PERF_TESTS=OFF 
-DBUILD_SHARED_LIBS=ON -DBUILD_WITH_DEBUG_INFO=ON -DCMAKE_BUILD_TYPE=release -DBUILD_JAVA=OFF -
DBUILD_opencv_python2=OFF -DBUILD_opencv_python3=ON -DBUILD_opencv_dnn=ON -DBUILD_opencv_dnn_modern=OFF 
-DBUILD_opencv_cnn_3dobj=ON -DBUILD_PROTOBUF=OFF
-DPROTOBUF_UPDATE_FILES=ON -DCMAKE_INSTALL_PREFIX=/path -DOPENCV_EXTRA_MODULES_PATH=/mnt/opencv_contrib/modules 
-DOPENCV_LICENSES_INSTALL_PATH=/path/share/doc/opencv -DOPENCV_GENERATE_PKGCONFIG=YES -DOPENCV_PYTHON3_VERSION=3.12 
-DPYTHON3_PACKAGES_PATH=/path/lib/python3.12/dist-packages -DENABLE_CCACHE=OFF -DENABLE_FAST_MATH=ON 
-DWITH_VTK=ON -DBUILD_opencv_hdf=OFF -DWITH_OPENGL=ON -DWITH_GPHOTO2=OFF -DWITH_FREETYPE=ON -DFREETYPE_INCLUDE_DIRS=/usr/include/freetype2 -DTINYDNN_USE_OMP=ON
-DINSTALL_C_EXAMPLES=OFF -DINSTALL_PYTHON_EXAMPLES=OFF -DOPENCV_DNN_CUDA=ON -DWITH_CUDA=ON -DWITH_CUBLAS=ON -DWITH_CUFFT=ON 
-DCUDA_NVCC_FLAGS=--expt-relaxed-constexpr -DCUDA_FAST_MATH=ON -DCUDA_ARCH_BIN=5.3,6.0,6.1,7.0,7.5,8.6,8.9 
-DENABLE_PRECOMPILED_HEADERS=ON -DWITH_NVCUVID=ON -DWITH_OPENMP=ON -DOpenGL_GL_PREFERENCE=GLVND 
-DPYTHON_DEFAULT_EXECUTABLE=/PATH/python3.12 -DPYTHON3_EXECUTABLE=/PATH/python3.12 
-DPYTHON3_INCLUDE_DIR=/miniconda/include -DPYTHON3_LIBRARY=/PATH/libpython3.12.so 
-DPYTHON3_NUMPY_INCLUDE_DIRS=/PATH/python3.12/site-packages/numpy/_core/include -DWITH_OPENVINO=ON 
-DWITH_TBB=ON -DMKL_WITH_OPENMP=ON -DMKL_WITH_TBB=ON
/mnt/opencv_extra /mnt
```
There are several tests which are failed :

```
[  FAILED  ] Core_SVD.orthogonality
[  FAILED  ] OCL_Arithm/InRange.Mat/33, where GetParam() = (CV_16U, Channels(1), false, true)
[  FAILED  ] OCL_Arithm/InRange.Mat/35, where GetParam() = (CV_16U, Channels(1), true, true)
[  FAILED  ] OCL_Arithm/InRange.Mat/37, where GetParam() = (CV_16U, Channels(2), false, true)
[  FAILED  ] OCL_Arithm/InRange.Mat/39, where GetParam() = (CV_16U, Channels(2), true, true)
[  FAILED  ] OCL_Arithm/InRange.Mat/49, where GetParam() = (CV_16S, Channels(1), false, true)
[  FAILED  ] OCL_Arithm/InRange.Mat/51, where GetParam() = (CV_16S, Channels(1), true, true)
[  FAILED  ] OCL_Arithm/InRange.Mat/57, where GetParam() = (CV_16S, Channels(3), false, true)
[  FAILED  ] OCL_Arithm/InRange.Mat/59, where GetParam() = (CV_16S, Channels(3), true, true)
[  FAILED  ] OCL_Arithm/InRange.Mat/65, where GetParam() = (CV_32S, Channels(1), false, true)
[  FAILED  ] OCL_Arithm/InRange.Mat/96, where GetParam() = (CV_64F, Channels(1), false, false)
[  FAILED  ] OCL_Arithm/InRange.Mat/98, where GetParam() = (CV_64F, Channels(1), true, false)
[  FAILED  ] OCL_Arithm/InRange.Mat/105, where GetParam() = (CV_64F, Channels(3), false, true)
[  FAILED  ] OCL_Arithm/InRange.Mat/107, where GetParam() = (CV_64F, Channels(3), true, true)
[  FAILED  ] Core_InRangeS/ElemWiseTest.accuracy/0, where GetParam() = 16-byte object <20-75 24-18 D2-55 00-00 60-52 59-18 D2-55 00-00>
[  FAILED  ] Core_InRange/ElemWiseTest.accuracy/0, where GetParam() = 16-byte object <C0-4A 53-18 D2-55 00-00 A0-55 59-18 D2-55 00-00>
[  FAILED  ] Core/CountNonZeroND.ndim/0, where GetParam() = (2, 0)
[  FAILED  ] Core/CountNonZeroND.ndim/1, where GetParam() = (2, 1)
[  FAILED  ] Core/CountNonZeroND.ndim/2, where GetParam() = (2, 5)
[  FAILED  ] Core/CountNonZeroND.ndim/3, where GetParam() = (3, 0)
[  FAILED  ] Core/CountNonZeroND.ndim/4, where GetParam() = (3, 1)
[  FAILED  ] Core/CountNonZeroND.ndim/5, where GetParam() = (3, 5)
[  FAILED  ] Core/CountNonZeroND.ndim/6, where GetParam() = (4, 0)
[  FAILED  ] Core/CountNonZeroND.ndim/7, where GetParam() = (4, 1)
[  FAILED  ] Core/CountNonZeroND.ndim/8, where GetParam() = (4, 5)
[  FAILED  ] Core/CountNonZeroND.ndim/9, where GetParam() = (5, 0)
[  FAILED  ] Core/CountNonZeroND.ndim/10, where GetParam() = (5, 1)
[  FAILED  ] Core/CountNonZeroND.ndim/11, where GetParam() = (5, 5)
[  FAILED  ] Core/CountNonZeroND.ndim/12, where GetParam() = (6, 0)
[  FAILED  ] Core/CountNonZeroND.ndim/13, where GetParam() = (6, 1)
[  FAILED  ] Core/CountNonZeroND.ndim/14, where GetParam() = (6, 5)
[  FAILED  ] Core/CountNonZeroND.ndim/18, where GetParam() = (8, 0)
[  FAILED  ] Core/CountNonZeroND.ndim/19, where GetParam() = (8, 1)
[  FAILED  ] Core/CountNonZeroND.ndim/20, where GetParam() = (8, 5)
[  FAILED  ] Core/HasNonZeroLimitValues.hasNonZeroLimitValues/0, where GetParam() = (5, 1x1)
[  FAILED  ] Core/HasNonZeroLimitValues.hasNonZeroLimitValues/1, where GetParam() = (5, 320x240)
[  FAILED  ] Core/HasNonZeroLimitValues.hasNonZeroLimitValues/2, where GetParam() = (5, 127x113)
[  FAILED  ] Core/HasNonZeroLimitValues.hasNonZeroLimitValues/3, where GetParam() = (5, 1x113)
[  FAILED  ] Core/HasNonZeroLimitValues.hasNonZeroLimitValues/4, where GetParam() = (6, 1x1)
[  FAILED  ] Core/HasNonZeroLimitValues.hasNonZeroLimitValues/5, where GetParam() = (6, 320x240)
```


After running tests individually i got below result : 

```
root@buildhost:/mnt/opencv.build/bin# ./opencv_test_core --gtest_filter=OCL_Arithm/InRange.Mat/49 --verbose
CTEST_FULL_OUTPUT
OpenCV version: 4.10.0
OpenCV VCS version: 4.10.0
Build type: Release
Compiler: /usr/bin/c++  (ver 11.4.0)
Parallel framework: tbb (nthreads=16)
CPU features: SSE SSE2 SSE3 SSSE3 SSE4.1 POPCNT SSE4.2 FP16 AVX AVX2 AVX512F AVX512-COMMON AVX512-SKX AVX512-CNL AVX512-CLX AVX512-ICL
Intel(R) IPP version: ippIP AVX-512F/CD/BW/DQ/VL (k0) 2021.11.0 (-) Feb  1 2024
Intel(R) IPP features code: 0x7300000
OpenCL is disabled
TEST: Skip tests with tags: 'mem_6gb', 'verylong'
Note: Google Test filter = OCL_Arithm/InRange.Mat/49
[==========] Running 1 test from 1 test case.
[----------] Global test environment set-up.
[----------] 1 test from OCL_Arithm/InRange
[ RUN      ] OCL_Arithm/InRange.Mat/49, where GetParam() = (CV_16S, Channels(1), false, true)
/mnt/opencv/modules/core/test/ocl/test_arithm.cpp:1532: Failure
Expected: (cvtest::ocl::TestUtils::checkNorm2(dst_roi, udst_roi)) <= (0), actual: 255 vs 0
Size: [21 x 15]

[  FAILED  ] OCL_Arithm/InRange.Mat/49, where GetParam() = (CV_16S, Channels(1), false, true) (1 ms)
[----------] 1 test from OCL_Arithm/InRange (1 ms total)

[----------] Global test environment tear-down
[==========] 1 test from 1 test case ran. (1 ms total)
[  PASSED  ] 0 tests.
[  FAILED  ] 1 test, listed below:
[  FAILED  ] OCL_Arithm/InRange.Mat/49, where GetParam() = (CV_16S, Channels(1), false, true)

 1 FAILED TEST
```
Expected Behavior
The build should complete successfully with no test failed, producing OpenCV binaries with the specified configurations.

Could someone help identify the cause of this issue and suggest a solution? Any guidance or help would be greatly appreciated.


### Steps to reproduce

git clone https://github.com/opencv/opencv.git
git checkout [version/tag/branch]

Install dependencies

Run below command :

`cmake ../opencv -DBUILD_DOCS=OFF -DBUILD_EXAMPLE=OFF -DBUILD_TESTS=ON -DBUILD_PERF_TESTS=OFF -DBUILD_SHARED_LIBS=ON -DBUILD_WITH_DEBUG_INFO=ON -DCMAKE_BUILD_TYPE=release -DBUILD_JAVA=OFF -DBUILD_opencv_python2=OFF -DBUILD_opencv_python3=ON -DBUILD_opencv_dnn=ON -DBUILD_opencv_dnn_modern=OFF -DBUILD_opencv_cnn_3dobj=ON -DBUILD_PROTOBUF=OFF -DPROTOBUF_UPDATE_FILES=ON -DCMAKE_INSTALL_PREFIX=/path -DOPENCV_EXTRA_MODULES_PATH=/mnt/opencv_contrib/modules -DOPENCV_LICENSES_INSTALL_PATH=/path/share/doc/opencv -DOPENCV_GENERATE_PKGCONFIG=YES -DOPENCV_PYTHON3_VERSION=3.12 -DPYTHON3_PACKAGES_PATH=/path/lib/python3.12/dist-packages -DENABLE_CCACHE=OFF -DENABLE_FAST_MATH=ON -DWITH_VTK=ON -DBUILD_opencv_hdf=OFF -DWITH_OPENGL=ON -DWITH_GPHOTO2=OFF -DWITH_FREETYPE=ON -DFREETYPE_INCLUDE_DIRS=/usr/include/freetype2 -DTINYDNN_USE_OMP=ON -DINSTALL_C_EXAMPLES=OFF -DINSTALL_PYTHON_EXAMPLES=OFF -DOPENCV_DNN_CUDA=ON -DWITH_CUDA=ON -DWITH_CUBLAS=ON -DWITH_CUFFT=ON -DCUDA_NVCC_FLAGS=--expt-relaxed-constexpr -DCUDA_FAST_MATH=ON -DCUDA_ARCH_BIN=5.3,6.0,6.1,7.0,7.5,8.6,8.9 -DENABLE_PRECOMPILED_HEADERS=ON -DWITH_NVCUVID=ON -DWITH_OPENMP=ON -DOpenGL_GL_PREFERENCE=GLVND -DPYTHON_DEFAULT_EXECUTABLE=/PATH/python3.12 -DPYTHON3_EXECUTABLE=/PATH/python3.12 -DPYTHON3_INCLUDE_DIR=/miniconda/include -DPYTHON3_LIBRARY=/PATH/libpython3.12.so -DPYTHON3_NUMPY_INCLUDE_DIRS=/PATH/python3.12/site-packages/numpy/_core/include -DWITH_OPENVINO=ON -DWITH_TBB=ON -DMKL_WITH_OPENMP=ON -DMKL_WITH_TBB=ON`

make -j$(no of cores)



### Issue submission checklist

- [X] I report the issue, it's not a question
- [X] I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
- [X] I updated to the latest OpenCV version and the issue is still there
- [X] There is reproducer code and related data files (videos, images, onnx, etc)