Home || Architecture || Video Search || Visual Search || Scripts || Applications || Important Messages || OGL || Src

mainCoreTest.cpp

Go to the documentation of this file.
00001 #include "Basis/CmdOptions.h"
00002 #include "Core/Test/TestWeibull.h"
00003 #include "Core/Test/TestColorSegmentation.h"
00004 #include "Core/Test/TestInvWiccest.h"
00005 #include "Core/Test/TestDumpSmall.h"
00006 #include "Core/Test/TestWatershedMarkers.h"
00007 #include "Core/Test/TestWatershed.h"
00008 #include "Core/Test/TestMatNorm2Dist.h"
00009 #include "Core/Array/Arrays.h"
00010 #include "Core/ImageSet/MakeImageSet.h"
00011 
00012 namespace Impala
00013 {
00014 namespace Samples
00015 {
00016 
00017 
00018 using namespace Impala::Core::Test;
00019 using namespace Impala::Core::Array;
00020 
00021 int
00022 DoTestSuite(std::string testSuite, TestBase** testList)
00023 {
00024     ILOG_VAR(Samples.DoTestSuite);
00025     ILOG_INFO(testSuite << "...");
00026 
00027     // Todo : check memory usage and speed
00028     bool result = true;
00029     for (; *testList; testList++)
00030     {
00031         TestBase* test = *testList;
00032         ArraySystem& aSys = ArraySystem::Instance();
00033         aSys.MarkMemoryUsage(false);
00034         test->Run();
00035         aSys.CheckMemoryUsageSinceMark(false);
00036         if (!test->Result())
00037         {
00038             ILOG_INFO("Test " << test->GetNr() << " " << test->Name()
00039                       << " failed");
00040             test->Report(std::cout);
00041             result = false;
00042         }
00043     }
00044     ILOG_INFO(testSuite << (result ? " OK" : " FAILED"));
00045     return result ? 0 : 1;
00046 }
00047 
00048 
00049 int
00050 mainCoreTest(int argc, char* argv[])
00051 {
00052     CmdOptions& options = CmdOptions::GetInstance();
00053     options.Initialise(false, false, true);
00054     std::string usageStr = "manual|auto\n\n";
00055     usageStr += "  manual tests requires inspection of test output\n";
00056     usageStr += "  auto tests does automatic test on output\n\n";
00057     if (! options.ParseArgs(argc, argv, usageStr, 1))
00058         return 1;
00059 
00060     ILOG_VAR(Samples.mainCoreTest);
00061 
00062     TestImage::SetImageSet(Impala::Core::ImageSet::MakeImageSet("test.txt"));
00063 
00064     int e = 0;
00065     if (options.GetArg(0) == std::string("auto"))
00066     {
00067         e += DoTestSuite("MatNorm2Dist suite", gMatNorm2DistSuite);
00068         e += DoTestSuite("Weibull suite", gWeibullSuite);
00069         e += DoTestSuite("Watershed suite", gWatershedSuite);
00070         e += DoTestSuite("WatershedMarkers suite", gWatershedMarkersSuite);
00071         e += DoTestSuite("InvWiccest suite", gInvWiccestSuite);
00072         e += DoTestSuite("ColorSegmentation suite", gColorSegmentationSuite);
00073     }
00074     else
00075     {
00076         e += DoTestSuite("DumpSmall suite", gDumpSmallSuite);
00077     }
00078     if (e == 0)
00079     {
00080         ILOG_INFO("All OK.");
00081     }
00082     else
00083     {
00084         ILOG_ERROR(e << " test suites failed.");
00085     }
00086 
00087     return 0;
00088 }
00089 
00090 } // namespace Samples
00091 } // namespace Impala
00092 
00093 int
00094 main(int argc, char* argv[])
00095 {
00096     return Impala::Samples::mainCoreTest(argc, argv);
00097 }

Generated on Fri Mar 19 09:30:40 2010 for ImpalaSrc by  doxygen 1.5.1