Commit 7c6191ec authored by Andrey Kamaev's avatar Andrey Kamaev

Refactored run.py script and temporary file generation logic

* use OPENCV_TEMP_PATH environment variable on all platforms
* fix cleanup after OpenCV tests on Windows
* add --list flag to output names of all tests found
* do not override user-passed --perf_min_samples and --perf_force_samples
  options by --check flag
* fix complier checks inside run.py
parent 7852b68c
...@@ -359,26 +359,24 @@ string format( const char* fmt, ... ) ...@@ -359,26 +359,24 @@ string format( const char* fmt, ... )
string tempfile( const char* suffix ) string tempfile( const char* suffix )
{ {
const char *temp_dir = getenv("OPENCV_TEMP_PATH");
string fname;
#if defined WIN32 || defined _WIN32 #if defined WIN32 || defined _WIN32
char temp_dir[MAX_PATH + 1] = { 0 }; char temp_dir2[MAX_PATH + 1] = { 0 };
char temp_file[MAX_PATH + 1] = { 0 }; char temp_file[MAX_PATH + 1] = { 0 };
::GetTempPathA(sizeof(temp_dir), temp_dir); if (temp_dir == 0 || temp_dir[0] == 0)
{
::GetTempPathA(sizeof(temp_dir2), temp_dir2);
temp_dir = temp_dir2;
}
if(0 == ::GetTempFileNameA(temp_dir, "ocv", 0, temp_file)) if(0 == ::GetTempFileNameA(temp_dir, "ocv", 0, temp_file))
return string(); return string();
DeleteFileA(temp_file); DeleteFileA(temp_file);
string name = temp_file; fname = temp_file;
if(suffix)
{
if (suffix[0] != '.')
return name + "." + suffix;
else
return name + suffix;
}
else
return name;
# else # else
# ifdef ANDROID # ifdef ANDROID
//char defaultTemplate[] = "/mnt/sdcard/__opencv_temp.XXXXXX"; //char defaultTemplate[] = "/mnt/sdcard/__opencv_temp.XXXXXX";
...@@ -387,9 +385,7 @@ string tempfile( const char* suffix ) ...@@ -387,9 +385,7 @@ string tempfile( const char* suffix )
char defaultTemplate[] = "/tmp/__opencv_temp.XXXXXX"; char defaultTemplate[] = "/tmp/__opencv_temp.XXXXXX";
# endif # endif
string fname; if (temp_dir == 0 || temp_dir[0] == 0)
const char *temp_dir = getenv("OPENCV_TEMP_PATH");
if(temp_dir == 0 || temp_dir[0] == 0)
fname = defaultTemplate; fname = defaultTemplate;
else else
{ {
...@@ -401,19 +397,20 @@ string tempfile( const char* suffix ) ...@@ -401,19 +397,20 @@ string tempfile( const char* suffix )
} }
const int fd = mkstemp((char*)fname.c_str()); const int fd = mkstemp((char*)fname.c_str());
if(fd == -1) return ""; if (fd == -1) return string();
close(fd); close(fd);
remove(fname.c_str()); remove(fname.c_str());
# endif
if(suffix) if (suffix)
{ {
if (suffix[0] != '.') if (suffix[0] != '.')
fname = fname + "." + suffix; return fname + "." + suffix;
else else
fname += suffix; return fname + suffix;
} }
return fname; return fname;
# endif
} }
static CvErrorCallback customErrorCallback = 0; static CvErrorCallback customErrorCallback = 0;
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment