From bfa0e3e1a47b08299e10ca0dce4970a586a5ddda Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Thu, 17 Mar 2022 11:17:25 +0300 Subject: [PATCH] Fix samples tests on azure (#10892) * Fix samples tests on azure * fixed bmp reader --- .ci/azure/windows.yml | 17 ++++++++--------- samples/c/common/opencv_c_wrapper/bmp_reader.c | 15 +++++++-------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/.ci/azure/windows.yml b/.ci/azure/windows.yml index f5ea7f9701c..70069298a7d 100644 --- a/.ci/azure/windows.yml +++ b/.ci/azure/windows.yml @@ -133,7 +133,7 @@ jobs: - script: | set PATH=$(WORK_DIR)\ninja-win;%PATH% - call "$(MSVS_VARS_PATH)" && $(CMAKE_CMD) -G "Ninja Multi-Config" -DENABLE_WHEEL=ON -DENABLE_ONEDNN_FOR_GPU=$(CMAKE_BUILD_SHARED_LIBS) -DENABLE_GAPI_PREPROCESSING=$(CMAKE_BUILD_SHARED_LIBS) -DBUILD_SHARED_LIBS=$(CMAKE_BUILD_SHARED_LIBS) -DENABLE_REQUIREMENTS_INSTALL=OFF -DENABLE_FASTER_BUILD=ON -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -DENABLE_TESTS=ON -DENABLE_STRICT_DEPENDENCIES=OFF -DENABLE_PYTHON=ON -DPYTHON_EXECUTABLE="C:\hostedtoolcache\windows\Python\3.7.6\x64\python.exe" -DPYTHON_INCLUDE_DIR="C:\hostedtoolcache\windows\Python\3.7.6\x64\include" -DPYTHON_LIBRARY="C:\hostedtoolcache\windows\Python\3.7.6\x64\libs\python37.lib" -DIE_EXTRA_MODULES=$(OPENVINO_CONTRIB_REPO_DIR)\modules -DCMAKE_C_COMPILER:PATH="$(MSVC_COMPILER_PATH)" -DCMAKE_CXX_COMPILER:PATH="$(MSVC_COMPILER_PATH)" $(REPO_DIR) + call "$(MSVS_VARS_PATH)" && $(CMAKE_CMD) -G "Ninja Multi-Config" -DENABLE_WHEEL=ON -DENABLE_ONEDNN_FOR_GPU=$(CMAKE_BUILD_SHARED_LIBS) -DBUILD_SHARED_LIBS=$(CMAKE_BUILD_SHARED_LIBS) -DENABLE_REQUIREMENTS_INSTALL=OFF -DENABLE_FASTER_BUILD=ON -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -DENABLE_TESTS=ON -DENABLE_STRICT_DEPENDENCIES=OFF -DENABLE_PYTHON=ON -DPYTHON_EXECUTABLE="C:\hostedtoolcache\windows\Python\3.7.6\x64\python.exe" -DPYTHON_INCLUDE_DIR="C:\hostedtoolcache\windows\Python\3.7.6\x64\include" -DPYTHON_LIBRARY="C:\hostedtoolcache\windows\Python\3.7.6\x64\libs\python37.lib" -DIE_EXTRA_MODULES=$(OPENVINO_CONTRIB_REPO_DIR)\modules -DCMAKE_C_COMPILER:PATH="$(MSVC_COMPILER_PATH)" -DCMAKE_CXX_COMPILER:PATH="$(MSVC_COMPILER_PATH)" $(REPO_DIR) workingDirectory: $(BUILD_DIR) displayName: 'CMake' @@ -167,13 +167,6 @@ jobs: workingDirectory: $(BUILD_SAMPLES_TESTS_DIR) displayName: 'Install Samples Tests' - - script: $(CMAKE_CMD) -DCMAKE_INSTALL_PREFIX=$(INSTALL_DIR) -DCOMPONENT=tests -P cmake_install.cmake && xcopy $(REPO_DIR)\temp\opencv_4.5.2\opencv\* $(INSTALL_DIR)\opencv\ /e /h /y - workingDirectory: $(BUILD_DIR) - displayName: 'Install tests' - - - script: dir $(INSTALL_DIR) /s - displayName: 'List install files' - - script: $(INSTALL_DIR)\samples\cpp\build_samples_msvc.bat -i $(INSTALL_DIR) workingDirectory: $(BUILD_SAMPLES_DIR) displayName: 'Build cpp samples' @@ -198,9 +191,15 @@ jobs: python -m pytest $(INSTALL_DIR)\tests\smoke_tests\ --env_conf $(INSTALL_DIR)\tests\smoke_tests\env_config.yml -s --junitxml=TEST-SamplesSmokeTests.xml workingDirectory: $(INSTALL_DIR) displayName: 'Samples Smoke Tests' - condition: eq(variables['CMAKE_BUILD_SHARED_LIBS'], 'ON') continueOnError: false + - script: $(CMAKE_CMD) -DCMAKE_INSTALL_PREFIX=$(INSTALL_DIR) -DCOMPONENT=tests -P cmake_install.cmake && xcopy $(REPO_DIR)\temp\opencv_4.5.2\opencv\* $(INSTALL_DIR)\opencv\ /e /h /y + workingDirectory: $(BUILD_DIR) + displayName: 'Install tests' + + - script: dir $(INSTALL_DIR) /s + displayName: 'List install files' + - script: rd /Q /S $(BUILD_DIR) displayName: 'Clean build dir' continueOnError: false diff --git a/samples/c/common/opencv_c_wrapper/bmp_reader.c b/samples/c/common/opencv_c_wrapper/bmp_reader.c index 40fd5fc4bd4..564d26c1ee8 100644 --- a/samples/c/common/opencv_c_wrapper/bmp_reader.c +++ b/samples/c/common/opencv_c_wrapper/bmp_reader.c @@ -29,7 +29,7 @@ int readBmpImage(const char* fileName, BitMap* image) { } cnt = fread(&image->header.type, sizeof(image->header.type), sizeof(unsigned char), input); - if (cnt != sizeof(image->header.type)) { + if (cnt != sizeof(unsigned char)) { printf("[BMP] file read error\n"); CLEANUP_AND_RETURN(-2); } @@ -40,25 +40,25 @@ int readBmpImage(const char* fileName, BitMap* image) { } cnt = fread(&image->header.size, sizeof(image->header.size), sizeof(unsigned char), input); - if (cnt != sizeof(image->header.size)) { + if (cnt != sizeof(unsigned char)) { printf("[BMP] file read error\n"); CLEANUP_AND_RETURN(2); } cnt = fread(&image->header.reserved, sizeof(image->header.reserved), sizeof(unsigned char), input); - if (cnt != sizeof(image->header.reserved)) { + if (cnt != sizeof(unsigned char)) { printf("[BMP] file read error\n"); CLEANUP_AND_RETURN(2); } cnt = fread(&image->header.offset, sizeof(image->header.offset), sizeof(unsigned char), input); - if (cnt != sizeof(image->header.offset)) { + if (cnt != sizeof(unsigned char)) { printf("[BMP] file read error\n"); CLEANUP_AND_RETURN(2); } cnt = fread(&image->infoHeader, sizeof(BmpInfoHeader), sizeof(unsigned char), input); - if (cnt != sizeof(image->header.offset)) { + if (cnt != sizeof(unsigned char)) { printf("[BMP] file read error\n"); CLEANUP_AND_RETURN(2); } @@ -98,13 +98,12 @@ int readBmpImage(const char* fileName, BitMap* image) { for (i = 0; i < image_height; i++) { unsigned int storeAt = image->infoHeader.height < 0 ? i : (unsigned int)image_height - 1 - i; cnt = fread(image->data + row_size * storeAt, row_size, sizeof(unsigned char), input); - if (cnt != row_size) { + if (cnt != sizeof(unsigned char)) { printf("[BMP] file read error\n"); CLEANUP_AND_RETURN(2); } - cnt = fread(pad, padSize, sizeof(unsigned char), input); - if (cnt != padSize) { + if ((padSize != 0 && cnt != 0) && (cnt != sizeof(unsigned char))) { printf("[BMP] file read error\n"); CLEANUP_AND_RETURN(2); }