Set stricter warning rules for gcc
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
#if _MSC_VER >= 1200
|
||||
#if defined _MSC_VER && _MSC_VER >= 1200
|
||||
#pragma warning( disable: 4127 4251)
|
||||
#endif
|
||||
|
||||
#include "opencv2/core/core_c.h"
|
||||
#include "opencv2/ts/ts.hpp"
|
||||
|
||||
#if GTEST_LINKED_AS_SHARED_LIBRARY
|
||||
#ifdef GTEST_LINKED_AS_SHARED_LIBRARY
|
||||
#error ts module should not have GTEST_LINKED_AS_SHARED_LIBRARY defined
|
||||
#endif
|
||||
|
@@ -112,7 +112,7 @@ static const int tsSigId[] = { SIGSEGV, SIGBUS, SIGFPE, SIGILL, SIGABRT, -1 };
|
||||
|
||||
static jmp_buf tsJmpMark;
|
||||
|
||||
void signalHandler( int sig_code )
|
||||
static void signalHandler( int sig_code )
|
||||
{
|
||||
int code = TS::FAIL_EXCEPTION;
|
||||
switch( sig_code )
|
||||
@@ -197,7 +197,7 @@ void BaseTest::safe_run( int start_from )
|
||||
read_params( ts->get_file_storage() );
|
||||
ts->update_context( 0, -1, true );
|
||||
ts->update_context( this, -1, true );
|
||||
|
||||
|
||||
if( !::testing::GTEST_FLAG(catch_exceptions) )
|
||||
run( start_from );
|
||||
else
|
||||
@@ -218,7 +218,7 @@ void BaseTest::safe_run( int start_from )
|
||||
{
|
||||
const char* errorStr = cvErrorStr(exc.code);
|
||||
char buf[1 << 16];
|
||||
|
||||
|
||||
sprintf( buf, "OpenCV Error: %s (%s) in %s, file %s, line %d",
|
||||
errorStr, exc.err.c_str(), exc.func.size() > 0 ?
|
||||
exc.func.c_str() : "unknown function", exc.file.c_str(), exc.line );
|
||||
@@ -230,7 +230,7 @@ void BaseTest::safe_run( int start_from )
|
||||
ts->set_failed_test_info( TS::FAIL_EXCEPTION );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ts->set_gtest_status();
|
||||
}
|
||||
|
||||
@@ -346,7 +346,7 @@ int BadArgTest::run_test_case( int expected_code, const string& _descr )
|
||||
int errcount = 0;
|
||||
bool thrown = false;
|
||||
const char* descr = _descr.c_str() ? _descr.c_str() : "";
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
run_func();
|
||||
@@ -402,7 +402,7 @@ TestInfo::TestInfo()
|
||||
test_case_idx = -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
TS::TS()
|
||||
{
|
||||
} // ctor
|
||||
@@ -450,7 +450,7 @@ static int tsErrorCallback( int status, const char* func_name, const char* err_m
|
||||
void TS::init( const string& modulename )
|
||||
{
|
||||
char* datapath_dir = getenv("OPENCV_TEST_DATA_PATH");
|
||||
|
||||
|
||||
if( datapath_dir )
|
||||
{
|
||||
char buf[1024];
|
||||
@@ -459,7 +459,7 @@ void TS::init( const string& modulename )
|
||||
sprintf( buf, "%s%s%s/", datapath_dir, haveSlash ? "" : "/", modulename.c_str() );
|
||||
data_path = string(buf);
|
||||
}
|
||||
|
||||
|
||||
cv::redirectError((cv::ErrorCallback)tsErrorCallback, this);
|
||||
|
||||
if( ::testing::GTEST_FLAG(catch_exceptions) )
|
||||
@@ -484,10 +484,10 @@ void TS::init( const string& modulename )
|
||||
signal( tsSigId[i], SIG_DFL );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
if( params.use_optimized == 0 )
|
||||
cv::setUseOptimized(false);
|
||||
|
||||
|
||||
rng = RNG(params.rng_seed);
|
||||
}
|
||||
|
||||
@@ -497,11 +497,11 @@ void TS::set_gtest_status()
|
||||
int code = get_err_code();
|
||||
if( code >= 0 )
|
||||
return SUCCEED();
|
||||
|
||||
|
||||
char seedstr[32];
|
||||
sprintf(seedstr, "%08x%08x", (unsigned)(current_test_info.rng_seed>>32),
|
||||
(unsigned)(current_test_info.rng_seed));
|
||||
|
||||
|
||||
string logs = "";
|
||||
if( !output_buf[SUMMARY_IDX].empty() )
|
||||
logs += "\n-----------------------------------\n\tSUM: " + output_buf[SUMMARY_IDX];
|
||||
@@ -510,7 +510,7 @@ void TS::set_gtest_status()
|
||||
if( !output_buf[CONSOLE_IDX].empty() )
|
||||
logs += "\n-----------------------------------\n\tCONSOLE: " + output_buf[CONSOLE_IDX];
|
||||
logs += "\n-----------------------------------\n";
|
||||
|
||||
|
||||
FAIL() << "\n\tfailure reason: " << str_from_code(code) <<
|
||||
"\n\ttest case #" << current_test_info.test_case_idx <<
|
||||
"\n\tseed: " << seedstr << logs;
|
||||
@@ -518,7 +518,7 @@ void TS::set_gtest_status()
|
||||
|
||||
|
||||
CvFileStorage* TS::get_file_storage() { return 0; }
|
||||
|
||||
|
||||
void TS::update_context( BaseTest* test, int test_case_idx, bool update_ts_context )
|
||||
{
|
||||
if( current_test_info.test != test )
|
||||
@@ -528,7 +528,7 @@ void TS::update_context( BaseTest* test, int test_case_idx, bool update_ts_conte
|
||||
rng = RNG(params.rng_seed);
|
||||
current_test_info.rng_seed0 = current_test_info.rng_seed = rng.state;
|
||||
}
|
||||
|
||||
|
||||
current_test_info.test = test;
|
||||
current_test_info.test_case_idx = test_case_idx;
|
||||
current_test_info.code = 0;
|
||||
@@ -537,7 +537,7 @@ void TS::update_context( BaseTest* test, int test_case_idx, bool update_ts_conte
|
||||
current_test_info.rng_seed = rng.state;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void TS::set_failed_test_info( int fail_code )
|
||||
{
|
||||
if( current_test_info.code >= 0 )
|
||||
@@ -577,7 +577,7 @@ void TS::printf( int streams, const char* fmt, ... )
|
||||
va_end( l );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
TS ts;
|
||||
TS* TS::ptr() { return &ts; }
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -36,7 +36,7 @@
|
||||
|
||||
// This line ensures that gtest.h can be compiled on its own, even
|
||||
// when it's fused.
|
||||
#include "opencv2/ts/ts_gtest.h"
|
||||
#include "opencv2/ts/ts.hpp"
|
||||
|
||||
// The following lines pull in the real gtest *.cc files.
|
||||
// Copyright 2005, Google Inc.
|
||||
@@ -1906,7 +1906,7 @@ extern const TypeId kTestTypeIdInGoogleTest = GetTestTypeId();
|
||||
// This predicate-formatter checks that 'results' contains a test part
|
||||
// failure of the given type and that the failure message contains the
|
||||
// given substring.
|
||||
AssertionResult HasOneFailure(const char* /* results_expr */,
|
||||
static AssertionResult HasOneFailure(const char* /* results_expr */,
|
||||
const char* /* type_expr */,
|
||||
const char* /* substr_expr */,
|
||||
const TestPartResultArray& results,
|
||||
@@ -3874,7 +3874,7 @@ WORD GetColorAttribute(GTestColor color) {
|
||||
|
||||
// Returns the ANSI color code for the given color. COLOR_DEFAULT is
|
||||
// an invalid input.
|
||||
const char* GetAnsiColorCode(GTestColor color) {
|
||||
static const char* GetAnsiColorCode(GTestColor color) {
|
||||
switch (color) {
|
||||
case COLOR_RED: return "1";
|
||||
case COLOR_GREEN: return "2";
|
||||
@@ -3921,7 +3921,7 @@ bool ShouldUseColor(bool stdout_is_tty) {
|
||||
// cannot simply emit special characters and have the terminal change colors.
|
||||
// This routine must actually emit the characters rather than return a string
|
||||
// that would be colored when printed, as can be done on Linux.
|
||||
void ColoredPrintf(GTestColor color, const char* fmt, ...) {
|
||||
static void ColoredPrintf(GTestColor color, const char* fmt, ...) {
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
|
||||
@@ -3967,7 +3967,7 @@ void ColoredPrintf(GTestColor color, const char* fmt, ...) {
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void PrintFullTestCommentIfPresent(const TestInfo& test_info) {
|
||||
static void PrintFullTestCommentIfPresent(const TestInfo& test_info) {
|
||||
const char* const type_param = test_info.type_param();
|
||||
const char* const value_param = test_info.value_param();
|
||||
|
||||
@@ -4946,13 +4946,13 @@ UnitTest * UnitTest::GetInstance() {
|
||||
// default implementation. Use this implementation to keep good OO
|
||||
// design with private destructor.
|
||||
|
||||
#if (_MSC_VER == 1310 && !defined(_DEBUG)) || defined(__BORLANDC__)
|
||||
#if (defined(_MSC_VER) && _MSC_VER == 1310 && !defined(_DEBUG)) || defined(__BORLANDC__)
|
||||
static UnitTest* const instance = new UnitTest;
|
||||
return instance;
|
||||
#else
|
||||
static UnitTest instance;
|
||||
return &instance;
|
||||
#endif // (_MSC_VER == 1310 && !defined(_DEBUG)) || defined(__BORLANDC__)
|
||||
#endif // (defined(_MSC_VER) && _MSC_VER == 1310 && !defined(_DEBUG)) || defined(__BORLANDC__)
|
||||
}
|
||||
|
||||
// Gets the number of successful test cases.
|
||||
@@ -5861,7 +5861,7 @@ bool SkipPrefix(const char* prefix, const char** pstr) {
|
||||
// part can be omitted.
|
||||
//
|
||||
// Returns the value of the flag, or NULL if the parsing failed.
|
||||
const char* ParseFlagValue(const char* str,
|
||||
static const char* ParseFlagValue(const char* str,
|
||||
const char* flag,
|
||||
bool def_optional) {
|
||||
// str and flag must not be NULL.
|
||||
@@ -5899,7 +5899,7 @@ const char* ParseFlagValue(const char* str,
|
||||
//
|
||||
// On success, stores the value of the flag in *value, and returns
|
||||
// true. On failure, returns false without changing *value.
|
||||
bool ParseBoolFlag(const char* str, const char* flag, bool* value) {
|
||||
static bool ParseBoolFlag(const char* str, const char* flag, bool* value) {
|
||||
// Gets the value of the flag as a string.
|
||||
const char* const value_str = ParseFlagValue(str, flag, true);
|
||||
|
||||
@@ -5933,7 +5933,7 @@ bool ParseInt32Flag(const char* str, const char* flag, Int32* value) {
|
||||
//
|
||||
// On success, stores the value of the flag in *value, and returns
|
||||
// true. On failure, returns false without changing *value.
|
||||
bool ParseStringFlag(const char* str, const char* flag, String* value) {
|
||||
static bool ParseStringFlag(const char* str, const char* flag, String* value) {
|
||||
// Gets the value of the flag as a string.
|
||||
const char* const value_str = ParseFlagValue(str, flag, false);
|
||||
|
||||
@@ -6407,7 +6407,7 @@ enum DeathTestOutcome { IN_PROGRESS, DIED, LIVED, RETURNED, THREW };
|
||||
// message is propagated back to the parent process. Otherwise, the
|
||||
// message is simply printed to stderr. In either case, the program
|
||||
// then exits with status 1.
|
||||
void DeathTestAbort(const String& message) {
|
||||
static void DeathTestAbort(const String& message) {
|
||||
// On a POSIX system, this function may be called from a threadsafe-style
|
||||
// death test child process, which operates on a very small stack. Use
|
||||
// the heap for any additional non-minuscule memory requirements.
|
||||
@@ -7139,7 +7139,7 @@ bool StackLowerThanAddress(const void* ptr) {
|
||||
return &dummy < ptr;
|
||||
}
|
||||
|
||||
bool StackGrowsDown() {
|
||||
static bool StackGrowsDown() {
|
||||
int dummy;
|
||||
return StackLowerThanAddress(&dummy);
|
||||
}
|
||||
@@ -8391,7 +8391,7 @@ static CapturedStream* g_captured_stderr = NULL;
|
||||
static CapturedStream* g_captured_stdout = NULL;
|
||||
|
||||
// Starts capturing an output stream (stdout/stderr).
|
||||
void CaptureStream(int fd, const char* stream_name, CapturedStream** stream) {
|
||||
static void CaptureStream(int fd, const char* stream_name, CapturedStream** stream) {
|
||||
if (*stream != NULL) {
|
||||
GTEST_LOG_(FATAL) << "Only one " << stream_name
|
||||
<< " capturer can exist at a time.";
|
||||
@@ -8400,7 +8400,7 @@ void CaptureStream(int fd, const char* stream_name, CapturedStream** stream) {
|
||||
}
|
||||
|
||||
// Stops capturing the output stream and returns the captured string.
|
||||
String GetCapturedStream(CapturedStream** captured_stream) {
|
||||
static String GetCapturedStream(CapturedStream** captured_stream) {
|
||||
const String content = (*captured_stream)->GetCapturedString();
|
||||
|
||||
delete *captured_stream;
|
||||
@@ -8603,9 +8603,9 @@ using ::std::ostream;
|
||||
|
||||
#if GTEST_OS_WINDOWS_MOBILE // Windows CE does not define _snprintf_s.
|
||||
# define snprintf _snprintf
|
||||
#elif _MSC_VER >= 1400 // VC 8.0 and later deprecate snprintf and _snprintf.
|
||||
#elif defined(_MSC_VER) && _MSC_VER >= 1400 // VC 8.0 and later deprecate snprintf and _snprintf.
|
||||
# define snprintf _snprintf_s
|
||||
#elif _MSC_VER
|
||||
#elif defined(_MSC_VER) && _MSC_VER
|
||||
# define snprintf _snprintf
|
||||
#endif // GTEST_OS_WINDOWS_MOBILE
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#include "precomp.hpp"
|
||||
|
||||
#if ANDROID
|
||||
#ifdef ANDROID
|
||||
# include <sys/time.h>
|
||||
#endif
|
||||
|
||||
@@ -18,7 +18,7 @@ const char *command_line_keys =
|
||||
"{ |perf_seed |809564 |seed for random numbers generator}"
|
||||
"{ |perf_tbb_nthreads |-1 |if TBB is enabled, the number of TBB threads}"
|
||||
"{ |perf_write_sanity |false |allow to create new records for sanity checks}"
|
||||
#if ANDROID
|
||||
#ifdef ANDROID
|
||||
"{ |perf_time_limit |6.0 |default time limit for a single test (in seconds)}"
|
||||
"{ |perf_affinity_mask |0 |set affinity mask for the main thread}"
|
||||
"{ |perf_log_power_checkpoints |false |additional xml logging for power measurement}"
|
||||
@@ -37,7 +37,7 @@ static uint64 param_seed;
|
||||
static double param_time_limit;
|
||||
static int param_tbb_nthreads;
|
||||
static bool param_write_sanity;
|
||||
#if ANDROID
|
||||
#ifdef ANDROID
|
||||
static int param_affinity_mask;
|
||||
static bool log_power_checkpoints;
|
||||
|
||||
@@ -57,7 +57,7 @@ static void setCurrentThreadAffinityMask(int mask)
|
||||
|
||||
#endif
|
||||
|
||||
void randu(cv::Mat& m)
|
||||
static void randu(cv::Mat& m)
|
||||
{
|
||||
const int bigValue = 0x00000FFF;
|
||||
if (m.depth() < CV_32F)
|
||||
@@ -151,7 +151,7 @@ void Regression::init(const std::string& testSuitName, const std::string& ext)
|
||||
{
|
||||
LOGE("Failed to open sanity data for reading: %s", storageInPath.c_str());
|
||||
}
|
||||
|
||||
|
||||
if(!storageIn.isOpened())
|
||||
storageOutPath = storageInPath;
|
||||
}
|
||||
@@ -534,7 +534,7 @@ void TestBase::Init(int argc, const char* const argv[])
|
||||
param_force_samples = args.get<unsigned int>("perf_force_samples");
|
||||
param_write_sanity = args.get<bool>("perf_write_sanity");
|
||||
param_tbb_nthreads = args.get<int>("perf_tbb_nthreads");
|
||||
#if ANDROID
|
||||
#ifdef ANDROID
|
||||
param_affinity_mask = args.get<int>("perf_affinity_mask");
|
||||
log_power_checkpoints = args.get<bool>("perf_log_power_checkpoints");
|
||||
#endif
|
||||
@@ -636,17 +636,17 @@ cv::Size TestBase::getSize(cv::InputArray a)
|
||||
bool TestBase::next()
|
||||
{
|
||||
bool has_next = ++currentIter < nIters && totalTime < timeLimit;
|
||||
#if ANDROID
|
||||
#ifdef ANDROID
|
||||
if (log_power_checkpoints)
|
||||
{
|
||||
timeval tim;
|
||||
gettimeofday(&tim, NULL);
|
||||
unsigned long long t1 = tim.tv_sec * 1000LLU + (unsigned long long)(tim.tv_usec / 1000.f);
|
||||
|
||||
|
||||
if (currentIter == 1) RecordProperty("test_start", cv::format("%llu",t1).c_str());
|
||||
if (!has_next) RecordProperty("test_complete", cv::format("%llu",t1).c_str());
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
return has_next;
|
||||
}
|
||||
|
||||
@@ -898,7 +898,7 @@ void TestBase::SetUp()
|
||||
p_tbb_initializer=new tbb::task_scheduler_init(param_tbb_nthreads);
|
||||
}
|
||||
#endif
|
||||
#if ANDROID
|
||||
#ifdef ANDROID
|
||||
if (param_affinity_mask)
|
||||
setCurrentThreadAffinityMask(param_affinity_mask);
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user