//M*/
#include "precomp.hpp"
+#include <opencv2/core/utils/configuration.private.hpp>
+
#include "opencv2/core/core_c.h"
#include <ctype.h>
}
-const CvFileNode* BaseTest::find_param( CvFileStorage* fs, const char* param_name )
+cv::FileNode BaseTest::find_param( const cv::FileStorage& fs, const char* param_name )
{
- CvFileNode* node = cvGetFileNodeByName(fs, 0, get_name().c_str());
- return node ? cvGetFileNodeByName( fs, node, param_name ) : 0;
+ cv::FileNode node = fs[get_name()];
+ return node[param_name];
}
-int BaseTest::read_params( CvFileStorage* )
+int BaseTest::read_params( const cv::FileStorage& )
{
return 0;
}
}
}
-static bool checkTestData = false;
+static bool checkTestData = cv::utils::getConfigurationParameterBool("OPENCV_TEST_REQUIRE_DATA", false);
bool skipUnstableTests = false;
bool runBigDataTests = false;
int testThreads = 0;
{
size_t peak = malloc_peak();
memory_usage = peak - memory_usage_base;
- CV_LOG_INFO(NULL, "Memory_usage (malloc): " << memory_usage << " (base=" << memory_usage_base << ")");
+ if (peak > 0)
+ {
+ CV_LOG_INFO(NULL, "Memory_usage (malloc): " << memory_usage << " (base=" << memory_usage_base << ")");
+ }
}
{
// core/src/alloc.cpp: #define OPENCV_ALLOC_ENABLE_STATISTICS
cv::utils::AllocatorStatisticsInterface& ocv_stats = cv::getAllocatorStatistics();
ocv_peak = ocv_stats.getPeakUsage();
ocv_memory_usage = ocv_peak - memory_usage_base_opencv;
- CV_LOG_INFO(NULL, "Memory_usage (OpenCV): " << ocv_memory_usage << " (base=" << memory_usage_base_opencv << " current=" << ocv_stats.getCurrentUsage() << ")");
+ if (ocv_peak)
+ {
+ CV_LOG_INFO(NULL, "Memory_usage (OpenCV): " << ocv_memory_usage << " (base=" << memory_usage_base_opencv << " current=" << ocv_stats.getCurrentUsage() << ")");
+ }
if (memory_usage == 0) // external profiler has higher priority (and accuracy)
memory_usage = ocv_memory_usage;
}
cv::utils::AllocatorStatisticsInterface& ocl_stats = cv::ocl::getOpenCLAllocatorStatistics();
ocl_peak = ocl_stats.getPeakUsage();
ocl_memory_usage = ocl_peak - memory_usage_base_opencl;
- CV_LOG_INFO(NULL, "Memory_usage (OpenCL): " << ocl_memory_usage << " (base=" << memory_usage_base_opencl << " current=" << ocl_stats.getCurrentUsage() << ")");
+ if (ocl_memory_usage > 0)
+ {
+ CV_LOG_INFO(NULL, "Memory_usage (OpenCL): " << ocl_memory_usage << " (base=" << memory_usage_base_opencl << " current=" << ocl_stats.getCurrentUsage() << ")");
+ }
::testing::Test::RecordProperty("ocl_memory_usage",
cv::format("%llu", (unsigned long long)ocl_memory_usage));
}
void parseCustomOptions(int argc, char **argv)
{
- const char * const command_line_keys =
+ const string command_line_keys = string(
"{ ipp test_ipp_check |false |check whether IPP works without failures }"
"{ test_seed |809564 |seed for random numbers generator }"
"{ test_threads |-1 |the number of worker threads, if parallel execution is enabled}"
"{ skip_unstable |false |skip unstable tests }"
"{ test_bigdata |false |run BigData tests (>=2Gb) }"
- "{ test_require_data |false |fail on missing non-required test data instead of skip}"
+ "{ test_require_data |") + (checkTestData ? "true" : "false") + string("|fail on missing non-required test data instead of skip (env:OPENCV_TEST_REQUIRE_DATA)}"
CV_TEST_TAGS_PARAMS
"{ h help |false |print help info }"
- ;
+ );
cv::CommandLineParser parser(argc, argv, command_line_keys);
if (parser.get<bool>("help"))
skipUnstableTests = parser.get<bool>("skip_unstable");
runBigDataTests = parser.get<bool>("test_bigdata");
- checkTestData = parser.get<bool>("test_require_data");
+ if (parser.has("test_require_data"))
+ checkTestData = parser.get<bool>("test_require_data");
activateTestTags(parser);
}
static std::string findData(const std::string& relative_path, bool required, bool findDirectory)
{
-#define TEST_TRY_FILE_WITH_PREFIX(prefix) \
+#define CHECK_FILE_WITH_PREFIX(prefix, result) \
{ \
+ result.clear(); \
std::string path = path_join(prefix, relative_path); \
/*printf("Trying %s\n", path.c_str());*/ \
if (findDirectory) \
{ \
if (isDirectory(path)) \
- return path; \
+ result = path; \
} \
else \
{ \
FILE* f = fopen(path.c_str(), "rb"); \
if(f) { \
fclose(f); \
- return path; \
+ result = path; \
} \
} \
}
+#define TEST_TRY_FILE_WITH_PREFIX(prefix) \
+{ \
+ std::string result__; \
+ CHECK_FILE_WITH_PREFIX(prefix, result__); \
+ if (!result__.empty()) \
+ return result__; \
+}
+
+
const std::vector<std::string>& search_path = TS::ptr()->data_search_path;
for(size_t i = search_path.size(); i > 0; i--)
{
{
const std::string& subdir = search_subdir[i - 1];
std::string prefix = path_join(datapath, subdir);
- TEST_TRY_FILE_WITH_PREFIX(prefix);
+ std::string result_;
+ CHECK_FILE_WITH_PREFIX(prefix, result_);
+ if (!required && !result_.empty())
+ {
+ std::cout << "TEST ERROR: Don't use 'optional' findData() for " << relative_path << std::endl;
+ static bool checkOptionalFlag = cv::utils::getConfigurationParameterBool("OPENCV_TEST_CHECK_OPTIONAL_DATA", false);
+ if (checkOptionalFlag)
+ {
+ CV_Assert(required || result_.empty());
+ }
+ }
+ if (!result_.empty())
+ return result_;
}
}
}