From 7a0d6559c3ca60e858c31162ece142c85d9e5d70 Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Wed, 2 Jul 2025 10:07:13 +0300 Subject: [PATCH] Made some GDAL specific tests optional. --- modules/imgcodecs/test/test_gdal.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/modules/imgcodecs/test/test_gdal.cpp b/modules/imgcodecs/test/test_gdal.cpp index b61d2ed786..0ede7098f7 100755 --- a/modules/imgcodecs/test/test_gdal.cpp +++ b/modules/imgcodecs/test/test_gdal.cpp @@ -8,10 +8,14 @@ namespace opencv_test { namespace { #ifdef HAVE_GDAL -static void test_gdal_read(const string filename) { +static void test_gdal_read(const string filename, bool required = true) { const string path = cvtest::findDataFile(filename); Mat img; ASSERT_NO_THROW(img = imread(path, cv::IMREAD_LOAD_GDAL | cv::IMREAD_ANYDEPTH | cv::IMREAD_ANYCOLOR)); + if(!required && img.empty()) + { + throw SkipTestException("GDAL is built wihout required back-end support"); + } ASSERT_FALSE(img.empty()); EXPECT_EQ(3, img.cols); EXPECT_EQ(5, img.rows); @@ -26,13 +30,12 @@ TEST(Imgcodecs_gdal, read_envi) test_gdal_read("../cv/gdal/envi_test.raw"); } - TEST(Imgcodecs_gdal, read_fits) { - test_gdal_read("../cv/gdal/fits_test.fit"); + // .fit test is optional because GDAL may be built wihtout CFITSIO library support + test_gdal_read("../cv/gdal/fits_test.fit", false); } - #endif // HAVE_GDAL }} // namespace