Adding test support for WINRT

This commit is contained in:
Evgeny Agafonchikov
2015-05-18 11:57:18 +03:00
parent 8869150649
commit 6a6d58d389
19 changed files with 303 additions and 21 deletions

View File

@@ -450,7 +450,11 @@ static int tsErrorCallback( int status, const char* func_name, const char* err_m
void TS::init( const string& modulename )
{
#ifndef WINRT
char* datapath_dir = getenv("OPENCV_TEST_DATA_PATH");
#else
char* datapath_dir = OPENCV_TEST_DATA_PATH;
#endif
if( datapath_dir )
{
@@ -684,7 +688,11 @@ void parseCustomOptions(int argc, char **argv)
test_ipp_check = parser.get<bool>("test_ipp_check");
if (!test_ipp_check)
#ifndef WINRT
test_ipp_check = getenv("OPENCV_IPP_CHECK") != NULL;
#else
test_ipp_check = false;
#endif
}
/* End of file. */

View File

@@ -4054,7 +4054,7 @@ enum GTestColor {
COLOR_YELLOW
};
#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE
#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE && !defined WINRT
// Returns the character attribute for the given color.
WORD GetColorAttribute(GTestColor color) {
@@ -4122,7 +4122,7 @@ static void ColoredPrintf(GTestColor color, const char* fmt, ...) {
va_list args;
va_start(args, fmt);
#if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_SYMBIAN || GTEST_OS_ZOS || GTEST_OS_IOS
#if GTEST_OS_WINDOWS_MOBILE || WINRT || GTEST_OS_SYMBIAN || GTEST_OS_ZOS || GTEST_OS_IOS
const bool use_color = false;
#else
static const bool in_color_mode =
@@ -4137,7 +4137,7 @@ static void ColoredPrintf(GTestColor color, const char* fmt, ...) {
return;
}
#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE
#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE && !defined WINRT
const HANDLE stdout_handle = GetStdHandle(STD_OUTPUT_HANDLE);
// Gets the current text color.
@@ -5320,7 +5320,7 @@ void UnitTest::AddTestPartResult(
// with another testing framework) and specify the former on the
// command line for debugging.
if (GTEST_FLAG(break_on_failure)) {
#if GTEST_OS_WINDOWS
#if GTEST_OS_WINDOWS && !defined WINRT
// Using DebugBreak on Windows allows gtest to still break into a debugger
// when a failure happens and both the --gtest_break_on_failure and
// the --gtest_catch_exceptions flags are specified.
@@ -5398,7 +5398,7 @@ int UnitTest::Run() {
// process. In either case the user does not want to see pop-up dialogs
// about crashes - they are expected.
if (impl()->catch_exceptions() || in_death_test_child_process) {
# if !GTEST_OS_WINDOWS_MOBILE
# if !GTEST_OS_WINDOWS_MOBILE && !defined WINRT
// SetErrorMode doesn't exist on CE.
SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOALIGNMENTFAULTEXCEPT |
SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX);
@@ -7110,6 +7110,7 @@ bool DeathTestImpl::Passed(bool status_ok) {
}
# if GTEST_OS_WINDOWS
#ifndef WINRT
// WindowsDeathTest implements death tests on Windows. Due to the
// specifics of starting new processes on Windows, death tests there are
// always threadsafe, and Google Test considers the
@@ -7301,6 +7302,7 @@ DeathTest::TestRole WindowsDeathTest::AssumeRole() {
set_spawned(true);
return OVERSEE_TEST;
}
#endif
# else // We are not on Windows.
// ForkingDeathTest provides implementations for most of the abstract
@@ -7711,10 +7713,14 @@ bool DefaultDeathTestFactory::Create(const char* statement, const RE* regex,
}
# if GTEST_OS_WINDOWS
if (GTEST_FLAG(death_test_style) == "threadsafe" ||
GTEST_FLAG(death_test_style) == "fast") {
#ifndef WINRT
*test = new WindowsDeathTest(statement, regex, file, line);
#else
printf("DeathTest is not supported on winrt!\n");
return false;
#endif
}
# else
@@ -7758,6 +7764,7 @@ static void SplitString(const ::std::string& str, char delimiter,
}
# if GTEST_OS_WINDOWS
#ifndef WINRT
// Recreates the pipe and event handles from the provided parameters,
// signals the event, and returns a file descriptor wrapped around the pipe
// handle. This function is called in the child process only.
@@ -7823,6 +7830,7 @@ int GetStatusFileDescriptor(unsigned int parent_process_id,
return write_fd;
}
#endif
# endif // GTEST_OS_WINDOWS
// Returns a newly created InternalRunDeathTestFlag object with fields
@@ -7840,7 +7848,7 @@ InternalRunDeathTestFlag* ParseInternalRunDeathTestFlag() {
int write_fd = -1;
# if GTEST_OS_WINDOWS
#ifndef WINRT
unsigned int parent_process_id = 0;
size_t write_handle_as_size_t = 0;
size_t event_handle_as_size_t = 0;
@@ -7857,6 +7865,7 @@ InternalRunDeathTestFlag* ParseInternalRunDeathTestFlag() {
write_fd = GetStatusFileDescriptor(parent_process_id,
write_handle_as_size_t,
event_handle_as_size_t);
#endif
# else
if (fields.size() != 4
@@ -7974,7 +7983,7 @@ static bool IsPathSeparator(char c) {
// Returns the current working directory, or "" if unsuccessful.
FilePath FilePath::GetCurrentDir() {
#if GTEST_OS_WINDOWS_MOBILE
#if GTEST_OS_WINDOWS_MOBILE || WINRT
// Windows CE doesn't have a current directory, so we just return
// something reasonable.
return FilePath(kCurrentDirectoryString);
@@ -8765,6 +8774,7 @@ class CapturedStream {
public:
// The ctor redirects the stream to a temporary file.
explicit CapturedStream(int fd) : fd_(fd), uncaptured_fd_(dup(fd)) {
#ifndef WINRT
# if GTEST_OS_WINDOWS
char temp_dir_path[MAX_PATH + 1] = { '\0' }; // NOLINT
char temp_file_path[MAX_PATH + 1] = { '\0' }; // NOLINT
@@ -8810,6 +8820,7 @@ class CapturedStream {
fflush(NULL);
dup2(captured_fd, fd_);
close(captured_fd);
#endif
}
~CapturedStream() {

View File

@@ -185,7 +185,11 @@ void Regression::init(const std::string& testSuitName, const std::string& ext)
return;
}
#ifndef WINRT
const char *data_path_dir = getenv("OPENCV_TEST_DATA_PATH");
#else
const char *data_path_dir = OPENCV_TEST_DATA_PATH;
#endif
const char *path_separator = "/";
if (data_path_dir)
@@ -814,7 +818,12 @@ void TestBase::Init(const std::vector<std::string> & availableImpls,
param_force_samples = args.get<unsigned int>("perf_force_samples");
param_write_sanity = args.has("perf_write_sanity");
param_verify_sanity = args.has("perf_verify_sanity");
#ifndef WINRT
test_ipp_check = !args.has("perf_ipp_check") ? getenv("OPENCV_IPP_CHECK") != NULL : true;
#else
test_ipp_check = false;
#endif
param_threads = args.get<int>("perf_threads");
#ifdef CV_COLLECT_IMPL_DATA
param_collect_impl = args.has("perf_collect_impl");
@@ -881,7 +890,11 @@ void TestBase::Init(const std::vector<std::string> & availableImpls,
#endif
{
#ifndef WINRT
const char* path = getenv("OPENCV_PERF_VALIDATION_DIR");
#else
const char* path = OPENCV_PERF_VALIDATION_DIR;
#endif
if (path)
perf_validation_results_directory = path;
}
@@ -1185,7 +1198,11 @@ bool TestBase::next()
printf("Performance is unstable, it may be a result of overheat problems\n");
printf("Idle delay for %d ms... \n", perf_validation_idle_delay_ms);
#if defined WIN32 || defined _WIN32 || defined WIN64 || defined _WIN64
#ifndef WINRT_8_0
Sleep(perf_validation_idle_delay_ms);
#else
WaitForSingleObjectEx(GetCurrentThread(), perf_validation_idle_delay_ms, FALSE);
#endif
#else
usleep(perf_validation_idle_delay_ms * 1000);
#endif
@@ -1635,7 +1652,11 @@ std::string TestBase::getDataPath(const std::string& relativePath)
throw PerfEarlyExitException();
}
#ifndef WINRT
const char *data_path_dir = getenv("OPENCV_TEST_DATA_PATH");
#else
const char *data_path_dir = OPENCV_TEST_DATA_PATH;
#endif
const char *path_separator = "/";
std::string path;