[Insight-developers] TestDriver Test

William A. Hoffman bill.hoffman@kitware.com
Fri, 01 Mar 2002 17:14:32 -0500


Hi Folks-

Just to see if the testing process we discussed on the TCON was
worth doing at all, I went ahead and converted
just the tests in BasicFilters to my approach.  Here are the results
for this one directory:

The project load time in .NET went from 15 sec. to 8 sec. (1.2 ghz processor).
The number of projects went from 240 to 160.
The binary directory went from 240 megs to 70 megs.
The TestDriver executable was only 2.8 megs.
Changing a test and re-linking/compiling showed no noticeable difference in 
time.

The test driver program looked like this:

#include <map>
#include <string>

typedef int (*MainFunc)(int , char**);

std::map<std::string, MainFunc> ArgsMap;
#define REGISTER_TEST(test) \
extern int test(); \
ArgsMap[#test] = test;

int main(int ac, char** av)
{
   REGISTER_TEST(itkAsinImageFilterAndAdaptorTest );
   REGISTER_TEST(itkAcosImageFilterAndAdaptorTest );
   REGISTER_TEST(itkAtanImageFilterAndAdaptorTest );
....

  std::map<std::string, MainFunc>::iterator i = NoArgsMap.find(av[1]);
   // run the test
   std::map<std::string, MainFuncArgs>::iterator j = ArgsMap.find(av[1]);
   if(j != ArgsMap.end())
     {
     MainFuncArgs f = j->second;
     return (*f)(ac-1, av+1);
     }
}


The CMakeLists.txt file looked like this:

ADD_TEST(itkAsinImageFilterAndAdaptorTest itkBasicFiltersTest 
itkAsinImageFilterAndAdaptorTest)
ADD_TEST(itkAcosImageFilterAndAdaptorTest itkBasicFiltersTest 
itkAcosImageFilterAndAdaptorTest)
....
# a test with data arguments
ADD_TEST(itkConfidenceConnectedImageFilterTest itkBasicFiltersTest 
itkConfidenceConnectedImageFilterTest ${ITK_DATA_ROOT}/Input/cthead1.png 
${ITK_DATA_ROOT}/Baseline/BasicFilters/ConfidenceConnectedImageFilterTest.png)

SOURCE_FILES(BasicFilters_SRCS
itkAsinImageFilterAndAdaptorTest
itkAcosImageFilterAndAdaptorTest
...)



ADD_EXECUTABLE(itkBasicFiltersTest itkBasicFiltersTest.cxx BasicFilters_SRCS)