From 387f2040d326f86f19b96223b5b911b390deb580 Mon Sep 17 00:00:00 2001 From: Vadim Pisarevsky Date: Tue, 19 Oct 2010 13:49:13 +0000 Subject: [PATCH] the path to "opencv/opencv_extra/testdata" can now be set using OPENCV_TEST_DATA_PATH. Filter pattern can now start with ">" or ">=" symbols, meaning - run all the test, beginning from the particular one - convenient for resuming tests after fixing crashed tests --- tests/cv/src/tsysa.cpp | 2 +- tests/cxcore/src/cxcoretest_main.cpp | 2 +- tests/cxts/cxts.cpp | 64 +++++++++++++++++----------- tests/cxts/cxts.h | 6 ++- tests/ml/src/mltest_main.cpp | 2 +- 5 files changed, 46 insertions(+), 30 deletions(-) diff --git a/tests/cv/src/tsysa.cpp b/tests/cv/src/tsysa.cpp index 714cf493d..57cf1a7aa 100644 --- a/tests/cv/src/tsysa.cpp +++ b/tests/cv/src/tsysa.cpp @@ -41,7 +41,7 @@ #include "cvtest.h" -CvTS test_system; +CvTS test_system("cv"); const char* blacklist[] = { diff --git a/tests/cxcore/src/cxcoretest_main.cpp b/tests/cxcore/src/cxcoretest_main.cpp index 1e657d1bd..94a325b52 100644 --- a/tests/cxcore/src/cxcoretest_main.cpp +++ b/tests/cxcore/src/cxcoretest_main.cpp @@ -41,7 +41,7 @@ #include "cxcoretest.h" -CvTS test_system; +CvTS test_system("core"); const char* blacklist[] = { diff --git a/tests/cxts/cxts.cpp b/tests/cxts/cxts.cpp index 4cece0e0d..5c6e3c57c 100644 --- a/tests/cxts/cxts.cpp +++ b/tests/cxts/cxts.cpp @@ -1035,8 +1035,9 @@ int CvBadArgTest::run_test_case( int expected_code, const char* descr ) /******************************** Constructors/Destructors ******************************/ -CvTS::CvTS() +CvTS::CvTS(const char* _module_name) { + module_name = _module_name; start_time = 0; version = CV_TS_VERSION; memory_manager = 0; @@ -1361,34 +1362,18 @@ int CvTS::run( int argc, char** argv, const char** blacklist ) } } -#if 0 -//#if !defined WIN32 && !defined _WIN32 - if (! config_name ) - { - char * confname = getenv("configname"); - if (confname) - config_name = confname; - } - - if( !params.data_path || !params.data_path[0] ) - { - char* datapath = getenv("datapath"); - if( datapath ) - set_data_path(datapath); - } - // this is the fallback for the current OpenCV autotools setup if( !params.data_path || !params.data_path[0] ) { - char* srcdir = getenv("srcdir"); + char* datapath_dir = getenv("OPENCV_TEST_DATA_PATH"); char buf[1024]; - if( srcdir ) + if( datapath_dir ) { - sprintf( buf, "%s/../../opencv_extra/testdata/", srcdir ); + sprintf( buf, "%s/%s", datapath_dir, module_name ? module_name : "" ); + printf( LOG + CONSOLE + SUMMARY, "Data Path = %s\n", buf); set_data_path(buf); } } -#endif if( write_params ) { @@ -1467,6 +1452,8 @@ int CvTS::run( int argc, char** argv, const char** blacklist ) } } + int filter_state = 0; + // 4. traverse through the list of all registered tests. // Initialize the selected tests and put them into the separate sequence for( i = 0; i < all_tests.size(); i++ ) @@ -1475,7 +1462,7 @@ int CvTS::run( int argc, char** argv, const char** blacklist ) if( !(test->get_support_testing_modes() & get_testing_mode()) ) continue; - if( strcmp( test->get_func_list(), "" ) != 0 && filter(test, blacklist) ) + if( strcmp( test->get_func_list(), "" ) != 0 && filter(test, filter_state, blacklist) ) { if( test->init(this) >= 0 ) { @@ -1875,11 +1862,12 @@ static char* cv_strnstr( const char* str, int len, } -int CvTS::filter( CvTest* test, const char** blacklist ) +int CvTS::filter( CvTest* test, int& filter_state, const char** blacklist ) { const char* pattern = params.test_filter_pattern; const char* test_name = test->get_name(); int inverse = 0; + int greater_or_equal = 0; if( blacklist ) { @@ -1895,7 +1883,18 @@ int CvTS::filter( CvTest* test, const char** blacklist ) inverse = 1; pattern++; } - + + if( pattern && pattern[0] == '>' ) + { + greater_or_equal = 1; + pattern++; + if( pattern[0] == '=' ) + { + greater_or_equal = 2; + pattern++; + } + } + if( !pattern || strcmp( pattern, "" ) == 0 || strcmp( pattern, "*" ) == 0 ) return 1 ^ inverse; @@ -1939,7 +1938,22 @@ int CvTS::filter( CvTest* test, const char** blacklist ) break; } - return found ^ inverse; + if( greater_or_equal == 0 ) + return found ^ inverse; + if( filter_state ) + return inverse^1; + if( !found ) + return inverse; + if( greater_or_equal == 1 ) + { + filter_state = 1; + return inverse; + } + if( greater_or_equal == 2 ) + { + filter_state = 1; + return inverse ^ 1; + } } else { diff --git a/tests/cxts/cxts.h b/tests/cxts/cxts.h index 3f1e88413..253b28f5e 100644 --- a/tests/cxts/cxts.h +++ b/tests/cxts/cxts.h @@ -268,7 +268,7 @@ class CV_EXPORTS CvTS public: // constructor(s) and destructor - CvTS(); + CvTS(const char* _module_name=0); virtual ~CvTS(); enum @@ -433,7 +433,7 @@ protected: virtual int read_params( CvFileStorage* fs ); // checks, whether the test needs to be run (1) or not (0); called from run() - virtual int filter( CvTest* test, const char** blacklist=0 ); + virtual int filter( CvTest* test, int& filter_state, const char** blacklist=0 ); // makes base name of output files virtual void make_output_stream_base_name( const char* config_name ); @@ -537,6 +537,8 @@ protected: // name of config file const char* config_name; + + const char* module_name; // information about the current test CvTestInfo current_test_info; diff --git a/tests/ml/src/mltest_main.cpp b/tests/ml/src/mltest_main.cpp index 22c8ae096..52b32b376 100644 --- a/tests/ml/src/mltest_main.cpp +++ b/tests/ml/src/mltest_main.cpp @@ -41,7 +41,7 @@ #include "mltest.h" -CvTS test_system; +CvTS test_system("ml"); const char* blacklist[] = {