From 13b2c6288f59961b3878c65db731594e6cda72bd Mon Sep 17 00:00:00 2001 From: Thomas Feuvrier <thomas.feuvrier@c-s.fr> Date: Tue, 13 Oct 2009 16:34:40 +0200 Subject: [PATCH] ENH: Creation of the OTBTesting library in OTB/Code/Testing. Update all CMakeLists testing files and otbIncludeDirectories.cmake file. --- Code/CMakeLists.txt | 1 + Code/GeospatialAnalysis/CMakeLists.txt | 2 +- Code/Testing/CMakeLists.txt | 23 + Code/Testing/otbTestHelper.cxx | 1378 +++++++++++++++++ Code/Testing/otbTestHelper.h | 109 ++ Code/Testing/otbTestMain.h | 604 ++++++++ Testing/Code/BasicFilters/CMakeLists.txt | 2 - Testing/Code/CMakeLists.txt | 26 - Testing/Code/ChangeDetection/CMakeLists.txt | 3 - Testing/Code/Common/CMakeLists.txt | 2 - Testing/Code/DisparityMap/CMakeLists.txt | 2 - Testing/Code/FeatureExtraction/CMakeLists.txt | 2 - Testing/Code/Fusion/CMakeLists.txt | 2 - .../Code/GeospatialAnalysis/CMakeLists.txt | 2 - Testing/Code/Gui/CMakeLists.txt | 2 - Testing/Code/IO/CMakeLists.txt | 1 - Testing/Code/Learning/CMakeLists.txt | 2 - Testing/Code/Markov/CMakeLists.txt | 2 - Testing/Code/MultiScale/CMakeLists.txt | 2 - Testing/Code/Projections/CMakeLists.txt | 2 - Testing/Code/Radiometry/CMakeLists.txt | 2 - Testing/Code/SARPolarimetry/CMakeLists.txt | 2 - Testing/Code/SpatialReasoning/CMakeLists.txt | 2 +- Testing/Code/TestSystem/CMakeLists.txt | 2 - Testing/Code/Visu/CMakeLists.txt | 2 - Testing/Code/Visualization/CMakeLists.txt | 2 - Testing/Fa/CMakeLists.txt | 2 - Testing/Utilities/CMakeLists.txt | 3 - otbIncludeDirectories.cmake | 3 + 29 files changed, 2120 insertions(+), 69 deletions(-) create mode 100644 Code/Testing/CMakeLists.txt create mode 100644 Code/Testing/otbTestHelper.cxx create mode 100644 Code/Testing/otbTestHelper.h create mode 100644 Code/Testing/otbTestMain.h diff --git a/Code/CMakeLists.txt b/Code/CMakeLists.txt index a6a579d3d1..0bd3e0d681 100644 --- a/Code/CMakeLists.txt +++ b/Code/CMakeLists.txt @@ -13,6 +13,7 @@ Radiometry Fusion Markov SARPolarimetry +Testing ) IF(OTB_USE_VISU_GUI) diff --git a/Code/GeospatialAnalysis/CMakeLists.txt b/Code/GeospatialAnalysis/CMakeLists.txt index 4f96fbf68b..039e2ca221 100644 --- a/Code/GeospatialAnalysis/CMakeLists.txt +++ b/Code/GeospatialAnalysis/CMakeLists.txt @@ -20,6 +20,6 @@ IF(NOT OTB_INSTALL_NO_DEVELOPMENT) FILE(GLOB __files1 "${CMAKE_CURRENT_SOURCE_DIR}/*.h") FILE(GLOB __files2 "${CMAKE_CURRENT_SOURCE_DIR}/*.txx") INSTALL(FILES ${__files1} ${__files2} - DESTINATION ${OTB_INSTALL_INCLUDE_DIR_CM24}/Gui + DESTINATION ${OTB_INSTALL_INCLUDE_DIR_CM24}/GeospatialAnalysis COMPONENT Development) ENDIF(NOT OTB_INSTALL_NO_DEVELOPMENT) diff --git a/Code/Testing/CMakeLists.txt b/Code/Testing/CMakeLists.txt new file mode 100644 index 0000000000..091ed1945f --- /dev/null +++ b/Code/Testing/CMakeLists.txt @@ -0,0 +1,23 @@ + +# Sources of non-templated classes. +FILE(GLOB OTBTesting_SRCS "*.cxx" ) + +ADD_LIBRARY(OTBTesting ${OTBTesting_SRCS}) +TARGET_LINK_LIBRARIES (OTBTesting OTBBasicFilters OTBIO OTBCommon ITKBasicFilters) +IF(OTB_LIBRARY_PROPERTIES) + SET_TARGET_PROPERTIES(OTBTesting PROPERTIES ${OTB_LIBRARY_PROPERTIES}) +ENDIF(OTB_LIBRARY_PROPERTIES) + +IF(NOT OTB_INSTALL_NO_LIBRARIES) + INSTALL(TARGETS OTBTesting + RUNTIME DESTINATION ${OTB_INSTALL_BIN_DIR_CM24} COMPONENT RuntimeLibraries + LIBRARY DESTINATION ${OTB_INSTALL_LIB_DIR_CM24} COMPONENT RuntimeLibraries + ARCHIVE DESTINATION ${OTB_INSTALL_LIB_DIR_CM24} COMPONENT Development) +ENDIF(NOT OTB_INSTALL_NO_LIBRARIES) + +IF(NOT OTB_INSTALL_NO_DEVELOPMENT) + FILE(GLOB __files "${CMAKE_CURRENT_SOURCE_DIR}/*.h") + INSTALL(FILES ${__files} + DESTINATION ${OTB_INSTALL_INCLUDE_DIR_CM24}/Testing + COMPONENT Development) +ENDIF(NOT OTB_INSTALL_NO_DEVELOPMENT) diff --git a/Code/Testing/otbTestHelper.cxx b/Code/Testing/otbTestHelper.cxx new file mode 100644 index 0000000000..a85a46a5c1 --- /dev/null +++ b/Code/Testing/otbTestHelper.cxx @@ -0,0 +1,1378 @@ +/*========================================================================= + + Program: ORFEO Toolbox + Language: C++ + Date: $Date$ + Version: $Revision$ + + + Copyright (c) Centre National d'Etudes Spatiales. All rights reserved. + See OTBCopyright.txt for details. + + Some parts of this code are derived from ITK. See ITKCopyright.txt + for details. + + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#include "otbTestHelper.h" +#include "otbMacro.h" +#include <iostream> +#include <fstream> +#include <cctype> + +#include "otbImage.h" +#include "otbVectorImage.h" +#include "otbImageFileReader.h" +#include "otbImageFileWriter.h" +#include "otbDifferenceImageFilter.h" +#include "otbPrintableImageFilter.h" + +#define ITK_TEST_DIMENSION_MAX 6 + +// OGR Headers files +#include "cpl_conv.h" +#include "cpl_string.h" +#include "cpl_multiproc.h" + +#define otbPrintDiff(comment,refStr,testStr) \ + std::cout << " ---- '"<<comment<<"' checking ---------------------------"<<std::endl; \ + std::cout << " Base << "<<refStr<<std::endl; \ + std::cout << " Test >> "<<testStr<<std::endl; + +#define otbCheckStringValue(Comment,RefStr,TestStr, count, report) \ +{ \ + std::string strRefStr(""); if(RefStr != NULL) strRefStr = RefStr; \ + std::string strTestStr(""); if(TestStr != NULL) strTestStr = TestStr; \ + if( strRefStr != strTestStr ) \ + { \ + count++; \ + if(report) \ + { \ + otbPrintDiff(Comment,strRefStr,strTestStr); \ + } \ + } \ +} +#define otbCheckValue(Comment,Ref,Test, count, report) \ +{ \ + if( Ref != Test ) \ + { \ + count++; \ + if(report) \ + { \ + otbPrintDiff(Comment,Ref,Test); \ + } \ + } \ +} + +namespace otb +{ + +int TestHelper::RegressionTestAsciiFile(const char * testAsciiFileName, const char * baselineAsciiFileName, + const double epsilon, std::vector<std::string> ignoredLines) const +{ + std::ifstream fluxfiletest(testAsciiFileName); + std::ifstream fluxfileref(baselineAsciiFileName); + + + std::string diffAsciiFileName(testAsciiFileName); + diffAsciiFileName += ".diff.txt"; + std::ofstream fluxfilediff; + if (m_ReportErrors) + { + fluxfilediff.open(diffAsciiFileName.c_str()); + } + + std::string strfiletest; + std::string strfileref; + + int nbdiff(0); + int numLine(1); + if (!fluxfiletest) + { + itkGenericExceptionMacro(<<"Impossible to open the test ASCII file <"<<testAsciiFileName<<">."); + } + if (!fluxfileref) + { + itkGenericExceptionMacro(<< "Impossible to open the baseline ASCII file <"<<baselineAsciiFileName<<">."); + } + + + + //fill up a vector of string, in which each element is one line of the file + std::vector<std::string> listLineFileRef; + std::vector<std::string> listLineFileTest; + while (std::getline(fluxfileref, strfileref) != 0) + { + listLineFileRef.push_back(strfileref); + } + fluxfileref.close(); + + while (std::getline(fluxfiletest, strfiletest) != 0) + { + listLineFileTest.push_back(strfiletest); + } + fluxfiletest.close(); + + if(m_IgnoreLineOrder) + { + std::sort(listLineFileRef.begin(), listLineFileRef.end()); + std::sort(listLineFileTest.begin(), listLineFileTest.end()); + } + + //These are to save up the differences + std::vector<std::string> listStrDiffLineFileRef; + std::vector<std::string> listStrDiffLineFileTest; + + std::vector<std::string>::iterator itRef = listLineFileRef.begin(); + std::vector<std::string>::iterator itTest = listLineFileTest.begin(); +// while (std::getline(fluxfileref, strfileref) != 0) + while ((itRef != listLineFileRef.end()) && (itTest != listLineFileTest.end())) + { + strfileref = *itRef; + strfiletest = *itTest; + + //Check is the current line should be ignored + bool ignoreCurrentLineRef = false; + bool ignoreCurrentLineTest = false; + if (ignoredLines.size() > 0) + { + for (std::vector<std::string>::iterator itIgnoredLines = ignoredLines.begin(); + itIgnoredLines != ignoredLines.end(); ++itIgnoredLines) + { + std::string ignoredLinesAscii = (*itIgnoredLines); + std::string::size_type loc = strfileref.find(ignoredLinesAscii); + if (loc != std::string::npos) + { + ignoreCurrentLineRef = true; + } + loc = strfiletest.find(ignoredLinesAscii); + if (loc != std::string::npos) + { + ignoreCurrentLineTest = true; + } + } + } + + //Compare the lines only if none is supposed to be ignored + //Note: the iterator increment will take care of moving only the + //ignored one if the order does not matter + bool differenceFoundInCurrentLine = false; + if ((!ignoreCurrentLineRef) && (!ignoreCurrentLineTest)) + { +// std::cout << "Ref line: " << strfileref << std::endl; +// std::cout << "Test line: " << strfiletest << std::endl; + differenceFoundInCurrentLine = CompareLines(strfileref,strfiletest, nbdiff, fluxfilediff, numLine, + listStrDiffLineFileRef, listStrDiffLineFileTest, epsilon); + } + + if (m_IgnoreLineOrder) + { + if (ignoreCurrentLineRef) ++itRef; + if (ignoreCurrentLineTest) ++itTest; + if ((!ignoreCurrentLineRef) && (!ignoreCurrentLineTest)) + { + if (differenceFoundInCurrentLine) + { + if (*itRef > *itTest) + { + fluxfilediff << "Additional line in test file: " << " : " << *itTest << std::endl; + ++itTest; + } + else + { + fluxfilediff << "Additional line in ref file: " << " : " << *itTest << std::endl; + ++itRef; + } + } + else + { + ++itRef; + ++itTest; + } + } + } + else + { + ++itRef; + ++itTest; + } + + } + + //Here, the line by line comparison is finished and at least one (ref or test) is at the end + //we simply output the content of the other one + + while (itRef != listLineFileRef.end()) + { + strfileref = *itRef; + otb::StringStream buffstreamRef; + std::string strRef = ""; + buffstreamRef << strfileref; + buffstreamRef >> strRef; + fluxfilediff << "Additional line in ref file: " << numLine << " : " << strRef << std::endl; + nbdiff++; + if (m_ReportErrors) + { + listStrDiffLineFileRef.push_back(strfileref); + } + ++itRef; + } + + while (itTest != listLineFileTest.end()) + { + strfiletest = *itTest; + otb::StringStream buffstreamTest; + std::string strTest = ""; + buffstreamTest << strfiletest; + buffstreamTest >> strTest; + fluxfilediff << "Additional line in test file: " << numLine << " : " << strTest << std::endl; + nbdiff++; + if (m_ReportErrors) + { + listStrDiffLineFileTest.push_back(strfiletest); + } + ++itTest; + } + + + if (m_ReportErrors) + { + fluxfilediff.close(); + } + + if (nbdiff != 0 && m_ReportErrors) + { + std::cout << "<DartMeasurement name=\"ASCIIFileError\" type=\"numeric/int\">"; + std::cout << nbdiff; + std::cout << "</DartMeasurement>" << std::endl; + std::cout << "================================================================" << std::endl; + std::cout << "baseline ASCII File : " << baselineAsciiFileName << std::endl; + std::cout << "Test ASCII File : " << testAsciiFileName << std::endl; + std::cout << "Diff ASCII File : " << diffAsciiFileName << std::endl; + std::cout << "Tolerance value : " << epsilon << std::endl; + std::cout << "Tolerance max check : " << m_EpsilonBoundaryChecking << std::endl; + + //FIXME won't be intuitive for the non order case + unsigned int numLineDiff = std::min(listStrDiffLineFileRef.size(), listStrDiffLineFileTest.size()); + std::cout << "Nb lines differents : " << numLineDiff << std::endl; + for (unsigned int i = 0; i < numLineDiff; ++i) + { + std::cout << " -------------------------------" << std::endl; + std::cout << " Base << " << listStrDiffLineFileRef[i] << std::endl; + std::cout << " Test >> " << listStrDiffLineFileTest[i] << std::endl; + } + for (unsigned int i = numLineDiff; i < listStrDiffLineFileRef.size(); ++i) + { + std::cout << " -------------------------------" << std::endl; + std::cout << " Base << " << listStrDiffLineFileRef[i] << std::endl; + } + for (unsigned int i = numLineDiff; i < listStrDiffLineFileTest.size(); ++i) + { + std::cout << " -------------------------------" << std::endl; + std::cout << " Test >> " << listStrDiffLineFileTest[i] << std::endl; + } + } + return (nbdiff != 0) ? 1 : 0; +} + + +/******************************************/ +/******************************************/ +/******************************************/ + +int TestHelper::RegressionTestBinaryFile(const char * testBinaryFileName, const char * baselineBinaryFileName) const +{ + int nbdiff(0); + std::ifstream fluxfiletest(testBinaryFileName, std::ifstream::binary); + std::ifstream fluxfileref(baselineBinaryFileName, std::ifstream::binary); + if (fluxfiletest.fail()) + { + itkGenericExceptionMacro(<<"Impossible to open the test binary file <" << testBinaryFileName << ">."); + } + if (!fluxfileref) + { + itkGenericExceptionMacro(<< "Impossible to open the baseline binary file <" << baselineBinaryFileName << ">."); + } + while (fluxfiletest.good() && fluxfileref.good()) + { + if (fluxfiletest.get() != fluxfileref.get()) + { + nbdiff++; + } + } + fluxfiletest.close(); + fluxfileref.close(); + + if (nbdiff != 0 && m_ReportErrors) + { + std::cout << "<DartMeasurement name=\"BINARYFileError\" type=\"numeric/int\">"; + std::cout << nbdiff; + std::cout << "</DartMeasurement>" << std::endl; + } + return (nbdiff != 0) ? 1 : 0; +} + +int TestHelper::RegressionTestImage(int cpt, const char *testImageFilename, const char *baselineImageFilename, + const double toleranceDiffPixelImage) const +{ + // Use the factory mechanism to read the test and baseline files and convert them to double + + typedef otb::VectorImage<double, 2> ImageType; + typedef otb::VectorImage<unsigned char, 2> OutputType; + typedef otb::VectorImage<unsigned char, 2> DiffOutputType; + typedef otb::ImageFileReader<ImageType> ReaderType; + + // Read the baseline file + ReaderType::Pointer baselineReader = ReaderType::New(); + baselineReader->SetFileName(baselineImageFilename); + try + { + baselineReader->UpdateLargestPossibleRegion(); + } catch (itk::ExceptionObject& e) + { + itkGenericExceptionMacro(<< "Exception detected while reading " + << baselineImageFilename << " : " << e.GetDescription()); + return 1000; + } + + // Read the file generated by the test + ReaderType::Pointer testReader = ReaderType::New(); + testReader->SetFileName(testImageFilename); + try + { + testReader->UpdateLargestPossibleRegion(); + } catch (itk::ExceptionObject& e) + { + itkGenericExceptionMacro(<< "Exception detected while reading " + << testImageFilename << " : " << e.GetDescription() ); + return 1000; + } + + // The sizes of the baseline and test image must match + ImageType::SizeType baselineSize; + baselineSize = baselineReader->GetOutput()->GetLargestPossibleRegion().GetSize(); + ImageType::SizeType testSize; + testSize = testReader->GetOutput()->GetLargestPossibleRegion().GetSize(); + + if (baselineSize != testSize) + { + std::cerr << "The size of the baseline image and Test image do not match!" << std::endl; + std::cerr << "baseline image: " << baselineImageFilename << " has size " << baselineSize << std::endl; + std::cerr << "Test image: " << testImageFilename << " has size " << testSize << std::endl; + return 1; + } + + // Now compare the two images + typedef otb::DifferenceImageFilter<ImageType, ImageType> DiffType; + DiffType::Pointer diff = DiffType::New(); + diff->SetValidInput(baselineReader->GetOutput()); + diff->SetTestInput(testReader->GetOutput()); + diff->SetDifferenceThreshold(toleranceDiffPixelImage); + diff->UpdateLargestPossibleRegion(); + + ImageType::PixelType status = diff->GetTotalDifference(); + unsigned long numberOfPixelsWithDifferences = diff->GetNumberOfPixelsWithDifferences(); + + //Write only one this message + if (m_ReportErrors == 0) + { + otbGenericMsgDebugMacro(<< "RegressionTestImage DifferenceThreshold: "<<toleranceDiffPixelImage); + otbGenericMsgDebugMacro(<< "Status diff->GetTotalDifference: " + << status <<" for "<<numberOfPixelsWithDifferences<<" pixel(s)." ); + } + // if there are discrepencies, create an diff image + if (status.GetSquaredNorm() > 0 && m_ReportErrors) + { + typedef otb::PrintableImageFilter<ImageType> RescaleType; + typedef RescaleType::OutputImageType OutputType; + /* typedef itk::ExtractImageFilter<OutputType,DiffOutputType> ExtractType; */ + typedef otb::ImageFileWriter<RescaleType::OutputImageType> WriterType; + + RescaleType::Pointer rescale = RescaleType::New(); + + WriterType::Pointer writer = WriterType::New(); + writer->SetInput(rescale->GetOutput()); + + // std::cout << "<DartMeasurement name=\"ImageError\" type=\"numeric/double\">"; + std::cout << "<DartMeasurement name=\"ImageError " << cpt << "\" type=\"numeric/double\">"; + std::cout << status; + std::cout << "</DartMeasurement>" << std::endl; + + std::cout << "<DartMeasurement name=\"NumberOfPixelsWithDifferences " << cpt << "\" type=\"numeric/integer\">"; + std::cout << numberOfPixelsWithDifferences; + std::cout << "</DartMeasurement>" << std::endl; + + std::cout << "<DartMeasurement name=\"ToleranceDiffPixelImage\" type=\"numeric/double\">"; + std::cout << toleranceDiffPixelImage; + std::cout << "</DartMeasurement>" << std::endl; + + ::itk::OStringStream diffName; + diffName << testImageFilename << ".diff.png"; + try + { + rescale->SetInput(diff->GetOutput()); + + for (unsigned int i = 1; i <= min(diff->GetOutput()->GetNumberOfComponentsPerPixel(), 3U); ++i) + { + rescale->SetChannel(i); + } + + rescale->Update(); + } catch (...) + { + itkGenericExceptionMacro(<< "Error during rescale of " << diffName.str() ); + } + writer->SetFileName(diffName.str().c_str()); + try + { + writer->Update(); + } catch (...) + { + itkGenericExceptionMacro(<< "Error during write of " << diffName.str() ); + } + + // std::cout << "<DartMeasurementFile name=\"DifferenceImage\" type=\"image/png\">"; + std::cout << "<DartMeasurementFile name=\"DifferenceImage " << cpt << "\" type=\"image/png\">"; + std::cout << diffName.str(); + std::cout << "</DartMeasurementFile>" << std::endl; + + ::itk::OStringStream baseName; + baseName << testImageFilename << ".base.png"; + try + { + rescale->SetInput(baselineReader->GetOutput()); + rescale->Update(); + } catch (...) + { + itkGenericExceptionMacro(<<"Error during rescale of " << baseName.str() ); + } + try + { + writer->SetFileName(baseName.str().c_str()); + writer->Update(); + } catch (...) + { + itkGenericExceptionMacro(<<"Error during write of " << baseName.str() ); + } + + // std::cout << "<DartMeasurementFile name=\"baselineImage\" type=\"image/png\">"; + std::cout << "<DartMeasurementFile name=\"baselineImage " << cpt << "\" type=\"image/png\">"; + std::cout << baseName.str(); + std::cout << "</DartMeasurementFile>" << std::endl; + + ::itk::OStringStream testName; + testName << testImageFilename << ".test.png"; + try + { + rescale->SetInput(testReader->GetOutput()); + rescale->Update(); + } catch (...) + { + itkGenericExceptionMacro(<< "Error during rescale of " << testName.str()); + } + try + { + writer->SetFileName(testName.str().c_str()); + writer->Update(); + } catch (...) + { + itkGenericExceptionMacro(<<"Error during write of " << testName.str() ); + } + + // std::cout << "<DartMeasurementFile name=\"TestImage\" type=\"image/png\">"; + std::cout << "<DartMeasurementFile name=\"TestImage " << cpt << "\" type=\"image/png\">"; + std::cout << testName.str(); + std::cout << "</DartMeasurementFile>" << std::endl; + + } + return (status.GetSquaredNorm() > 0) ? 1 : 0; +} + +int TestHelper::RegressionTestMetaData(const char *testImageFilename, const char *baselineImageFilename, + const double /*toleranceDiffPixelImage*/) const +{ + // Use the factory mechanism to read the test and baseline files and convert them to double + typedef otb::Image<double, ITK_TEST_DIMENSION_MAX> ImageType; + typedef otb::ImageFileReader<ImageType> ReaderType; + + // Read the baseline file + ReaderType::Pointer baselineReader = ReaderType::New(); + baselineReader->SetFileName(baselineImageFilename); + try + { + baselineReader->GenerateOutputInformation(); + } catch (itk::ExceptionObject& e) + { + itkGenericExceptionMacro(<< "Exception detected while reading " + << baselineImageFilename << " : " << e.GetDescription()); + } + + // Read the baseline file + ReaderType::Pointer testReader = ReaderType::New(); + testReader->SetFileName(testImageFilename); + try + { + testReader->GenerateOutputInformation(); + } catch (itk::ExceptionObject& e) + { + itkGenericExceptionMacro(<< "Exception detected while reading " + << baselineImageFilename << " : " << e.GetDescription()); + } + + unsigned int errcount = 0; + // The sizes of the baseline and test image must match + ImageType::SizeType baselineSize; + baselineSize = baselineReader->GetOutput()->GetLargestPossibleRegion().GetSize(); + ImageType::SizeType testSize; + testSize = testReader->GetOutput()->GetLargestPossibleRegion().GetSize(); + + if (baselineSize != testSize) + { + std::cerr << "The size of the baseline image and Test image do not match!" << std::endl; + std::cerr << "baseline image: " << baselineImageFilename << " has size " << baselineSize << std::endl; + std::cerr << "Test image: " << testImageFilename << " has size " << testSize << std::endl; + errcount++; + } + ImageType::Pointer blImPtr = baselineReader->GetOutput(); + ImageType::Pointer testImPtr = testReader->GetOutput(); + + // test orgin + if (blImPtr->GetOrigin() != testImPtr->GetOrigin()) + { + std::cerr << "The origin of the baseline image and Test image do not match!" << std::endl; + std::cerr << "baseline image: " << baselineImageFilename << " has origin " << blImPtr->GetOrigin() << std::endl; + std::cerr << "Test image: " << testImageFilename << " has origin " << testImPtr->GetOrigin() << std::endl; + errcount++; + } + + // test spacing + if (blImPtr->GetSpacing() != testImPtr->GetSpacing()) + { + std::cerr << "The spacing of the baseline image and Test image do not match!" << std::endl; + std::cerr << "baseline image: " << baselineImageFilename << " has spacing " << blImPtr->GetSpacing() << std::endl; + std::cerr << "Test image: " << testImageFilename << " has spacing " << testImPtr->GetSpacing() << std::endl; + errcount++; + } + + // test projection reference + if (blImPtr->GetProjectionRef().compare(testImPtr->GetProjectionRef()) != 0) + { + std::cerr << "The projection reference of the baseline image and Test image do not match!" << std::endl; + std::cerr << "baseline image: " << baselineImageFilename << " has projection reference " + << blImPtr->GetProjectionRef() << std::endl; + std::cerr << "Test image: " << testImageFilename << " has projection reference " + << testImPtr->GetProjectionRef() << std::endl; + errcount++; + } + + // test Geographic transform + if (blImPtr->GetGeoTransform() != testImPtr->GetGeoTransform()) + { + std::cerr << "The geographic transform of the baseline image and Test image do not match!" << std::endl; + std::cerr << "baseline image: " << baselineImageFilename << " has geographic transform " << VectorToString( + blImPtr->GetGeoTransform()) << std::endl; + std::cerr << "Test image: " << testImageFilename << " has geographic transform " << VectorToString( + testImPtr->GetGeoTransform()) << std::endl; + errcount++; + } + + // test upper left corner + if (blImPtr->GetUpperLeftCorner() != testImPtr->GetUpperLeftCorner()) + { + std::cerr << "The upper left corner of the baseline image and Test image do not match!" << std::endl; + std::cerr << "baseline image: " << baselineImageFilename << " has upper left corner " << VectorToString( + blImPtr->GetUpperLeftCorner()) << std::endl; + std::cerr << "Test image: " << testImageFilename << " has upper left corner " << VectorToString( + testImPtr->GetUpperLeftCorner()) << std::endl; + errcount++; + } + + // test upper right corner + if (blImPtr->GetUpperRightCorner() != testImPtr->GetUpperRightCorner()) + { + std::cerr << "The upper right corner of the baseline image and Test image do not match!" << std::endl; + std::cerr << "baseline image: " << baselineImageFilename << " has upper right corner " << VectorToString( + blImPtr->GetUpperRightCorner()) << std::endl; + std::cerr << "Test image: " << testImageFilename << " has upper right corner " << VectorToString( + testImPtr->GetUpperRightCorner()) << std::endl; + errcount++; + } + + // test lower left corner + if (blImPtr->GetLowerLeftCorner() != testImPtr->GetLowerLeftCorner()) + { + std::cerr << "The lower left corner of the baseline image and Test image do not match!" << std::endl; + std::cerr << "baseline image: " << baselineImageFilename << " has lower left corner " << VectorToString( + blImPtr->GetLowerLeftCorner()) << std::endl; + std::cerr << "Test image: " << testImageFilename << " has lower left corner " << VectorToString( + testImPtr->GetLowerLeftCorner()) << std::endl; + errcount++; + } + + // test lower right corner + if (blImPtr->GetLowerRightCorner() != testImPtr->GetLowerRightCorner()) + { + std::cerr << "The lower right of the baseline image and Test image do not match!" << std::endl; + std::cerr << "baseline image: " << baselineImageFilename << " has lower right corner " << VectorToString( + blImPtr->GetLowerRightCorner()) << std::endl; + std::cerr << "Test image: " << testImageFilename << " has lower right corner " << VectorToString( + testImPtr->GetLowerRightCorner()) << std::endl; + errcount++; + } + + // test gcp projection + if (blImPtr->GetGCPProjection().compare(testImPtr->GetGCPProjection()) != 0) + { + std::cerr << "The gcp projection of the baseline image and Test image do not match!" << std::endl; + std::cerr << "baseline image: " << baselineImageFilename << " has gcp projection " << blImPtr->GetGCPProjection() + << std::endl; + std::cerr << "Test image: " << testImageFilename << " has gcp projection " << testImPtr->GetGCPProjection() + << std::endl; + errcount++; + } + + // test gcp count + if (blImPtr->GetGCPCount() != testImPtr->GetGCPCount()) + { + std::cerr << "The gcp count of the baseline image and Test image do not match!" << std::endl; + std::cerr << "baseline image: " << baselineImageFilename << " has gcp count " << blImPtr->GetGCPCount() + << std::endl; + std::cerr << "Test image: " << testImageFilename << " has gcp count " << testImPtr->GetGCPCount() << std::endl; + errcount++; + } + else + { + for (unsigned int i = 0; i < blImPtr->GetGCPCount(); ++i) + { + if ((blImPtr->GetGCPId(i).compare(testImPtr->GetGCPId(i)) != 0) || (blImPtr->GetGCPInfo(i).compare( + testImPtr->GetGCPInfo(i)) != 0) || (blImPtr->GetGCPRow(i) != testImPtr->GetGCPRow(i)) || (blImPtr->GetGCPCol( + i) != testImPtr->GetGCPCol(i)) || (blImPtr->GetGCPX(i) != testImPtr->GetGCPX(i)) || (blImPtr->GetGCPY(i) + != testImPtr->GetGCPY(i)) || (blImPtr->GetGCPZ(i) != testImPtr->GetGCPZ(i))) + { + std::cerr << "The GCP number " << i << " of the baseline image and Test image do not match!" << std::endl; + std::cerr << "baseline image: " << baselineImageFilename << " has gcp number " << i << " (" << "id: " + << blImPtr->GetGCPId(i) << ", " << "info: " << blImPtr->GetGCPInfo(i) << ", " << "row: " + << blImPtr->GetGCPRow(i) << ", " << "col: " << blImPtr->GetGCPCol(i) << ", " << "X: " + << blImPtr->GetGCPX(i) << ", " << "Y: " << blImPtr->GetGCPY(i) << ", " << "Z: " << blImPtr->GetGCPZ(i) + << ")" << std::endl; + std::cerr << "Test image: " << testImageFilename << " has gcp number " << i << " (" << "id: " + << testImPtr->GetGCPId(i) << ", " << "info: " << testImPtr->GetGCPInfo(i) << ", " << "row: " + << testImPtr->GetGCPRow(i) << ", " << "col: " << testImPtr->GetGCPCol(i) << ", " << "X: " + << testImPtr->GetGCPX(i) << ", " << "Y: " << testImPtr->GetGCPY(i) << ", " << "Z: " + << testImPtr->GetGCPZ(i) << ")" << std::endl; + errcount++; + } + } + } + if (errcount > 0) + { + std::cout << "<DartMeasurement name=\"MetadataError\" type=\"numeric/int\">"; + std::cout << errcount; + std::cout << "</DartMeasurement>" << std::endl; + } + return errcount; + +} + +// +// Generate all of the possible baselines +// The possible baselines are generated fromn the baselineFilename using the following algorithm: +// 1) strip the suffix +// 2) append a digit _x +// 3) append the original suffix. +// It the file exists, increment x and continue +// +std::map<std::string, int> TestHelper::RegressionTestbaselines(char *baselineFilename) const +{ + std::map<std::string, int> baselines; + baselines[std::string(baselineFilename)] = 0; + + std::string originalBaseline(baselineFilename); + + int x = 0; + std::string::size_type suffixPos = originalBaseline.rfind("."); + std::string suffix; + if (suffixPos != std::string::npos) + { + suffix = originalBaseline.substr(suffixPos, originalBaseline.length()); + originalBaseline.erase(suffixPos, originalBaseline.length()); + } + while (++x) + { + ::itk::OStringStream filename; + filename << originalBaseline << "." << x << suffix; + std::ifstream filestream(filename.str().c_str()); + if (!filestream) + { + break; + } + baselines[filename.str()] = 0; + filestream.close(); + } + return baselines; +} + +int TestHelper::RegressionTestOgrFile(const char *testOgrFilename, const char *baselineOgrFilename, + const double toleranceDiffValue) const +{ + const char *ref_pszDataSource = baselineOgrFilename; + const char *test_pszDataSource = testOgrFilename; + const char *ref_pszWHERE = NULL; + const char *test_pszWHERE = NULL; + int bReadOnly = FALSE; + int nbdiff(0); + /* -------------------------------------------------------------------- */ + /* Open data source. */ + /* -------------------------------------------------------------------- */ + OGRDataSource *ref_poDS = NULL; + OGRSFDriver *ref_poDriver = NULL; + OGRGeometry *ref_poSpatialFilter = NULL; + OGRDataSource *test_poDS = NULL; + OGRSFDriver *test_poDriver = NULL; + OGRGeometry *test_poSpatialFilter = NULL; + + OGRRegisterAll(); + + ref_poDS = OGRSFDriverRegistrar::Open(ref_pszDataSource, !bReadOnly, &ref_poDriver); + if (ref_poDS == NULL && !bReadOnly) + { + ref_poDS = OGRSFDriverRegistrar::Open(ref_pszDataSource, FALSE, &ref_poDriver); + if (ref_poDS != NULL && m_ReportErrors) + { + std::cout << "Had to open REF data source read-only.\n"; + bReadOnly = TRUE; + } + } + test_poDS = OGRSFDriverRegistrar::Open(test_pszDataSource, !bReadOnly, &test_poDriver); + if (test_poDS == NULL && !bReadOnly) + { + test_poDS = OGRSFDriverRegistrar::Open(test_pszDataSource, FALSE, &test_poDriver); + if (test_poDS != NULL && m_ReportErrors) + { + std::cout << "Had to open REF data source read-only.\n"; + bReadOnly = TRUE; + } + } + /* -------------------------------------------------------------------- */ + /* Report failure */ + /* -------------------------------------------------------------------- */ + if (ref_poDS == NULL) + { + OGRSFDriverRegistrar *ref_poR = OGRSFDriverRegistrar::GetRegistrar(); + + if (m_ReportErrors) + std::cout << "FAILURE:\n" + "Unable to open REF datasource `" << ref_pszDataSource << "' with the following drivers." << std::endl; + for (int iDriver = 0; iDriver < ref_poR->GetDriverCount(); ++iDriver) + { + std::cout << " -> " << ref_poR->GetDriver(iDriver)->GetName() << std::endl; + } + return (1); + } CPLAssert( ref_poDriver != NULL); + + if (test_poDS == NULL) + { + OGRSFDriverRegistrar *test_poR = OGRSFDriverRegistrar::GetRegistrar(); + + if (m_ReportErrors) + std::cout << "FAILURE:\n" + "Unable to open TEST datasource `" << test_pszDataSource << "' with the following drivers." << std::endl; + for (int iDriver = 0; iDriver < test_poR->GetDriverCount(); ++iDriver) + { + std::cout << " -> " << test_poR->GetDriver(iDriver)->GetName() << std::endl; + } + return (1); + } CPLAssert( test_poDriver != NULL); + + /* -------------------------------------------------------------------- */ + /* Some information messages. */ + /* -------------------------------------------------------------------- */ + otbCheckStringValue("INFO: using driver", ref_poDriver->GetName(),test_poDriver->GetName(),nbdiff,m_ReportErrors ); + + // otbCheckStringValue("INFO: Internal data source name", ref_poDS->GetName(),test_poDS->GetName(),nbdiff,m_ReportErrors ); + std::string strRefName(ref_poDS->GetName()); + std::string strTestName(test_poDS->GetName()); + if (strRefName != strTestName) + { + if (!m_ReportErrors) + otbPrintDiff("WARNING: INFO: Internal data source name poDS->GetName() were different",strRefName,strTestName); + } + + /* -------------------------------------------------------------------- */ + /* Process each data source layer. */ + /* -------------------------------------------------------------------- */ + otbCheckValue("GetLayerCount()", ref_poDS->GetLayerCount(),test_poDS->GetLayerCount(),nbdiff,m_ReportErrors ); + + for (int iLayer = 0; iLayer < ref_poDS->GetLayerCount(); ++iLayer) + { + OGRLayer *ref_poLayer = ref_poDS->GetLayer(iLayer); + OGRLayer *test_poLayer = test_poDS->GetLayer(iLayer); + + if (ref_poLayer == NULL) + { + if (m_ReportErrors) + std::cout << "FAILURE: Couldn't fetch advertised layer " << iLayer << " for REF data source" << std::endl; + return (1); + } + if (test_poLayer == NULL) + { + if (m_ReportErrors) + std::cout << "FAILURE: Couldn't fetch advertised layer " << iLayer << " for REF data source" << std::endl; + return (1); + } + + //Check Layer inforamtion + ogrReportOnLayer(ref_poLayer, ref_pszWHERE, ref_poSpatialFilter, test_poLayer, test_pszWHERE, test_poSpatialFilter, + nbdiff); + + //If no difference, check the feature + if (nbdiff == 0) + { + OGRFeature *ref_poFeature = NULL; + OGRFeature *test_poFeature = NULL; + std::string basefilename(test_pszDataSource); + int nbFeature(0); + otb::StringStream oss2; + oss2.str(""); + oss2 << iLayer; + + while ((ref_poFeature = ref_poLayer->GetNextFeature()) != NULL) + { + test_poFeature = test_poLayer->GetNextFeature(); + otb::StringStream oss; + oss.str(""); + oss << nbFeature; + + std::string ref_filename = basefilename + "_temporary_layer_" + oss2.str() + "_feature_" + oss.str() + + "_ref.txt"; + std::string test_filename = basefilename + "_temporary_layer_" + oss2.str() + "_feature_" + oss.str() + + "_test.txt"; + FILE *ref_f(NULL); + ref_f = fopen(ref_filename.c_str(), "w"); + if (ref_f == NULL) + { + itkGenericExceptionMacro(<<"Impossible to create ASCII file <"<<ref_filename<<">."); + } + ref_poFeature->DumpReadable(ref_f); + delete ref_poFeature; + fclose(ref_f); + + FILE *test_f(NULL); + test_f = fopen(test_filename.c_str(), "w"); + if (test_f == NULL) + { + itkGenericExceptionMacro(<<"Impossible to create ASCII file <"<<test_filename<<">."); + } + test_poFeature->DumpReadable(test_f); + delete test_poFeature; + fclose(test_f); + + //Check ASCII comparaison + std::vector<std::string> ignoredLines; + ignoredLines.clear(); + nbdiff = RegressionTestAsciiFile(test_filename.c_str(), ref_filename.c_str(), toleranceDiffValue, + ignoredLines); + + nbFeature++; + } + // If no verbose and an diff was found, exit checking. The full checking will be executed in verbose mode + if ((!m_ReportErrors) && (nbdiff != 0)) + return (1); + } //if(nbdiff == 0) + + } + + /* -------------------------------------------------------------------- */ + /* Close down. */ + /* -------------------------------------------------------------------- */ + /* CSLDestroy( papszArgv ); + CSLDestroy( papszLayers ); + CSLDestroy( papszOptions );*/ + delete ref_poDS; + if (ref_poSpatialFilter) + delete ref_poSpatialFilter; + delete test_poDS; + if (test_poSpatialFilter) + delete test_poSpatialFilter; + + delete OGRSFDriverRegistrar::GetRegistrar(); + + OSRCleanup(); + CPLFinderClean(); + VSICleanupFileManager(); + CPLFreeConfig(); + CPLCleanupTLS(); + + return (nbdiff != 0) ? 1 : 0; + +} + +// Regression Testing Code + +bool TestHelper::isNumber(int i) const +{ + return ((i > 47) && (i < 58)); +} + +bool TestHelper::isHexaNumber(int i) const +{ + return (((i > 47) && (i < 58)) || ((i > 96) && (i < 103))); +} + +bool TestHelper::isPoint(int i) const +{ + return (i == 46); +} + +bool TestHelper::isMinusSign(int i) const +{ + return (i == 45); +} + +bool TestHelper::isNumeric(std::string str) const +{ + int nbOfPoints = 0; + int nbOfNumbers = 0; + int number; + unsigned int i = 0; + bool result = true; + + while ((i < str.size()) && (result == true)) + { + number = str[i]; + + if (isPoint(number)) + ++nbOfPoints; + if (isNumber(number)) + ++nbOfNumbers; + if ((!isNumber(number) && !isPoint(number) && !isMinusSign(number)) || (isMinusSign(number) && (i != 0))) + result = false; + + ++i; + } + if ((str.size() == 0) || (nbOfPoints > 1)/*||(nbOfNumbers==0)*/) + result = false; + + return result; +} + +bool TestHelper::isScientificNumeric(std::string str) const +{ + + int number(0); + number = str[0]; + bool pointDetected(false); + bool eDetected(false); + bool signDetected(false); + + // Analyse first character (+, -, 0...9) + unsigned int cpt(0); + if ((str[0] != '+') && (str[0] != '-') && (!isNumber(number))) + return false; + if ((str[0] == '+') || (str[0] == '-')) + { + cpt++; + signDetected = true; + } + + while (cpt < str.size()) + { + if (str[cpt] == '.') + { + // Exit false if two points or if e already detected + if ((pointDetected == true) || (eDetected == true)) + return false; + pointDetected = true; + } + else if ((str[cpt] == 'e') || (str[cpt] == 'E')) + { + // Exit false if two e + if (eDetected == true) + return false; + eDetected = true; + } + else if ((str[cpt] == '-') || (str[cpt] == '+')) + { + // Exit false if already sign with no E detected + if ((signDetected == true) && (eDetected == false)) + return false; + signDetected = true; + } + else + { + number = str[cpt]; + if (!isNumber(number)) + return false; + } + cpt++; + } + + return true; +} + +bool TestHelper::isHexaPointerAddress(std::string str) const +{ + unsigned int size(0); + bool result(false); + unsigned int start(0); + //If (0xadresss) + if ((str[0] == 40) && (str[str.size() - 1] == 41) && (str[1] == 48) && (str[2] == 120)) + { + result = true; + start = 3; + size = str.size() - 1; + } + //If 0xadresss + else if ((str[0] == 48) && (str[1] == 120)) + { + result = true; + start = 2; + size = str.size(); + } + // if 01adress + else if ((str[0] == 48) && (str[1] == 49)) + { + result = true; + start = 2; + size = str.size(); + } + + unsigned int i(start); + while (result && (i < size)) + { + result = result && isHexaNumber(str[i]); + ++i; + } + return result; +} + +bool TestHelper::CompareLines(std::string strfileref, std::string strfiletest, int& nbdiff, std::ofstream& fluxfilediff, int& numLine, + std::vector<std::string>& listStrDiffLineFileRef, std::vector<std::string>& listStrDiffLineFileTest, + double epsilon) const +{ + otb::StringStream buffstreamRef, buffstreamTest; + buffstreamRef << strfileref; + buffstreamTest << strfiletest; + //Number of differences in the current line + bool differenceFoundInCurrentLine = false; + + enum TypeEtat + { + ETAT_NUM, ETAT_CHAR + }; + + TypeEtat etatPrec(ETAT_NUM), etatCour(ETAT_NUM); + + + while (buffstreamRef.peek() != EOF) + { + std::string strRef = ""; + std::string strTest = ""; + + std::string strNumRef = ""; + std::string strCharRef = ""; + std::string strNumTest = ""; + std::string strCharTest = ""; + + buffstreamRef >> strRef; + buffstreamTest >> strTest; + + bool chgt = false; + std::string charTmpRef = ""; + std::string charTmpTest = ""; + + + if (!isHexaPointerAddress(strRef)) + { + //Analyse if strRef contains scientific value (ex: "-142.124e-012") + if (isScientificNumeric(strRef)) + { + if (!isScientificNumeric(strTest)) + { + if (m_ReportErrors) + { + fluxfilediff << "Diff at line " << numLine << " : compare numeric value with no numeric value (" + << strRef << strRef << " != " << strTest << ")" << std::endl; + differenceFoundInCurrentLine = true; + } + nbdiff++; + + } + else if ((strRef != strTest) + && (vcl_abs(atof(strRef.c_str())) > m_EpsilonBoundaryChecking) + && (vcl_abs( + atof(strRef.c_str()) - atof(strTest.c_str())) > epsilon * vcl_abs(atof(strRef.c_str()))))//epsilon as relative error + { + if (m_ReportErrors) + { + fluxfilediff << "Diff at line " << numLine << " : vcl_abs ( (" << strRef << ") - (" << strTest + << ") ) > " << epsilon << std::endl; + differenceFoundInCurrentLine = true; + } + nbdiff++; + } + } + else + { + unsigned int i = 0; + while (i < strRef.size()) + { + charTmpRef = strRef[i]; + + if (i < strTest.size()) + { + charTmpTest = strTest[i]; + } + + if (isNumeric(charTmpRef)) + etatCour = ETAT_NUM; + else + etatCour = ETAT_CHAR; + + // "reference" state initialisation. + if (i == 0) + etatPrec = etatCour; + + // Case where there's a number after characteres. + if ((etatCour == ETAT_NUM) && (etatPrec == ETAT_CHAR)) + { + if (strCharRef != strCharTest) + { + if (m_ReportErrors) + { + fluxfilediff << "Diff at line " << numLine << " : " << strCharRef << " != " << strCharTest + << std::endl; + differenceFoundInCurrentLine = true; + } + nbdiff++; + } + + strCharRef = ""; + strCharTest = ""; + strNumRef = charTmpRef; + strNumTest = charTmpTest; + chgt = true; + } + // Case where there's a character after numbers. + else if ((etatCour == ETAT_CHAR) && (etatPrec == ETAT_NUM)) + { + + if ((strNumRef != strNumTest) && (vcl_abs(atof(strNumRef.c_str())) > m_EpsilonBoundaryChecking) + && (vcl_abs(atof(strNumRef.c_str()) - atof(strNumTest.c_str())) > epsilon * vcl_abs(atof( + strNumRef.c_str())))) //epsilon as relative error + { + if (m_ReportErrors) + { + fluxfilediff << "Diff at line " << numLine << " : vcl_abs ( (" << strNumRef << ") - (" + << strNumTest << ") ) > " << epsilon << std::endl; + differenceFoundInCurrentLine = true; + } + nbdiff++; + } + + strNumRef = ""; + strNumTest = ""; + strCharRef = charTmpRef; + strCharTest = charTmpTest; + chgt = true; + } + else if (etatCour == etatPrec) + { + if (etatCour == ETAT_CHAR) + { + strCharRef += charTmpRef; + strCharTest += charTmpTest; + } + else + { + strNumRef += charTmpRef; + strNumTest += charTmpTest; + } + } + + etatPrec = etatCour; + ++i; + } + + // Simpliest case : string characters or numeric value between 2 separators + if (!chgt) + { + if (isNumeric(strRef)) + { + + if ((strRef != strTest) && (vcl_abs(atof(strRef.c_str())) > m_EpsilonBoundaryChecking) && (vcl_abs( + atof(strRef.c_str()) - atof(strTest.c_str())) > epsilon * vcl_abs(atof(strRef.c_str())))) //epsilon as relative error + { + if (m_ReportErrors) + { + fluxfilediff << "Diff at line " << numLine << " : vcl_abs( (" << strRef << ") - (" << strTest + << ") ) > " << epsilon << std::endl; + differenceFoundInCurrentLine = true; + } + nbdiff++; + } + } + else + { + if (strRef != strTest) + { + if (m_ReportErrors) + { + fluxfilediff << "Diff at line " << numLine << " : " << strRef << " != " << strTest << std::endl; + differenceFoundInCurrentLine = true; + } + nbdiff++; + } + } + } + } // else + } // if(!isHexaPointerAddress(strRef)) + else + { + if (m_ReportErrors) + { + fluxfilediff << "Pointer address found at line " << numLine << " : " << strRef + << " -> comparison skipped." << std::endl; + } + } + } + + numLine++; + //Store alls differences lines + if (differenceFoundInCurrentLine && m_ReportErrors) + { + listStrDiffLineFileRef.push_back(strfileref); + listStrDiffLineFileTest.push_back(strfiletest); + } + + return differenceFoundInCurrentLine; +} + +std::string TestHelper::VectorToString(otb::MetaDataKey::VectorType vector) const +{ + otb::StringStream oss; + oss.str(""); + otb::MetaDataKey::VectorType::iterator it = vector.begin(); + oss << "["; + while (it != vector.end()) + { + oss << (*it); + ++it; + if (it == vector.end()) + { + oss << "]"; + break; + } + else + { + oss << ", "; + } + } + return oss.str(); +} + +/************************************************************************/ +/* ReportOnLayer() */ +/************************************************************************/ + +void TestHelper::ogrReportOnLayer(OGRLayer * ref_poLayer, const char *ref_pszWHERE, OGRGeometry *ref_poSpatialFilter, + OGRLayer * test_poLayer, const char *test_pszWHERE, OGRGeometry *test_poSpatialFilter, int & nbdiff) const + +{ + OGRFeatureDefn *ref_poDefn = ref_poLayer->GetLayerDefn(); + OGRFeatureDefn *test_poDefn = test_poLayer->GetLayerDefn(); + + /* -------------------------------------------------------------------- */ + /* Set filters if provided. */ + /* -------------------------------------------------------------------- */ + otbCheckStringValue("pszWHERE",ref_pszWHERE,test_pszWHERE,nbdiff,m_ReportErrors); + + if (ref_pszWHERE != NULL) + ref_poLayer->SetAttributeFilter(ref_pszWHERE); + + if (ref_poSpatialFilter != NULL) + ref_poLayer->SetSpatialFilter(ref_poSpatialFilter); + + if (test_pszWHERE != NULL) + test_poLayer->SetAttributeFilter(test_pszWHERE); + + if (test_poSpatialFilter != NULL) + test_poLayer->SetSpatialFilter(test_poSpatialFilter); + + /* -------------------------------------------------------------------- */ + /* Report various overall information. */ + /* -------------------------------------------------------------------- */ + printf("\n"); + + otbCheckStringValue("Layer name", ref_poDefn->GetName() ,test_poDefn->GetName() ,nbdiff,m_ReportErrors); + + otbCheckStringValue( "Geometry", OGRGeometryTypeToName( ref_poDefn->GetGeomType() ), OGRGeometryTypeToName( test_poDefn->GetGeomType() ),nbdiff, m_ReportErrors ); + + otbCheckValue("Feature Count", ref_poLayer->GetFeatureCount(),test_poLayer->GetFeatureCount(),nbdiff ,m_ReportErrors); + + OGREnvelope ref_oExt; + OGREnvelope test_oExt; + + otbCheckValue("GetExtent",ref_poLayer->GetExtent(&ref_oExt, TRUE),test_poLayer->GetExtent(&test_oExt, TRUE), nbdiff, m_ReportErrors); + + if (ref_poLayer->GetExtent(&ref_oExt, TRUE) == OGRERR_NONE) + { + otbCheckValue("Extent: MinX",ref_oExt.MinX,test_oExt.MinX,nbdiff,m_ReportErrors); + otbCheckValue("Extent: MinY",ref_oExt.MinY,test_oExt.MinY,nbdiff,m_ReportErrors); + otbCheckValue("Extent: MaxX",ref_oExt.MaxX,test_oExt.MaxX,nbdiff,m_ReportErrors); + otbCheckValue("Extent: MaxY",ref_oExt.MaxY,test_oExt.MaxY,nbdiff,m_ReportErrors); + } + + char *ref_pszWKT; + char *test_pszWKT; + + if (ref_poLayer->GetSpatialRef() == NULL) + ref_pszWKT = CPLStrdup("(unknown)"); + else + { + ref_poLayer->GetSpatialRef()->exportToPrettyWkt(&ref_pszWKT); + } + if (test_poLayer->GetSpatialRef() == NULL) + test_pszWKT = CPLStrdup("(unknown)"); + else + { + test_poLayer->GetSpatialRef()->exportToPrettyWkt(&test_pszWKT); + } + + otbCheckStringValue( "Layer SRS WKT", ref_pszWKT,test_pszWKT ,nbdiff,m_ReportErrors); + + CPLFree(ref_pszWKT); + CPLFree(test_pszWKT); + + otbCheckStringValue( "FID Column", ref_poLayer->GetFIDColumn(),test_poLayer->GetFIDColumn() ,nbdiff,m_ReportErrors); + otbCheckStringValue( "Geometry Column", ref_poLayer->GetGeometryColumn(),test_poLayer->GetGeometryColumn() ,nbdiff,m_ReportErrors); + otbCheckValue("GetFieldCount",ref_poDefn->GetFieldCount(),test_poDefn->GetFieldCount(),nbdiff,m_ReportErrors); + if (ref_poDefn->GetFieldCount() == test_poDefn->GetFieldCount()) + { + for (int iAttr = 0; iAttr < ref_poDefn->GetFieldCount(); ++iAttr) + { + OGRFieldDefn *ref_poField = ref_poDefn->GetFieldDefn(iAttr); + OGRFieldDefn *test_poField = test_poDefn->GetFieldDefn(iAttr); + + otbCheckStringValue( "Field GetName",ref_poField->GetNameRef(),test_poField->GetNameRef(),nbdiff,m_ReportErrors); + otbCheckStringValue( "Field GetFieldTypeName",ref_poField->GetFieldTypeName( ref_poField->GetType() ),test_poField->GetFieldTypeName( test_poField->GetType() ),nbdiff,m_ReportErrors); + otbCheckValue( "Field GetWidth",ref_poField->GetWidth(),test_poField->GetWidth(),nbdiff,m_ReportErrors); + otbCheckValue( "Field GetPrecision",ref_poField->GetPrecision(),test_poField->GetPrecision(),nbdiff,m_ReportErrors); + } + } + + /* -------------------------------------------------------------------- */ + /* Read, and dump features. */ + /* -------------------------------------------------------------------- */ + + //Check the feature contains only if no differences found + +} + +} + diff --git a/Code/Testing/otbTestHelper.h b/Code/Testing/otbTestHelper.h new file mode 100644 index 0000000000..6765ab8642 --- /dev/null +++ b/Code/Testing/otbTestHelper.h @@ -0,0 +1,109 @@ +/*========================================================================= + + Program: ORFEO Toolbox + Language: C++ + Date: $Date$ + Version: $Revision$ + + + Copyright (c) Centre National d'Etudes Spatiales. All rights reserved. + See OTBCopyright.txt for details. + + Some parts of this code are derived from ITK. See ITKCopyright.txt + for details. + + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef __otbTestHelper_h +#define __otbTestHelper_h + +#include <map> +#include <string> +#include <vector> +#include "otbMetaDataKey.h" + +// OGR Headers files +#include "ogrsf_frmts.h" + +namespace otb +{ +class /*ITK_EXPORT*/TestHelper +{ +public: + TestHelper() : + m_EpsilonBoundaryChecking(1.0e-30), + m_ReportErrors(false), + m_IgnoreLineOrder(false) + {} + + ~TestHelper(){} + + std::map<std::string, int> RegressionTestbaselines(char *baselineFilename) const; + + int RegressionTestImage(int cpt, const char *testImageFilename, const char *baselineImageFilename, + const double toleranceDiffPixelImage) const; + + int RegressionTestOgrFile(const char *testOgrFilename, const char *baselineOgrFilename, + const double toleranceDiffValue) const; + + int RegressionTestBinaryFile(const char * testBinaryFileName, const char * baselineBinaryFileName) const; + + int RegressionTestAsciiFile(const char * testAsciiFileName, const char * baselineAsciiFileName, + const double epsilon, std::vector<std::string> ignoredLines) const; + + int RegressionTestMetaData(const char *testImageFilename, const char *baselineImageFilename, + const double toleranceDiffPixelImage) const; + + void ReportErrorsOn() + { + m_ReportErrors=true; + } + void ReportErrorsOff() + { + m_ReportErrors=false; + } + + void IgnoreLineOrderOn() + { + m_IgnoreLineOrder=true; + } + void IgnoreLineOrderOff() + { + m_IgnoreLineOrder=false; + } + + void SetEpsilonBoundaryChecking(double epsilonBoundary) + { + m_EpsilonBoundaryChecking = epsilonBoundary; + } + +private: + bool isNumber(int i) const; + bool isHexaNumber(int i) const; + bool isPoint(int i) const; + bool isMinusSign(int i) const; + bool isNumeric(std::string str) const; + bool isScientificNumeric(std::string str) const; + bool isHexaPointerAddress(std::string str) const; + std::string VectorToString(otb::MetaDataKey::VectorType vector) const; + //FIXME parameters have to be cleaned up later (this is the first step of refactoring) + bool CompareLines(std::string strfileref, std::string strfiletest, int& nbdiff, std::ofstream& fluxfilediff, int& numLine, + std::vector<std::string>& listStrDiffLineFileRef, std::vector<std::string>& listStrDiffLineFileTest, + double epsilon) const; + + void + ogrReportOnLayer(OGRLayer * ref_poLayer, const char *ref_pszWHERE, OGRGeometry *ref_poSpatialFilter, + OGRLayer * test_poLayer, const char *test_pszWHERE, OGRGeometry *test_poSpatialFilter, int & nbdiff) const; + + double m_EpsilonBoundaryChecking; + bool m_ReportErrors; + bool m_IgnoreLineOrder; + +}; +} + +#endif diff --git a/Code/Testing/otbTestMain.h b/Code/Testing/otbTestMain.h new file mode 100644 index 0000000000..5cd5aa9f7a --- /dev/null +++ b/Code/Testing/otbTestMain.h @@ -0,0 +1,604 @@ +/*========================================================================= + + Program: ORFEO Toolbox + Language: C++ + Date: $Date$ + Version: $Revision$ + + + Copyright (c) Centre National d'Etudes Spatiales. All rights reserved. + See OTBCopyright.txt for details. + + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef __otbTestMain_h +#define __otbTestMain_h + +#include "itkWin32Header.h" +#include <map> +#include <string> +#include <iostream> +#include <fstream> + +#include "itkMultiThreader.h" + +#include "otbTestHelper.h" + + + +typedef int (*MainFuncPointer)(int , char* [] ); +std::map<std::string, MainFuncPointer> StringToTestFunctionMap; + +#define REGISTER_TEST(test) \ +extern int test(int, char* [] ); \ +StringToTestFunctionMap[#test] = test + + + +void RegisterTests(); +void PrintAvailableTests() +{ + std::cout << "Tests available:\n"; + std::map<std::string, MainFuncPointer>::iterator j = StringToTestFunctionMap.begin(); + int i = 0; + while (j != StringToTestFunctionMap.end()) + { + std::cout << i << ". " << j->first << "\n"; + ++i; + ++j; + } +} + +int main(int ac, char* av[] ) +{ + bool lFlagRegression(false); + double lToleranceDiffValue(0); + double lEpsilon(0); + bool lIgnoreOrder(false); + double epsilonBoundary(0.0); + + std::vector<std::string> baselineFilenamesBinary; + std::vector<std::string> testFilenamesBinary; + std::vector<std::string> baselineFilenamesMetaData; + std::vector<std::string> testFilenamesMetaData; + std::vector<std::string> baselineFilenamesOgr; + std::vector<std::string> testFilenamesOgr; + + std::vector<std::string> baselineFilenamesImage; + std::vector<std::string> testFilenamesImage; + std::vector<std::string> baselineFilenamesAscii; + std::vector<std::string> testFilenamesAscii; + std::vector<std::string> ignoredLines; + ignoredLines.clear(); + + otb::TestHelper testHelper; + +// On some sgi machines, threads and stl don't mix. +#if defined(__sgi) && defined(_COMPILER_VERSION) && _COMPILER_VERSION <= 730 + itk::MultiThreader::SetGlobalDefaultNumberOfThreads(1); +#endif + + RegisterTests(); + std::string testToRun; + if (ac < 2) + { + PrintAvailableTests(); + std::cout << "To launch a test, enter its number: "; + int testNum = 0; + std::cin >> testNum; + std::map<std::string, MainFuncPointer>::iterator j = StringToTestFunctionMap.begin(); + int i = 0; + while (j != StringToTestFunctionMap.end() && i < testNum) + { + ++i; + ++j; + } + if (j == StringToTestFunctionMap.end()) + { + std::cerr << testNum << " is not a valid test number\n"; + return -1; + } + testToRun = j->first; + } + else + { + if (strcmp(av[1], "--with-threads") == 0) + { + int numThreads = atoi(av[2]); + itk::MultiThreader::SetGlobalDefaultNumberOfThreads(numThreads); + av += 2; + ac -= 2; + } + else if (strcmp(av[1], "--without-threads") == 0) + { + itk::MultiThreader::SetGlobalDefaultNumberOfThreads(1); + av += 1; + ac -= 1; + } + if (strcmp(av[1], "--ignore-order") == 0) + { + lIgnoreOrder = true; + av += 1; + ac -= 1; + } + if (strcmp(av[1], "--epsilon-boundary") == 0) + { + epsilonBoundary = atof(av[2]); + av += 2; + ac -= 2; + } + if (strcmp(av[1], "--compare-image") == 0) + { + lFlagRegression = true; + lToleranceDiffValue = (double)(::atof(av[2])); + baselineFilenamesImage.reserve(1); + testFilenamesImage.reserve(1); + baselineFilenamesImage.push_back(av[3]); + testFilenamesImage.push_back(av[4]); + av += 4; + ac -= 4; + } + else if (strcmp(av[1], "--compare-n-images") == 0) + { + lFlagRegression = true; + lToleranceDiffValue = (double)(::atof(av[2])); + // Number of comparisons to do + unsigned int nbComparisons=(unsigned int)(::atoi(av[3])); + baselineFilenamesImage.reserve(nbComparisons); + testFilenamesImage.reserve(nbComparisons); + // Retrieve all the file names + for (unsigned int i = 0; i<nbComparisons;++i) + { + baselineFilenamesImage.push_back(av[4+2*i]); + testFilenamesImage.push_back(av[5+2*i]); + } + av+=3+2*nbComparisons; + ac-=3+2*nbComparisons; + } + else if (strcmp(av[1], "--compare-binary") == 0) + { + lFlagRegression = true; + baselineFilenamesBinary.reserve(1); + testFilenamesBinary.reserve(1); + baselineFilenamesBinary.push_back(av[2]); + testFilenamesBinary.push_back(av[3]); + av += 3; + ac -= 3; + } + else if (strcmp(av[1], "--compare-n-binary") == 0) + { + lFlagRegression = true; + unsigned int nbComparisons=(unsigned int)(::atoi(av[2])); + baselineFilenamesBinary.reserve(nbComparisons); + testFilenamesBinary.reserve(nbComparisons); + // Retrieve all the file names + for (unsigned int i = 0; i<nbComparisons;++i) + { + baselineFilenamesBinary.push_back(av[3+2*i]); + testFilenamesBinary.push_back(av[4+2*i]); + } + av+=2+2*nbComparisons; + ac-=2+2*nbComparisons; + } + else if (strcmp(av[1], "--compare-ascii") == 0) + { + lFlagRegression = true; + lEpsilon = (double)(::atof(av[2])); + baselineFilenamesAscii.reserve(1); + testFilenamesAscii.reserve(1); + baselineFilenamesAscii.push_back(av[3]); + testFilenamesAscii.push_back(av[4]); + av += 4; + ac -= 4; + + if ( ac > 1 ) + { + if (strcmp(av[1], "--ignore-lines-with") == 0) + { + unsigned int nbIgnoredLines=(unsigned int)(::atoi(av[2])); + for (unsigned int i=0; i<nbIgnoredLines; ++i ) + { + ignoredLines.push_back(av[3+i]); + } + av += 2+nbIgnoredLines; + ac -= 2+nbIgnoredLines; + } + } + } + else if (strcmp(av[1], "--compare-n-ascii") == 0) + { + lFlagRegression = true; + lEpsilon = (double)(::atof(av[2])); + // Number of comparisons to do + unsigned int nbComparisons=(unsigned int)(::atoi(av[3])); + baselineFilenamesAscii.reserve(nbComparisons); + testFilenamesAscii.reserve(nbComparisons); + // Retrieve all the file names + for (unsigned int i = 0; i<nbComparisons;++i) + { + baselineFilenamesAscii.push_back(av[4+2*i]); + testFilenamesAscii.push_back(av[5+2*i]); + } + av+=3+2*nbComparisons; + ac-=3+2*nbComparisons; + + if ( ac > 1 ) + { + if (strcmp(av[1], "--ignore-lines-with") == 0) + { + unsigned int nbIgnoredLines=(unsigned int)(::atoi(av[2])); + for (unsigned int i=0; i<nbIgnoredLines; ++i ) + { + ignoredLines.push_back(av[3+i]); + } + av += 2+nbIgnoredLines; + ac -= 2+nbIgnoredLines; + } + } + + } + else if (strcmp(av[1], "--compare-metadata") == 0) + { + lFlagRegression = true; + lToleranceDiffValue = (double)(::atof(av[2])); + baselineFilenamesMetaData.reserve(1); + testFilenamesMetaData.reserve(1); + baselineFilenamesMetaData.push_back(av[3]); + testFilenamesMetaData.push_back(av[4]); + av += 4; + ac -= 4; + } + + else if (strcmp(av[1], "--compare-ogr") == 0) + { + lFlagRegression = true; + lToleranceDiffValue = (double)(::atof(av[2])); + baselineFilenamesOgr.reserve(1); + testFilenamesOgr.reserve(1); + baselineFilenamesOgr.push_back(av[3]); + testFilenamesOgr.push_back(av[4]); + av += 4; + ac -= 4; + } + testToRun = av[1]; + } + std::map<std::string, MainFuncPointer>::iterator j = StringToTestFunctionMap.find(testToRun); + if (j != StringToTestFunctionMap.end()) + { + MainFuncPointer f = j->second; + int result, multiResult; + try + { + // Invoke the test's "main" function. + result = (*f)(ac-1, av+1); + if (result!=EXIT_SUCCESS) + { + std::cout << "-> Test EXIT FAILURE ("<<result<<")."<<std::endl; + itkGenericExceptionMacro(<<"Function returns EXIT_FAILURE (no regression test)"); + } + } + catch ( itk::ExceptionObject & e ) + { + std::cerr << "otbTestMain '"<<testToRun<<"': ITK Exception thrown:" << std::endl; + std::cerr << e.GetFile() << ":" << e.GetLine() << ":"<< std::endl; + std::cerr << e.GetDescription() << std::endl; + result = EXIT_FAILURE; + } + catch ( std::bad_alloc & err ) + { + std::cerr << "otbTestMain '"<<testToRun<<"': Exception bad_alloc thrown: "<< std::endl; + std::cerr <<(char*)err.what()<< std::endl; + result = EXIT_FAILURE; + } + catch (const std::exception& e) + { + std::cerr << "otbTestMain '"<<testToRun<<"': std::exception thrown:"<< std::endl; + std::cerr << e.what() << std::endl; + result = EXIT_FAILURE; + } + catch ( ... ) + { + std::cerr << "otbTestMain '"<<testToRun<<"': Unknown exception thrown !" << std::endl; + result = EXIT_FAILURE; + } + + if (result==EXIT_SUCCESS) + { + result = 0; + std::cout << " -> Test EXIT SUCCESS."<<std::endl; + if ( lFlagRegression == false ) + { + std::cout << "------------- No control baseline tests -------------"<<std::endl; + } + else + { + try + { + std::cout << "------------- Start control baseline tests -------------"<<std::endl; + // Make a list of possible baselines + + if (lIgnoreOrder) + { + testHelper.IgnoreLineOrderOn(); + } + else + { + testHelper.IgnoreLineOrderOff(); + } + + if (epsilonBoundary != 0.0) + { + testHelper.SetEpsilonBoundaryChecking(epsilonBoundary); + } + + // Non regression test for images + if ((baselineFilenamesImage.size()>0) && (testFilenamesImage.size()>0)) + { + // Creates iterators on baseline filenames vector and test filenames vector + std::vector<std::string>::iterator itbaselineFilenames = baselineFilenamesImage.begin(); + std::vector<std::string>::iterator itTestFilenames = testFilenamesImage.begin(); + int cpt(1); + // For each couple of baseline and test file, do the comparison + for (;(itbaselineFilenames != baselineFilenamesImage.end()) + &&(itTestFilenames != testFilenamesImage.end()); + ++itbaselineFilenames,++itTestFilenames) + { + std::string baselineFilenameImage = (*itbaselineFilenames); + std::string testFilenameImage = (*itTestFilenames); + + + std::map<std::string,int> baselines = testHelper.RegressionTestbaselines(const_cast<char*>(baselineFilenameImage.c_str())); + std::map<std::string,int>::reverse_iterator baseline = baselines.rbegin(); + multiResult = 1; + std::cout<<"Number of baseline images: "<<baselines.size()<<std::endl; + while (baseline!=baselines.rend() && (multiResult!=0)) + { + std::cout<<"Testing non-regression on image: "<<(baseline->first).c_str()<<std::endl; + testHelper.ReportErrorsOff(); + baseline->second = testHelper.RegressionTestImage(cpt,testFilenameImage.c_str(), + (baseline->first).c_str(), + lToleranceDiffValue); + + multiResult = baseline->second; + ++baseline; + } + if (multiResult != 0) + { + baseline = baselines.rbegin(); + testHelper.ReportErrorsOn(); + baseline->second + = testHelper.RegressionTestImage(cpt,testFilenameImage.c_str(), + (baseline->first).c_str(), + lToleranceDiffValue); + } + cpt++; + result += multiResult; + } + + } + + // Non-regression test for metadata. + if ((baselineFilenamesMetaData.size()>0) && (testFilenamesMetaData.size()>0)) + { + // Creates iterators on baseline filenames vector and test filenames vector + std::vector<std::string>::iterator itbaselineFilenames = baselineFilenamesMetaData.begin(); + std::vector<std::string>::iterator itTestFilenames = testFilenamesMetaData.begin(); + // For each couple of baseline and test file, do the comparison + for (;(itbaselineFilenames != baselineFilenamesMetaData.end()) + &&(itTestFilenames != testFilenamesMetaData.end()); + ++itbaselineFilenames,++itTestFilenames) + { + std::string baselineFilenameImage = (*itbaselineFilenames); + std::string testFilenameImage = (*itTestFilenames); + + std::map<std::string,int> baselines = testHelper.RegressionTestbaselines(const_cast<char*>(baselineFilenameImage.c_str())); + std::map<std::string,int>::reverse_iterator baseline = baselines.rbegin(); + multiResult = 1; + std::cout<<"Number of baseline images: "<<baselines.size()<<std::endl; + while (baseline!=baselines.rend() && (multiResult!=0)) + { + std::cout<<"Testing non-regression on image: "<<(baseline->first).c_str()<<std::endl; + testHelper.ReportErrorsOff(); + baseline->second = testHelper.RegressionTestMetaData(testFilenameImage.c_str(), + (baseline->first).c_str(), + lToleranceDiffValue); + + multiResult = baseline->second; + ++baseline; + } + if (multiResult != 0) + { + baseline = baselines.rbegin(); + testHelper.ReportErrorsOn(); + baseline->second + = testHelper.RegressionTestMetaData(testFilenameImage.c_str(), + (baseline->first).c_str(), + lToleranceDiffValue); + } + result += multiResult; + } + } + + // Non regression test for ascii files + if ((baselineFilenamesAscii.size()>0) && (testFilenamesAscii.size()>0)) + { + + // Creates iterators on baseline filenames vector and test filenames vector + std::vector<std::string>::iterator itbaselineFilenames = baselineFilenamesAscii.begin(); + std::vector<std::string>::iterator itTestFilenames = testFilenamesAscii.begin(); + std::vector<std::string>::iterator itIgnoredLines = ignoredLines.begin(); + + // Warning message + if (ignoredLines.size() > 0 ) + { + std::cout << "The lines containing the expressions "; + for (;itIgnoredLines!=ignoredLines.end();++itIgnoredLines) + { + std::cout << (*itIgnoredLines) <<" "; + } + std::cout << "are not considered"<< std::endl; + } + + // For each couple of baseline and test file, do the comparison + for (;(itbaselineFilenames != baselineFilenamesAscii.end()) + &&(itTestFilenames != testFilenamesAscii.end()); + ++itbaselineFilenames,++itTestFilenames) + { + std::string baselineFilenameAscii = (*itbaselineFilenames); + std::string testFilenameAscii = (*itTestFilenames); + + std::map<std::string,int> baselines = testHelper.RegressionTestbaselines(const_cast<char*>(baselineFilenameAscii.c_str())); + std::map<std::string,int>::reverse_iterator baseline = baselines.rbegin(); + multiResult = 1; + std::cout<<"Number of baseline files: "<<baselines.size()<<std::endl; + while (baseline!=baselines.rend() && (multiResult!=0)) + { + std::cout<<"Testing non-regression on file: "<<(baseline->first).c_str()<<std::endl; + testHelper.ReportErrorsOff(); + baseline->second = testHelper.RegressionTestAsciiFile(testFilenameAscii.c_str(), + (baseline->first).c_str(), + lEpsilon, + ignoredLines); + + multiResult = baseline->second; + ++baseline; + } + if (multiResult != 0) + { + baseline = baselines.rbegin(); + testHelper.ReportErrorsOn(); + baseline->second + = testHelper.RegressionTestAsciiFile(testFilenameAscii.c_str(), + (baseline->first).c_str(), + lEpsilon, + ignoredLines); + } + result += multiResult; + } + } +/******************************************/ +/******************************************/ +/******************************************/ + // Non regression test for binary files + if ((baselineFilenamesBinary.size()>0) && (testFilenamesBinary.size()>0)) + { + // Creates iterators on baseline filenames vector and test filenames vector + std::vector<std::string>::iterator itbaselineFilenames = baselineFilenamesBinary.begin(); + std::vector<std::string>::iterator itTestFilenames = testFilenamesBinary.begin(); + + // For each couple of baseline and test file, do the comparison + for (;(itbaselineFilenames != baselineFilenamesBinary.end()) + &&(itTestFilenames != testFilenamesBinary.end()); + ++itbaselineFilenames,++itTestFilenames) + { + std::string baselineFilenameBinary = (*itbaselineFilenames); + std::string testFilenameBinary = (*itTestFilenames); + + std::map<std::string,int> baselines = testHelper.RegressionTestbaselines(const_cast<char*>(baselineFilenameBinary.c_str())); + std::map<std::string,int>::reverse_iterator baseline = baselines.rbegin(); + multiResult = 1; + std::cout<<"Number of baseline files: "<<baselines.size()<<std::endl; + while (baseline!=baselines.rend() && (multiResult!=0)) + { + std::cout<<"Testing non-regression on file: "<<(baseline->first).c_str()<<std::endl; + testHelper.ReportErrorsOff(); + baseline->second = testHelper.RegressionTestBinaryFile(testFilenameBinary.c_str(), + (baseline->first).c_str()); + + multiResult = baseline->second; + ++baseline; + } + if (multiResult != 0) + { + baseline = baselines.rbegin(); + testHelper.ReportErrorsOn(); + baseline->second + = testHelper.RegressionTestBinaryFile(testFilenameBinary.c_str(), + (baseline->first).c_str()); + } + result += multiResult; + } + } + // Non regression test for OGR files + if ((baselineFilenamesOgr.size()>0) && (testFilenamesOgr.size()>0)) + { + // Creates iterators on baseline filenames vector and test filenames vector + std::vector<std::string>::iterator itbaselineFilenames = baselineFilenamesOgr.begin(); + std::vector<std::string>::iterator itTestFilenames = testFilenamesOgr.begin(); + // For each couple of baseline and test file, do the comparison + for (;(itbaselineFilenames != baselineFilenamesOgr.end()) + &&(itTestFilenames != testFilenamesOgr.end()); + ++itbaselineFilenames,++itTestFilenames) + { + std::string baselineFilenameOgr = (*itbaselineFilenames); + std::string testFilenameOgr = (*itTestFilenames); + + std::map<std::string,int> baselines = testHelper.RegressionTestbaselines(const_cast<char*>(baselineFilenameOgr.c_str())); + std::map<std::string,int>::reverse_iterator baseline = baselines.rbegin(); + multiResult = 1; + std::cout<<"Number of baseline OGR files: "<<baselines.size()<<std::endl; + while (baseline!=baselines.rend() && (multiResult!=0)) + { + std::cout<<"Testing non-regression on OGR file: "<<(baseline->first).c_str()<<std::endl; + testHelper.ReportErrorsOff(); + baseline->second = testHelper.RegressionTestOgrFile(testFilenameOgr.c_str(), + (baseline->first).c_str(), + lToleranceDiffValue); + + multiResult = baseline->second; + ++baseline; + } + if (multiResult != 0) + { + baseline = baselines.rbegin(); + testHelper.ReportErrorsOn(); + baseline->second + = testHelper.RegressionTestOgrFile(testFilenameOgr.c_str(), + (baseline->first).c_str(), + lToleranceDiffValue); + } + result += multiResult; + } + } + + } + catch ( itk::ExceptionObject & e ) + { + std::cerr << "otbTestMain 'control baseline test': ITK Exception thrown:" << std::endl; + std::cerr << e.GetFile() << ":" << e.GetLine() << ":"<< std::endl; + std::cerr << e.GetDescription() << std::endl; + return -1; + } + catch ( std::bad_alloc & err ) + { + std::cerr << "otbTestMain 'control baseline test': Exception bad_alloc thrown: "<< std::endl; + std::cerr <<(char*)err.what()<< std::endl; + return -1; + } + catch (const std::exception& e) + { + std::cerr << "otbTestMain 'control baseline test': std::exception thrown:"<< std::endl; + std::cerr << e.what() << std::endl; + return -1; + } + catch ( ... ) + { + std::cerr << "otbTestMain 'control baseline test': Unknown exception thrown !" << std::endl; + return -1; + } + std::cout << "------------- End control baseline tests -------------"<<std::endl; + } // Fin else de if( lFlagRegression == false ) + } // if (result==EXIT_SUCCESS) + return result; + } + PrintAvailableTests(); + std::cerr << "Failure: " << testToRun << ": no test identified " << testToRun << "\n"; + return -1; +} + +#endif + diff --git a/Testing/Code/BasicFilters/CMakeLists.txt b/Testing/Code/BasicFilters/CMakeLists.txt index 46b90b69c6..41fcdf4d19 100644 --- a/Testing/Code/BasicFilters/CMakeLists.txt +++ b/Testing/Code/BasicFilters/CMakeLists.txt @@ -1808,8 +1808,6 @@ otbImageAndVectorImageOperationFilterNew.cxx otbImageAndVectorImageOperationFilterTest.cxx ) -INCLUDE_DIRECTORIES(${OTB_SOURCE_DIR}/Testing/Code) - OTB_ADD_EXECUTABLE(otbBasicFiltersTests1 "${BasicFilters_SRCS1}" "OTBBasicFilters;OTBIO;OTBTesting") OTB_ADD_EXECUTABLE(otbBasicFiltersTests2 "${BasicFilters_SRCS2}" "OTBBasicFilters;OTBIO;OTBTesting") OTB_ADD_EXECUTABLE(otbBasicFiltersTests3 "${BasicFilters_SRCS3}" "OTBBasicFilters;OTBIO;OTBTesting") diff --git a/Testing/Code/CMakeLists.txt b/Testing/Code/CMakeLists.txt index c7a9d618ac..c8cff58428 100644 --- a/Testing/Code/CMakeLists.txt +++ b/Testing/Code/CMakeLists.txt @@ -26,29 +26,3 @@ IF(OTB_USE_PQXX) SUBDIRS(GeospatialAnalysis) ENDIF(OTB_USE_PQXX) -ADD_LIBRARY(OTBTesting otbTestHelper.cxx) -TARGET_LINK_LIBRARIES(OTBTesting OTBIO) - -IF(OTB_LIBRARY_PROPERTIES) -SET_TARGET_PROPERTIES(OTBTesting PROPERTIES ${OTB_LIBRARY_PROPERTIES}) -ENDIF(OTB_LIBRARY_PROPERTIES) - - -IF(NOT OTB_INSTALL_NO_LIBRARIES) -INSTALL(TARGETS OTBTesting -RUNTIME DESTINATION ${OTB_INSTALL_BIN_DIR_CM24} COMPONENT RuntimeLibraries -LIBRARY DESTINATION ${OTB_INSTALL_LIB_DIR_CM24} COMPONENT RuntimeLibraries -ARCHIVE DESTINATION ${OTB_INSTALL_LIB_DIR_CM24} COMPONENT Development) -ENDIF(NOT OTB_INSTALL_NO_LIBRARIES) - -FILE(GLOB __files1 "${CMAKE_CURRENT_SOURCE_DIR}/*.h") -FILE(GLOB __files2 "${CMAKE_CURRENT_SOURCE_DIR}/*.txx") - -IF(NOT OTB_INSTALL_NO_DEVELOPMENT) -FILE(GLOB __files1 "${CMAKE_CURRENT_SOURCE_DIR}/*.h") -FILE(GLOB __files2 "${CMAKE_CURRENT_SOURCE_DIR}/*.txx") -INSTALL(FILES ${__files1} ${__files2} -DESTINATION ${OTB_INSTALL_INCLUDE_DIR_CM24}/Testing -COMPONENT Development) -ENDIF(NOT OTB_INSTALL_NO_DEVELOPMENT) - diff --git a/Testing/Code/ChangeDetection/CMakeLists.txt b/Testing/Code/ChangeDetection/CMakeLists.txt index f1ad38e09d..c8e50c0b6e 100644 --- a/Testing/Code/ChangeDetection/CMakeLists.txt +++ b/Testing/Code/ChangeDetection/CMakeLists.txt @@ -150,9 +150,6 @@ otbKullbackLeiblerSupervizedDistanceImageFilterNew.cxx otbKullbackLeiblerSupervizedDistanceImageFilter.cxx ) - -INCLUDE_DIRECTORIES(${OTB_SOURCE_DIR}/Testing/Code) - OTB_ADD_EXECUTABLE(otbChangeDetectionTests1 "${BasicChangeDetection_SRCS1}" "OTBChangeDetection;OTBIO;OTBTesting") OTB_ADD_EXECUTABLE(otbChangeDetectionTests2 "${BasicChangeDetection_SRCS2}" "OTBChangeDetection;OTBIO;OTBTesting") diff --git a/Testing/Code/Common/CMakeLists.txt b/Testing/Code/Common/CMakeLists.txt index dd2d36fbf4..9e15a95920 100644 --- a/Testing/Code/Common/CMakeLists.txt +++ b/Testing/Code/Common/CMakeLists.txt @@ -1106,8 +1106,6 @@ otbLabelObjectMapVectorizer.cxx ) -INCLUDE_DIRECTORIES(${OTB_SOURCE_DIR}/Testing/Code) - OTB_ADD_EXECUTABLE(otbCommonTests1 "${BasicCommon_SRCS1}" "OTBIO;OTBTesting") OTB_ADD_EXECUTABLE(otbCommonTests2 "${BasicCommon_SRCS2}" "OTBIO;OTBTesting") OTB_ADD_EXECUTABLE(otbCommonTests3 "${BasicCommon_SRCS3}" "OTBIO;OTBTesting") diff --git a/Testing/Code/DisparityMap/CMakeLists.txt b/Testing/Code/DisparityMap/CMakeLists.txt index 4cbfee47fd..a4f2d2f267 100644 --- a/Testing/Code/DisparityMap/CMakeLists.txt +++ b/Testing/Code/DisparityMap/CMakeLists.txt @@ -368,8 +368,6 @@ otbStreamingWarpImageFilterNew.cxx otbStreamingWarpImageFilter.cxx ) -INCLUDE_DIRECTORIES(${OTB_SOURCE_DIR}/Testing/Code) - OTB_ADD_EXECUTABLE(otbDisparityMapTests1 "${BasicDisparityMap_SRCS1}" "OTBDisparityMap;OTBIO;OTBTesting") OTB_ADD_EXECUTABLE(otbDisparityMapTests2 "${BasicDisparityMap_SRCS2}" "OTBDisparityMap;OTBIO;OTBTesting") OTB_ADD_EXECUTABLE(otbDisparityMapTests3 "${BasicDisparityMap_SRCS3}" "OTBDisparityMap;OTBIO;OTBTesting") diff --git a/Testing/Code/FeatureExtraction/CMakeLists.txt b/Testing/Code/FeatureExtraction/CMakeLists.txt index 4270810c5f..98375e3ee3 100644 --- a/Testing/Code/FeatureExtraction/CMakeLists.txt +++ b/Testing/Code/FeatureExtraction/CMakeLists.txt @@ -1949,8 +1949,6 @@ otbImageToLineSegmentVectorData.cxx otbSqrtSpectralAngleImageFilter.cxx ) -INCLUDE_DIRECTORIES(${OTB_SOURCE_DIR}/Testing/Code) - OTB_ADD_EXECUTABLE(otbFeatureExtractionTests1 "${BasicFeatureExtraction_SRCS1}" "OTBFeatureExtraction;OTBIO;OTBTesting") OTB_ADD_EXECUTABLE(otbFeatureExtractionTests2 "${BasicFeatureExtraction_SRCS2}" "OTBFeatureExtraction;OTBIO;OTBTesting") OTB_ADD_EXECUTABLE(otbFeatureExtractionTests3 "${BasicFeatureExtraction_SRCS3}" "OTBFeatureExtraction;OTBIO;OTBTesting") diff --git a/Testing/Code/Fusion/CMakeLists.txt b/Testing/Code/Fusion/CMakeLists.txt index db145f9574..dbdb8ce9df 100644 --- a/Testing/Code/Fusion/CMakeLists.txt +++ b/Testing/Code/Fusion/CMakeLists.txt @@ -67,8 +67,6 @@ otbSimpleRcsPanSharpeningFusionImageFilterNew.cxx otbSimpleRcsPanSharpeningFusionImageFilter.cxx ) -INCLUDE_DIRECTORIES(${OTB_SOURCE_DIR}/Testing/Code) - OTB_ADD_EXECUTABLE(otbFusionTests1 "${Fusion_SRCS1}" "OTBFusion;OTBIO;OTBTesting") ENDIF( NOT OTB_DISABLE_CXX_TESTING AND BUILD_TESTING ) diff --git a/Testing/Code/GeospatialAnalysis/CMakeLists.txt b/Testing/Code/GeospatialAnalysis/CMakeLists.txt index 55413323c7..6e05112690 100644 --- a/Testing/Code/GeospatialAnalysis/CMakeLists.txt +++ b/Testing/Code/GeospatialAnalysis/CMakeLists.txt @@ -50,8 +50,6 @@ otbPostGISCreateTableTransactorCreate.cxx otbPostGISFromStringTransactorNew.cxx ) -INCLUDE_DIRECTORIES(${OTB_SOURCE_DIR}/Testing/Code) - OTB_ADD_EXECUTABLE(otbGeospatialAnalysisTests "${GEOSPATIALANALYSIS_SRCS}" "OTBGeospatialAnalysis;OTBTesting;OTBCommon;pq;pqxx") ENDIF( NOT OTB_DISABLE_CXX_TESTING AND BUILD_TESTING ) diff --git a/Testing/Code/Gui/CMakeLists.txt b/Testing/Code/Gui/CMakeLists.txt index 1321e4d443..e475f8ec23 100644 --- a/Testing/Code/Gui/CMakeLists.txt +++ b/Testing/Code/Gui/CMakeLists.txt @@ -38,8 +38,6 @@ otbFltkFilterWatcher.cxx otbFltkWriterWatcher.cxx ) -INCLUDE_DIRECTORIES(${OTB_SOURCE_DIR}/Testing/Code) - # ${TIFF_LIBRARY} # To suppress "ld: cycle in dylib re-exports with /usr/X11R6/lib/libGL.dylib" error on APPLE configuration diff --git a/Testing/Code/IO/CMakeLists.txt b/Testing/Code/IO/CMakeLists.txt index b90a136a27..8b04f67289 100755 --- a/Testing/Code/IO/CMakeLists.txt +++ b/Testing/Code/IO/CMakeLists.txt @@ -2298,7 +2298,6 @@ otbImageKeywordlist.cxx otbTerraSarImageMetadataInterface.cxx ) -INCLUDE_DIRECTORIES(${OTB_SOURCE_DIR}/Testing/Code) OTB_ADD_EXECUTABLE(otbIOTests1 "${BasicIO_SRCS1}" "OTBIO;OTBTesting") OTB_ADD_EXECUTABLE(otbIOTests2 "${BasicIO_SRCS2}" "OTBIO;OTBTesting") diff --git a/Testing/Code/Learning/CMakeLists.txt b/Testing/Code/Learning/CMakeLists.txt index 835caf9897..3c35652362 100644 --- a/Testing/Code/Learning/CMakeLists.txt +++ b/Testing/Code/Learning/CMakeLists.txt @@ -461,8 +461,6 @@ otbSVMCrossValidationCostFunctionNew.cxx otbExhaustiveExponentialOptimizerNew.cxx ) -INCLUDE_DIRECTORIES(${OTB_SOURCE_DIR}/Testing/Code) - OTB_ADD_EXECUTABLE(otbLearningTests1 "${BasicLearning_SRCS1}" "OTBLearning;OTBIO;OTBTesting") OTB_ADD_EXECUTABLE(otbLearningTests2 "${BasicLearning_SRCS2}" "OTBLearning;OTBIO;OTBTesting") OTB_ADD_EXECUTABLE(otbLearningTests3 "${BasicLearning_SRCS3}" "OTBLearning;OTBIO;OTBTesting") diff --git a/Testing/Code/Markov/CMakeLists.txt b/Testing/Code/Markov/CMakeLists.txt index ab7fd2c63c..4f1000b229 100644 --- a/Testing/Code/Markov/CMakeLists.txt +++ b/Testing/Code/Markov/CMakeLists.txt @@ -177,8 +177,6 @@ otbMRFSamplerRandomMAPNew.cxx otbMRFSamplerRandomMAP.cxx ) -INCLUDE_DIRECTORIES(${OTB_SOURCE_DIR}/Testing/Code) - OTB_ADD_EXECUTABLE(otbMarkovTests1 "${Markov_SRCS1}" "OTBMarkov;OTBIO;OTBTesting") OTB_ADD_EXECUTABLE(otbMarkovTests2 "${Markov_SRCS2}" "OTBMarkov;OTBIO;OTBTesting") diff --git a/Testing/Code/MultiScale/CMakeLists.txt b/Testing/Code/MultiScale/CMakeLists.txt index f785610364..58713ec678 100644 --- a/Testing/Code/MultiScale/CMakeLists.txt +++ b/Testing/Code/MultiScale/CMakeLists.txt @@ -508,8 +508,6 @@ otbWaveletPacketInverseTransformNew.cxx otbWaveletPacketTransform.cxx ) -INCLUDE_DIRECTORIES(${OTB_SOURCE_DIR}/Testing/Code) - OTB_ADD_EXECUTABLE(otbMultiScaleTests1 "${BasicMultiScale_SRCS1}" "OTBMultiScale;OTBIO;OTBTesting") OTB_ADD_EXECUTABLE(otbMultiScaleTests2 "${BasicMultiScale_SRCS2}" "OTBMultiScale;OTBIO;OTBTesting") OTB_ADD_EXECUTABLE(otbMultiScaleTests3 "${BasicMultiScale_SRCS3}" "OTBMultiScale;OTBIO;OTBTesting") diff --git a/Testing/Code/Projections/CMakeLists.txt b/Testing/Code/Projections/CMakeLists.txt index de321a7998..f1297f73ec 100644 --- a/Testing/Code/Projections/CMakeLists.txt +++ b/Testing/Code/Projections/CMakeLists.txt @@ -487,8 +487,6 @@ otbGeocentricTransform.cxx otbVectorDataExtractROIandProjection.cxx ) -INCLUDE_DIRECTORIES(${OTB_SOURCE_DIR}/Testing/Code) - OTB_ADD_EXECUTABLE(otbProjectionsTests1 "${Projections_SRCS1}" "OTBProjections;OTBIO;OTBTesting") OTB_ADD_EXECUTABLE(otbProjectionsTests2 "${Projections_SRCS2}" "OTBProjections;OTBIO;OTBTesting") OTB_ADD_EXECUTABLE(otbProjectionsTests3 "${Projections_SRCS3}" "OTBProjections;OTBIO;OTBTesting") diff --git a/Testing/Code/Radiometry/CMakeLists.txt b/Testing/Code/Radiometry/CMakeLists.txt index 112cd6eb17..33d770f937 100644 --- a/Testing/Code/Radiometry/CMakeLists.txt +++ b/Testing/Code/Radiometry/CMakeLists.txt @@ -1191,8 +1191,6 @@ otbTerraSarCalibrationCplxImageFilterTest.cxx ) -INCLUDE_DIRECTORIES(${OTB_SOURCE_DIR}/Testing/Code) - OTB_ADD_EXECUTABLE(otbRadiometryTests1 "${Radiometry_SRCS1}" "OTBRadiometry;OTBIO;OTBTesting") OTB_ADD_EXECUTABLE(otbRadiometryTests2 "${Radiometry_SRCS2}" "OTBRadiometry;OTBIO;OTBTesting") OTB_ADD_EXECUTABLE(otbRadiometryTests3 "${Radiometry_SRCS3}" "OTBRadiometry;OTBIO;OTBTesting") diff --git a/Testing/Code/SARPolarimetry/CMakeLists.txt b/Testing/Code/SARPolarimetry/CMakeLists.txt index 4c6ae5f17e..7d562a16d7 100644 --- a/Testing/Code/SARPolarimetry/CMakeLists.txt +++ b/Testing/Code/SARPolarimetry/CMakeLists.txt @@ -134,8 +134,6 @@ otbMultiChannelsPolarimetricSynthesisFilter.cxx otbVectorMultiChannelsPolarimetricSynthesisFilter.cxx ) -INCLUDE_DIRECTORIES(${OTB_SOURCE_DIR}/Testing/Code) - OTB_ADD_EXECUTABLE(otbSARPolarimetryTests1 "${SARPOLARIMETRY_SRCS1}" "OTBSARPolarimetry;OTBIO;OTBTesting") ENDIF( NOT OTB_DISABLE_CXX_TESTING AND BUILD_TESTING ) diff --git a/Testing/Code/SpatialReasoning/CMakeLists.txt b/Testing/Code/SpatialReasoning/CMakeLists.txt index f030da35ea..a5a4d49f54 100644 --- a/Testing/Code/SpatialReasoning/CMakeLists.txt +++ b/Testing/Code/SpatialReasoning/CMakeLists.txt @@ -267,7 +267,7 @@ otbPolygonListToRCC8GraphFilterNew.cxx otbPolygonListToRCC8GraphFilter.cxx ) -INCLUDE_DIRECTORIES(${OTB_SOURCE_DIR}/Testing/Code) + OTB_ADD_EXECUTABLE(otbSpatialReasoningTests1 "${BasicSpatialReasoning_SRCS1}" "OTBSpatialReasoning;OTBIO;OTBTesting") OTB_ADD_EXECUTABLE(otbSpatialReasoningTests2 "${BasicSpatialReasoning_SRCS2}" "OTBSpatialReasoning;OTBIO;OTBTesting") diff --git a/Testing/Code/TestSystem/CMakeLists.txt b/Testing/Code/TestSystem/CMakeLists.txt index d0f490b33a..91883a3cae 100644 --- a/Testing/Code/TestSystem/CMakeLists.txt +++ b/Testing/Code/TestSystem/CMakeLists.txt @@ -131,8 +131,6 @@ otbCompareAsciiTests4.cxx otbCompareAsciiTests5.cxx ) -INCLUDE_DIRECTORIES(${OTB_SOURCE_DIR}/Testing/Code) - OTB_ADD_EXECUTABLE(otbTestSystemTests "${TESTSYSTEM_SRCS}" "OTBTesting;OTBCommon;OTBIO") ENDIF( NOT OTB_DISABLE_CXX_TESTING AND BUILD_TESTING ) diff --git a/Testing/Code/Visu/CMakeLists.txt b/Testing/Code/Visu/CMakeLists.txt index af325be82c..c1f2d4809d 100644 --- a/Testing/Code/Visu/CMakeLists.txt +++ b/Testing/Code/Visu/CMakeLists.txt @@ -218,8 +218,6 @@ otbImageWidgetTransferFunctionsNew.cxx otbImageViewerWithOverlay.cxx ) -INCLUDE_DIRECTORIES(${OTB_SOURCE_DIR}/Testing/Code) - OTB_ADD_EXECUTABLE(otbVisuTests1 "${BasicVisu_SRCS1}" "OTBVisu;OTBIO;OTBTesting") OTB_ADD_EXECUTABLE(otbVisuTests2 "${BasicVisu_SRCS2}" "OTBVisu;OTBIO;OTBTesting") diff --git a/Testing/Code/Visualization/CMakeLists.txt b/Testing/Code/Visualization/CMakeLists.txt index 1ca481da35..8f4a463e2c 100644 --- a/Testing/Code/Visualization/CMakeLists.txt +++ b/Testing/Code/Visualization/CMakeLists.txt @@ -392,8 +392,6 @@ otbSplittedWidgetManagerNew.cxx otbVerticalAsymptoteCurveNew.cxx ) -INCLUDE_DIRECTORIES(${OTB_SOURCE_DIR}/Testing/Code) - OTB_ADD_EXECUTABLE(otbVisualizationTests1 "${Visualization_SRCS1}" "OTBVisualization;OTBIO;OTBTesting") ENDIF( NOT OTB_DISABLE_CXX_TESTING AND BUILD_TESTING ) diff --git a/Testing/Fa/CMakeLists.txt b/Testing/Fa/CMakeLists.txt index b74ced7521..d2ba007f85 100644 --- a/Testing/Fa/CMakeLists.txt +++ b/Testing/Fa/CMakeLists.txt @@ -224,8 +224,6 @@ ADD_TEST(FA-0000041-mean_shift2 ${CXX_TEST_PATH}/0000041-mean_shift # -out ${TEMP}/objtest2-result.tif # ) -INCLUDE_DIRECTORIES(${OTB_SOURCE_DIR}/Testing/Code) - ADD_EXECUTABLE(AlignementsQB AlignementsQB.cxx) TARGET_LINK_LIBRARIES(AlignementsQB OTBFeatureExtraction OTBIO OTBCommon) diff --git a/Testing/Utilities/CMakeLists.txt b/Testing/Utilities/CMakeLists.txt index cd121ce9e7..db6615dafa 100644 --- a/Testing/Utilities/CMakeLists.txt +++ b/Testing/Utilities/CMakeLists.txt @@ -496,12 +496,9 @@ ELSE(CMAKE_COMPILER_IS_GNUCXX) ENDIF(WIN32) ENDIF(CMAKE_COMPILER_IS_GNUCXX) - -INCLUDE_DIRECTORIES(${OTB_SOURCE_DIR}/Testing/Code) INCLUDE_DIRECTORIES("${OTBTesting_BINARY_DIR}") INCLUDE_DIRECTORIES("${CMAKE_CURRENT_SOURCE_DIR}") - IF(NOT BUILD_SHARED_LIBS) ADD_DEFINITIONS(-DOPJ_STATIC) ENDIF(NOT BUILD_SHARED_LIBS) diff --git a/otbIncludeDirectories.cmake b/otbIncludeDirectories.cmake index 58cb6f7ae0..86c5e08598 100644 --- a/otbIncludeDirectories.cmake +++ b/otbIncludeDirectories.cmake @@ -41,6 +41,7 @@ SET(OTB_INCLUDE_DIRS_BUILD_TREE ${OTB_INCLUDE_DIRS_BUILD_TREE} ${OTB_SOURCE_DIR}/Code/SARPolarimetry ${OTB_SOURCE_DIR}/Code/Markov ${OTB_SOURCE_DIR}/Code/GeospatialAnalysis + ${OTB_SOURCE_DIR}/Code/Testing ${OTB_SOURCE_DIR}/Utilities/otbsvm ${OTB_SOURCE_DIR}/Utilities/otbossim ${OTB_SOURCE_DIR}/Utilities/otbossim/include @@ -300,6 +301,8 @@ SET(OTB_INCLUDE_RELATIVE_DIRS ${OTB_INCLUDE_RELATIVE_DIRS} SARPolarimetry Markov Fusion + GeospatialAnalysis + Testing Utilities Utilities/ITK Utilities/otbsvm -- GitLab