2012-11-24 02:57:22 +08:00
#!/usr/bin/env python
2012-07-03 05:07:32 +08:00
import sys , os , platform , xml , re , tempfile , glob , datetime , getpass , shutil
2011-09-06 23:30:28 +08:00
from optparse import OptionParser
from subprocess import Popen , PIPE
hostos = os . name # 'nt', 'posix'
hostmachine = platform . machine ( ) # 'x86', 'AMD64', 'x86_64'
2012-01-24 00:28:46 +08:00
SIMD_DETECTION_PROGRAM = """
#if __SSE5__
# error SSE5
#endif
#if __AVX2__
# error AVX2
#endif
#if __AVX__
# error AVX
#endif
#if __SSE4_2__
# error SSE4.2
#endif
#if __SSE4_1__
# error SSE4.1
#endif
#if __SSSE3__
# error SSSE3
#endif
#if __SSE3__
# error SSE3
#endif
#if __AES__
# error AES
#endif
#if __SSE2__
# error SSE2
#endif
#if __SSE__
# error SSE
#endif
#if __3dNOW__
# error 3dNOW
#endif
#if __MMX__
# error MMX
#endif
#if __ARM_NEON__
# error NEON
#endif
#error NOSIMD
"""
2011-09-06 23:30:28 +08:00
parse_patterns = (
2012-01-24 19:46:11 +08:00
{ ' name ' : " has_perf_tests " , ' default ' : " OFF " , ' pattern ' : re . compile ( " ^BUILD_PERF_TESTS:BOOL=(ON)$ " ) } ,
2012-04-14 05:50:59 +08:00
{ ' name ' : " has_accuracy_tests " , ' default ' : " OFF " , ' pattern ' : re . compile ( " ^BUILD_TESTS:BOOL=(ON)$ " ) } ,
2012-01-24 19:46:11 +08:00
{ ' name ' : " cmake_home " , ' default ' : None , ' pattern ' : re . compile ( " ^CMAKE_HOME_DIRECTORY:INTERNAL=(.+)$ " ) } ,
{ ' name ' : " opencv_home " , ' default ' : None , ' pattern ' : re . compile ( " ^OpenCV_SOURCE_DIR:STATIC=(.+)$ " ) } ,
{ ' name ' : " tests_dir " , ' default ' : None , ' pattern ' : re . compile ( " ^EXECUTABLE_OUTPUT_PATH:PATH=(.+)$ " ) } ,
{ ' name ' : " build_type " , ' default ' : " Release " , ' pattern ' : re . compile ( " ^CMAKE_BUILD_TYPE:STRING=(.*)$ " ) } ,
{ ' name ' : " svnversion_path " , ' default ' : None , ' pattern ' : re . compile ( " ^SVNVERSION_PATH:FILEPATH=(.*)$ " ) } ,
2012-08-07 15:35:13 +08:00
{ ' name ' : " git_executable " , ' default ' : None , ' pattern ' : re . compile ( " ^GIT_EXECUTABLE:FILEPATH=(.*)$ " ) } ,
2012-01-24 19:46:11 +08:00
{ ' name ' : " cxx_flags " , ' default ' : " " , ' pattern ' : re . compile ( " ^CMAKE_CXX_FLAGS:STRING=(.*)$ " ) } ,
{ ' name ' : " cxx_flags_debug " , ' default ' : " " , ' pattern ' : re . compile ( " ^CMAKE_CXX_FLAGS_DEBUG:STRING=(.*)$ " ) } ,
{ ' name ' : " cxx_flags_release " , ' default ' : " " , ' pattern ' : re . compile ( " ^CMAKE_CXX_FLAGS_RELEASE:STRING=(.*)$ " ) } ,
{ ' name ' : " opencv_cxx_flags " , ' default ' : " " , ' pattern ' : re . compile ( " ^OPENCV_EXTRA_C_FLAGS:INTERNAL=(.*)$ " ) } ,
{ ' name ' : " opencv_cxx_flags_debug " , ' default ' : " " , ' pattern ' : re . compile ( " ^OPENCV_EXTRA_C_FLAGS_DEBUG:INTERNAL=(.*)$ " ) } ,
{ ' name ' : " opencv_cxx_flags_release " , ' default ' : " " , ' pattern ' : re . compile ( " ^OPENCV_EXTRA_C_FLAGS_RELEASE:INTERNAL=(.*)$ " ) } ,
{ ' name ' : " cxx_flags_android " , ' default ' : None , ' pattern ' : re . compile ( " ^ANDROID_CXX_FLAGS:INTERNAL=(.*)$ " ) } ,
{ ' name ' : " ndk_path " , ' default ' : None , ' pattern ' : re . compile ( " ^(?:ANDROID_NDK|ANDROID_STANDALONE_TOOLCHAIN)?:PATH=(.*)$ " ) } ,
{ ' name ' : " android_abi " , ' default ' : None , ' pattern ' : re . compile ( " ^ANDROID_ABI:STRING=(.*)$ " ) } ,
{ ' name ' : " android_executable " , ' default ' : None , ' pattern ' : re . compile ( " ^ANDROID_EXECUTABLE:FILEPATH=(.*android.*)$ " ) } ,
{ ' name ' : " is_x64 " , ' default ' : " OFF " , ' pattern ' : re . compile ( " ^CUDA_64_BIT_DEVICE_CODE:BOOL=(ON)$ " ) } , #ugly(
{ ' name ' : " cmake_generator " , ' default ' : None , ' pattern ' : re . compile ( " ^CMAKE_GENERATOR:INTERNAL=(.+)$ " ) } ,
{ ' name ' : " cxx_compiler " , ' default ' : None , ' pattern ' : re . compile ( " ^CMAKE_CXX_COMPILER:FILEPATH=(.+)$ " ) } ,
2012-12-08 19:43:23 +08:00
{ ' name ' : " cxx_compiler_arg1 " , ' default ' : None , ' pattern ' : re . compile ( " ^CMAKE_CXX_COMPILER_ARG1:[A-Z]+=(.+)$ " ) } ,
2012-01-24 19:46:11 +08:00
{ ' name ' : " with_cuda " , ' default ' : " OFF " , ' pattern ' : re . compile ( " ^WITH_CUDA:BOOL=(ON)$ " ) } ,
{ ' name ' : " cuda_library " , ' default ' : None , ' pattern ' : re . compile ( " ^CUDA_CUDA_LIBRARY:FILEPATH=(.+)$ " ) } ,
{ ' name ' : " core_dependencies " , ' default ' : None , ' pattern ' : re . compile ( " ^opencv_core_LIB_DEPENDS:STATIC=(.+)$ " ) } ,
2011-09-06 23:30:28 +08:00
)
def query_yes_no ( stdout , question , default = " yes " ) :
valid = { " yes " : True , " y " : True , " ye " : True , " no " : False , " n " : False }
if default == None :
prompt = " [y/n] "
elif default == " yes " :
prompt = " [Y/n] "
elif default == " no " :
prompt = " [y/N] "
else :
raise ValueError ( " invalid default answer: ' %s ' " % default )
while True :
stdout . write ( os . linesep + question + prompt )
choice = raw_input ( ) . lower ( )
if default is not None and choice == ' ' :
return valid [ default ]
elif choice in valid :
return valid [ choice ]
else :
stdout . write ( " Please respond with ' yes ' or ' no ' " \
" (or ' y ' or ' n ' ). \n " )
2012-06-25 19:24:06 +08:00
2011-09-15 15:35:05 +08:00
def getRunningProcessExePathByName_win32 ( name ) :
2011-09-15 14:31:59 +08:00
from ctypes import windll , POINTER , pointer , Structure , sizeof
from ctypes import c_long , c_int , c_uint , c_char , c_ubyte , c_char_p , c_void_p
2012-06-25 19:24:06 +08:00
2011-09-15 14:31:59 +08:00
class PROCESSENTRY32 ( Structure ) :
2012-06-25 19:24:06 +08:00
_fields_ = [ ( ' dwSize ' , c_uint ) ,
2011-09-15 14:31:59 +08:00
( ' cntUsage ' , c_uint ) ,
( ' th32ProcessID ' , c_uint ) ,
( ' th32DefaultHeapID ' , c_uint ) ,
( ' th32ModuleID ' , c_uint ) ,
( ' cntThreads ' , c_uint ) ,
( ' th32ParentProcessID ' , c_uint ) ,
( ' pcPriClassBase ' , c_long ) ,
( ' dwFlags ' , c_uint ) ,
2012-06-25 19:24:06 +08:00
( ' szExeFile ' , c_char * 260 ) ,
2011-09-15 14:31:59 +08:00
( ' th32MemoryBase ' , c_long ) ,
( ' th32AccessKey ' , c_long ) ]
2012-06-25 19:24:06 +08:00
2011-09-15 14:31:59 +08:00
class MODULEENTRY32 ( Structure ) :
2012-06-25 19:24:06 +08:00
_fields_ = [ ( ' dwSize ' , c_long ) ,
2011-09-15 14:31:59 +08:00
( ' th32ModuleID ' , c_long ) ,
( ' th32ProcessID ' , c_long ) ,
( ' GlblcntUsage ' , c_long ) ,
( ' ProccntUsage ' , c_long ) ,
( ' modBaseAddr ' , c_long ) ,
2012-06-25 19:24:06 +08:00
( ' modBaseSize ' , c_long ) ,
2011-09-15 14:31:59 +08:00
( ' hModule ' , c_void_p ) ,
( ' szModule ' , c_char * 256 ) ,
( ' szExePath ' , c_char * 260 ) ]
2012-06-25 19:24:06 +08:00
2011-09-15 14:31:59 +08:00
TH32CS_SNAPPROCESS = 2
TH32CS_SNAPMODULE = 0x00000008
2012-06-25 19:24:06 +08:00
2011-09-15 14:31:59 +08:00
## CreateToolhelp32Snapshot
CreateToolhelp32Snapshot = windll . kernel32 . CreateToolhelp32Snapshot
CreateToolhelp32Snapshot . reltype = c_long
CreateToolhelp32Snapshot . argtypes = [ c_int , c_int ]
## Process32First
Process32First = windll . kernel32 . Process32First
Process32First . argtypes = [ c_void_p , POINTER ( PROCESSENTRY32 ) ]
Process32First . rettype = c_int
## Process32Next
Process32Next = windll . kernel32 . Process32Next
Process32Next . argtypes = [ c_void_p , POINTER ( PROCESSENTRY32 ) ]
Process32Next . rettype = c_int
## CloseHandle
CloseHandle = windll . kernel32 . CloseHandle
CloseHandle . argtypes = [ c_void_p ]
CloseHandle . rettype = c_int
## Module32First
Module32First = windll . kernel32 . Module32First
Module32First . argtypes = [ c_void_p , POINTER ( MODULEENTRY32 ) ]
Module32First . rettype = c_int
2012-06-25 19:24:06 +08:00
2011-09-15 14:31:59 +08:00
hProcessSnap = c_void_p ( 0 )
hProcessSnap = CreateToolhelp32Snapshot ( TH32CS_SNAPPROCESS , 0 )
pe32 = PROCESSENTRY32 ( )
pe32 . dwSize = sizeof ( PROCESSENTRY32 )
ret = Process32First ( hProcessSnap , pointer ( pe32 ) )
path = None
while ret :
if name + " .exe " == pe32 . szExeFile :
hModuleSnap = c_void_p ( 0 )
me32 = MODULEENTRY32 ( )
me32 . dwSize = sizeof ( MODULEENTRY32 )
hModuleSnap = CreateToolhelp32Snapshot ( TH32CS_SNAPMODULE , pe32 . th32ProcessID )
ret = Module32First ( hModuleSnap , pointer ( me32 ) )
path = me32 . szExePath
CloseHandle ( hModuleSnap )
if path :
break
ret = Process32Next ( hProcessSnap , pointer ( pe32 ) )
CloseHandle ( hProcessSnap )
return path
2011-09-15 15:35:05 +08:00
def getRunningProcessExePathByName_posix ( name ) :
pids = [ pid for pid in os . listdir ( ' /proc ' ) if pid . isdigit ( ) ]
for pid in pids :
try :
path = os . readlink ( os . path . join ( ' /proc ' , pid , ' exe ' ) )
2012-06-25 19:24:06 +08:00
if path and path . endswith ( name ) :
2011-09-15 15:35:05 +08:00
return path
except :
pass
2011-09-15 14:31:59 +08:00
def getRunningProcessExePathByName ( name ) :
try :
if hostos == " nt " :
return getRunningProcessExePathByName_win32 ( name )
2011-09-15 15:35:05 +08:00
elif hostos == " posix " :
return getRunningProcessExePathByName_posix ( name )
2011-09-15 14:31:59 +08:00
else :
return None
except :
return None
2012-06-25 19:24:06 +08:00
2012-12-08 19:43:23 +08:00
class TestSuite ( object ) :
def __init__ ( self , options , path = None ) :
2012-01-24 00:28:46 +08:00
self . options = options
2011-09-06 23:30:28 +08:00
self . path = path
self . error = None
2012-04-14 05:50:59 +08:00
self . setUp = None
self . tearDown = None
2012-12-08 19:43:23 +08:00
self . adb = None
self . targetos = None
self . nameprefix = " opencv_ " + self . options . mode + " _ "
2011-09-06 23:30:28 +08:00
for p in parse_patterns :
setattr ( self , p [ " name " ] , p [ " default " ] )
2012-06-25 19:24:06 +08:00
2012-12-08 19:43:23 +08:00
if self . path :
cachefile = open ( os . path . join ( self . path , " CMakeCache.txt " ) , " rt " )
try :
for l in cachefile . readlines ( ) :
ll = l . strip ( )
if not ll or ll . startswith ( " # " ) :
continue
for p in parse_patterns :
match = p [ " pattern " ] . match ( ll )
if match :
value = match . groups ( ) [ 0 ]
if value and not value . endswith ( " -NOTFOUND " ) :
setattr ( self , p [ " name " ] , value )
except :
pass
cachefile . close ( )
# detect target platform
if self . android_executable or self . android_abi or self . ndk_path :
self . targetos = " android "
else :
self . targetos = hostos
self . initialize ( )
def initialize ( self ) :
2011-09-06 23:30:28 +08:00
# fix empty tests dir
if not self . tests_dir :
self . tests_dir = self . path
2012-07-03 05:07:32 +08:00
self . tests_dir = os . path . normpath ( self . tests_dir )
2012-12-08 19:43:23 +08:00
# compute path to adb
2011-09-06 23:30:28 +08:00
if self . android_executable :
self . adb = os . path . join ( os . path . dirname ( os . path . dirname ( self . android_executable ) ) , ( " platform-tools/adb " , " platform-tools/adb.exe " ) [ hostos == ' nt ' ] )
2011-09-15 14:31:59 +08:00
if not os . path . isfile ( self . adb ) or not os . access ( self . adb , os . X_OK ) :
self . adb = None
2011-09-06 23:30:28 +08:00
else :
self . adb = None
2011-09-15 14:31:59 +08:00
if self . targetos == " android " :
# fix adb tool location
if not self . adb :
self . adb = getRunningProcessExePathByName ( " adb " )
2011-09-06 23:30:28 +08:00
if not self . adb :
2011-12-19 15:43:07 +08:00
self . adb = " adb "
2012-12-08 19:43:23 +08:00
if self . options . adb_serial :
self . adb = [ self . adb , " -s " , self . options . adb_serial ]
2012-06-25 19:24:06 +08:00
else :
2011-12-19 15:43:07 +08:00
self . adb = [ self . adb ]
try :
output = Popen ( self . adb + [ " shell " , " ls " ] , stdout = PIPE , stderr = PIPE ) . communicate ( )
except OSError :
self . adb = [ ]
# remember current device serial. Needed if another device is connected while this script runs
2012-12-08 19:43:23 +08:00
if self . adb and not self . options . adb_serial :
2011-12-19 15:43:07 +08:00
adb_res = self . runAdb ( " devices " )
if not adb_res :
self . error = " Could not run adb command: %s (for %s ) " % ( self . error , self . path )
self . adb = [ ]
else :
2012-10-10 20:59:00 +08:00
# assume here that device name may consists of any characters except newline
connected_devices = re . findall ( r " ^[^ \ n]+[ \ t]+device \ r?$ " , adb_res , re . MULTILINE )
2012-11-24 18:11:07 +08:00
if not connected_devices :
self . error = " Android device not found "
self . adb = [ ]
elif len ( connected_devices ) != 1 :
self . error = " Too many ( %s ) devices are connected. Please specify single device using --serial option: \n \n " % ( len ( connected_devices ) ) + adb_res
2011-12-19 15:43:07 +08:00
self . adb = [ ]
else :
2012-12-08 19:43:23 +08:00
self . options . adb_serial = connected_devices [ 0 ] . split ( " \t " ) [ 0 ]
self . adb = self . adb + [ " -s " , self . options . adb_serial ]
2012-11-24 18:11:07 +08:00
if self . adb :
2012-12-08 19:43:23 +08:00
# construct name for aapt tool
2012-11-24 18:11:07 +08:00
self . aapt = [ os . path . join ( os . path . dirname ( self . adb [ 0 ] ) , ( " aapt " , " aapt.exe " ) [ hostos == ' nt ' ] ) ]
2012-04-14 05:50:59 +08:00
2011-09-06 23:30:28 +08:00
# fix has_perf_tests param
self . has_perf_tests = self . has_perf_tests == " ON "
2012-04-14 05:50:59 +08:00
self . has_accuracy_tests = self . has_accuracy_tests == " ON "
2011-09-06 23:30:28 +08:00
# fix is_x64 flag
self . is_x64 = self . is_x64 == " ON "
if not self . is_x64 and ( " X64 " in " %s %s %s " % ( self . cxx_flags , self . cxx_flags_release , self . cxx_flags_debug ) or " Win64 " in self . cmake_generator ) :
self . is_x64 = True
# fix test path
if " Visual Studio " in self . cmake_generator :
2012-12-08 19:43:23 +08:00
if self . options . configuration :
self . tests_dir = os . path . join ( self . tests_dir , self . options . configuration )
2011-09-08 14:27:46 +08:00
else :
self . tests_dir = os . path . join ( self . tests_dir , self . build_type )
2011-09-06 23:30:28 +08:00
elif not self . is_x64 and self . cxx_compiler :
#one more attempt to detect x64 compiler
try :
2012-12-08 19:43:23 +08:00
compiler = [ self . cxx_compiler ]
if self . cxx_compiler_arg1 :
compiler . append ( self . cxx_compiler_arg1 )
output = Popen ( compiler + [ " -v " ] , stdout = PIPE , stderr = PIPE ) . communicate ( )
2011-09-06 23:30:28 +08:00
if not output [ 0 ] and " x86_64 " in output [ 1 ] :
self . is_x64 = True
except OSError :
pass
# detect target arch
if self . targetos == " android " :
2012-01-24 00:28:46 +08:00
if " armeabi-v7a " in self . android_abi :
2012-08-07 15:35:13 +08:00
self . targetarch = " armv7a "
2012-01-24 00:28:46 +08:00
elif " armeabi-v6 " in self . android_abi :
2012-08-07 15:35:13 +08:00
self . targetarch = " armv6 "
2012-01-24 00:28:46 +08:00
elif " armeabi " in self . android_abi :
2012-08-07 15:35:13 +08:00
self . targetarch = " armv5te "
2012-01-24 00:28:46 +08:00
elif " x86 " in self . android_abi :
self . targetarch = " x86 "
2012-08-07 15:35:13 +08:00
elif " mips " in self . android_abi :
self . targetarch = " mips "
2012-01-24 00:28:46 +08:00
else :
self . targetarch = " ARM "
2011-09-06 23:30:28 +08:00
elif self . is_x64 and hostmachine in [ " AMD64 " , " x86_64 " ] :
self . targetarch = " x64 "
elif hostmachine in [ " x86 " , " AMD64 " , " x86_64 " ] :
self . targetarch = " x86 "
else :
self . targetarch = " unknown "
2012-06-25 19:24:06 +08:00
2011-09-08 19:01:45 +08:00
# fix CUDA attributes
self . with_cuda = self . with_cuda == " ON "
if self . cuda_library and self . cuda_library . endswith ( " -NOTFOUND " ) :
self . cuda_library = None
self . has_cuda = self . with_cuda and self . cuda_library and self . targetarch in [ " x86 " , " x64 " ]
2012-06-25 19:24:06 +08:00
2011-09-06 23:30:28 +08:00
self . hardware = None
2012-06-25 19:24:06 +08:00
2012-08-07 15:35:13 +08:00
self . cmake_home_vcver = self . getVCVersion ( self . cmake_home )
2011-09-06 23:30:28 +08:00
if self . opencv_home == self . cmake_home :
2012-08-07 15:35:13 +08:00
self . opencv_home_vcver = self . cmake_home_vcver
2011-09-06 23:30:28 +08:00
else :
2012-08-07 15:35:13 +08:00
self . opencv_home_vcver = self . getVCVersion ( self . opencv_home )
2012-06-25 19:24:06 +08:00
2011-09-06 23:30:28 +08:00
self . tests = self . getAvailableTestApps ( )
2012-06-25 19:24:06 +08:00
2012-08-07 15:35:13 +08:00
def getVCVersion ( self , root_path ) :
2012-08-29 23:16:11 +08:00
if not root_path :
return None
2012-08-07 15:35:13 +08:00
if os . path . isdir ( os . path . join ( root_path , " .svn " ) ) :
return self . getSvnVersion ( root_path )
elif os . path . isdir ( os . path . join ( root_path , " .git " ) ) :
return self . getGitHash ( root_path )
return None
def getGitHash ( self , path ) :
if not path or not self . git_executable :
return None
try :
output = Popen ( [ self . git_executable , " rev-parse " , " --short " , " HEAD " ] , stdout = PIPE , stderr = PIPE , cwd = path ) . communicate ( )
if not output [ 1 ] :
return output [ 0 ] . strip ( )
else :
return None
except OSError :
return None
def getSvnVersion ( self , path ) :
2011-09-06 23:30:28 +08:00
if not path :
2012-08-06 22:41:20 +08:00
val = None
elif not self . svnversion_path and hostos == ' nt ' :
2012-08-07 15:35:13 +08:00
val = self . tryGetSvnVersionWithTortoise ( path )
2011-09-06 23:30:28 +08:00
else :
svnversion = self . svnversion_path
if not svnversion :
svnversion = " svnversion "
try :
output = Popen ( [ svnversion , " -n " , path ] , stdout = PIPE , stderr = PIPE ) . communicate ( )
if not output [ 1 ] :
2012-08-06 22:41:20 +08:00
val = output [ 0 ]
2011-09-06 23:30:28 +08:00
else :
2012-08-06 22:41:20 +08:00
val = None
2011-09-06 23:30:28 +08:00
except OSError :
2012-08-06 22:41:20 +08:00
val = None
if val :
val = val . replace ( " " , " _ " )
2012-08-07 15:35:13 +08:00
return val
2012-06-25 19:24:06 +08:00
2012-08-07 15:35:13 +08:00
def tryGetSvnVersionWithTortoise ( self , path ) :
2011-09-06 23:30:28 +08:00
try :
wcrev = " SubWCRev.exe "
dir = tempfile . mkdtemp ( )
#print dir
tmpfilename = os . path . join ( dir , " svn.tmp " )
tmpfilename2 = os . path . join ( dir , " svn_out.tmp " )
tmpfile = open ( tmpfilename , " w " )
tmpfile . write ( " $WCRANGE$$WCMODS?M:$ " )
tmpfile . close ( ) ;
output = Popen ( [ wcrev , path , tmpfilename , tmpfilename2 , " -f " ] , stdout = PIPE , stderr = PIPE ) . communicate ( )
if " is not a working copy " in output [ 0 ] :
version = " exported "
else :
tmpfile = open ( tmpfilename2 , " r " )
version = tmpfile . read ( )
tmpfile . close ( )
2012-08-06 22:41:20 +08:00
return version
2011-09-06 23:30:28 +08:00
except :
2012-08-06 22:41:20 +08:00
return None
2011-09-06 23:30:28 +08:00
finally :
if dir :
shutil . rmtree ( dir )
2012-06-25 19:24:06 +08:00
2011-09-06 23:30:28 +08:00
def isTest ( self , fullpath ) :
if not os . path . isfile ( fullpath ) :
return False
2012-04-30 22:33:52 +08:00
if self . targetos == " nt " and not fullpath . endswith ( " .exe " ) :
return False
2011-09-06 23:30:28 +08:00
if hostos == self . targetos :
return os . access ( fullpath , os . X_OK )
2012-04-14 05:50:59 +08:00
if self . targetos == " android " and fullpath . endswith ( " .apk " ) :
return True
2011-09-06 23:30:28 +08:00
return True
2012-06-25 19:24:06 +08:00
2011-09-06 23:30:28 +08:00
def getAvailableTestApps ( self ) :
if self . tests_dir and os . path . isdir ( self . tests_dir ) :
2012-04-14 05:50:59 +08:00
files = glob . glob ( os . path . join ( self . tests_dir , self . nameprefix + " * " ) )
files = [ f for f in files if self . isTest ( f ) ]
2011-09-06 23:30:28 +08:00
return files
return [ ]
2012-06-25 19:24:06 +08:00
2011-09-06 23:30:28 +08:00
def getLogName ( self , app , timestamp ) :
app = os . path . basename ( app )
if app . endswith ( " .exe " ) :
2012-04-30 22:33:52 +08:00
if app . endswith ( " d.exe " ) :
app = app [ : - 5 ]
else :
app = app [ : - 4 ]
2012-04-14 05:50:59 +08:00
if app . startswith ( self . nameprefix ) :
app = app [ len ( self . nameprefix ) : ]
2012-01-24 00:28:46 +08:00
2012-08-07 15:35:13 +08:00
if self . cmake_home_vcver :
if self . cmake_home_vcver == self . opencv_home_vcver :
rev = self . cmake_home_vcver
elif self . opencv_home_vcver :
rev = self . cmake_home_vcver + " - " + self . opencv_home_vcver
2011-09-06 23:30:28 +08:00
else :
2012-08-07 15:35:13 +08:00
rev = self . cmake_home_vcver
2011-09-06 23:30:28 +08:00
else :
rev = None
if rev :
2012-01-24 00:28:46 +08:00
rev = rev . replace ( " : " , " to " )
2011-09-06 23:30:28 +08:00
else :
rev = " "
2012-01-24 00:28:46 +08:00
if self . options . useLongNames :
if not rev :
rev = " unknown "
tstamp = timestamp . strftime ( " % Y % m %d - % H % M % S " )
features = [ ]
#OS
_os = " "
if self . targetos == " android " :
_os = " Android " + self . runAdb ( " shell " , " getprop ro.build.version.release " ) . strip ( )
else :
mv = platform . mac_ver ( )
if mv [ 0 ] :
_os = " Darwin " + mv [ 0 ]
else :
wv = platform . win32_ver ( )
if wv [ 0 ] :
_os = " Windows " + wv [ 0 ]
else :
lv = platform . linux_distribution ( )
if lv [ 0 ] :
_os = lv [ 0 ] + lv [ 1 ]
else :
_os = self . targetos
features . append ( _os )
#HW(x86, x64, ARMv7a)
if self . targetarch :
features . append ( self . targetarch )
#TBB
if " ;tbb; " in self . core_dependencies :
features . append ( " TBB " )
#CUDA
if self . has_cuda :
#TODO: determine compute capability
features . append ( " CUDA " )
#SIMD
compiler_output = " "
try :
tmpfile = tempfile . mkstemp ( suffix = " .cpp " , text = True )
fd = os . fdopen ( tmpfile [ 0 ] , " w+b " )
fd . write ( SIMD_DETECTION_PROGRAM )
fd . close ( ) ;
2012-12-08 19:43:23 +08:00
options = [ self . cxx_compiler ]
if self . cxx_compiler_arg1 :
options . append ( self . cxx_compiler_arg1 )
2012-01-24 19:46:11 +08:00
cxx_flags = self . cxx_flags + " " + self . cxx_flags_release + " " + self . opencv_cxx_flags + " " + self . opencv_cxx_flags_release
2012-12-08 19:43:23 +08:00
if self . targetos == " android " and self . cxx_flags_android :
2012-01-24 00:28:46 +08:00
cxx_flags = self . cxx_flags_android + " " + cxx_flags
prev_option = None
for opt in cxx_flags . split ( " " ) :
if opt . count ( ' \" ' ) % 2 == 1 :
if prev_option is None :
prev_option = opt
else :
options . append ( prev_option + " " + opt )
prev_option = None
elif prev_option is None :
options . append ( opt )
else :
prev_option = prev_option + " " + opt
options . append ( tmpfile [ 1 ] )
output = Popen ( options , stdout = PIPE , stderr = PIPE ) . communicate ( )
compiler_output = output [ 1 ]
os . remove ( tmpfile [ 1 ] )
except OSError :
pass
if compiler_output :
m = re . search ( " #error \ W+( \ w+) " , compiler_output )
if m :
features . append ( m . group ( 1 ) )
#fin
return " %s __ %s __ %s __ %s .xml " % ( app , rev , tstamp , " _ " . join ( features ) )
2011-09-06 23:30:28 +08:00
else :
2012-01-24 00:28:46 +08:00
if rev :
rev = rev + " _ "
if self . hardware :
hw = str ( self . hardware ) . replace ( " " , " _ " ) + " _ "
elif self . has_cuda :
hw = " CUDA_ "
else :
hw = " "
2012-08-07 15:35:13 +08:00
tstamp = timestamp . strftime ( " % Y % m %d - % H % M % S " )
2012-01-24 00:28:46 +08:00
return " %s _ %s _ %s _ %s %s %s .xml " % ( app , self . targetos , self . targetarch , hw , rev , tstamp )
2012-06-25 19:24:06 +08:00
2011-09-06 23:30:28 +08:00
def getTest ( self , name ) :
# full path
if self . isTest ( name ) :
return name
2012-06-25 19:24:06 +08:00
2011-09-06 23:30:28 +08:00
# name only
fullname = os . path . join ( self . tests_dir , name )
if self . isTest ( fullname ) :
return fullname
2012-06-25 19:24:06 +08:00
2011-09-06 23:30:28 +08:00
# name without extension
fullname + = " .exe "
if self . isTest ( fullname ) :
return fullname
2012-04-14 05:50:59 +08:00
if self . targetos == " android " :
fullname + = " .apk "
if self . isTest ( fullname ) :
return fullname
2012-06-25 19:24:06 +08:00
2011-09-06 23:30:28 +08:00
# short name for OpenCV tests
for t in self . tests :
if t == name :
return t
fname = os . path . basename ( t )
if fname == name :
return t
2012-04-14 05:50:59 +08:00
if fname . endswith ( " .exe " ) or ( self . targetos == " android " and fname . endswith ( " .apk " ) ) :
2012-07-03 05:07:32 +08:00
fname = fname [ : - 4 ]
2011-09-06 23:30:28 +08:00
if fname == name :
return t
2012-07-03 05:07:32 +08:00
if self . options . configuration == " Debug " and fname == name + ' d ' :
return t
2012-04-14 05:50:59 +08:00
if fname . startswith ( self . nameprefix ) :
fname = fname [ len ( self . nameprefix ) : ]
2011-09-06 23:30:28 +08:00
if fname == name :
return t
2012-07-03 05:07:32 +08:00
if self . options . configuration == " Debug " and fname == name + ' d ' :
return t
2011-09-06 23:30:28 +08:00
return None
2012-06-25 19:24:06 +08:00
2011-09-06 23:30:28 +08:00
def runAdb ( self , * args ) :
2011-12-19 15:43:07 +08:00
cmd = self . adb [ : ]
2011-09-06 23:30:28 +08:00
cmd . extend ( args )
try :
output = Popen ( cmd , stdout = PIPE , stderr = PIPE ) . communicate ( )
if not output [ 1 ] :
return output [ 0 ]
self . error = output [ 1 ]
except OSError :
pass
return None
2012-06-25 19:24:06 +08:00
2011-09-06 23:30:28 +08:00
def isRunnable ( self ) :
2011-12-19 15:43:07 +08:00
if self . error :
return False
2011-09-06 23:30:28 +08:00
if self . targetarch == " x64 " and hostmachine == " x86 " :
self . error = " Target architecture is incompatible with current platform (at %s ) " % self . path
return False
if self . targetos == " android " :
2011-09-15 14:31:59 +08:00
if not self . adb :
self . error = " Could not find adb executable (for %s ) " % self . path
2011-09-06 23:30:28 +08:00
return False
2011-11-16 22:32:10 +08:00
if " armeabi-v7a " in self . android_abi :
2011-09-06 23:30:28 +08:00
adb_res = self . runAdb ( " shell " , " cat /proc/cpuinfo " )
if not adb_res :
2011-09-15 14:31:59 +08:00
self . error = " Could not get info about Android platform: %s (for %s ) " % ( self . error , self . path )
2011-09-06 23:30:28 +08:00
return False
if " ARMv7 " not in adb_res :
2011-09-15 14:31:59 +08:00
self . error = " Android device does not support ARMv7 commands, but tests are built for armeabi-v7a (for %s ) " % self . path
2011-09-06 23:30:28 +08:00
return False
2011-11-16 22:32:10 +08:00
if " NEON " in self . android_abi and " neon " not in adb_res :
self . error = " Android device has no NEON, but tests are built for %s (for %s ) " % ( self . android_abi , self . path )
2011-09-06 23:30:28 +08:00
return False
hw = re . search ( r " ^Hardware[ \ t]*:[ \ t]*(.*?)$ " , adb_res , re . MULTILINE )
if hw :
self . hardware = hw . groups ( ) [ 0 ] . strip ( )
return True
2012-06-25 19:24:06 +08:00
2011-09-06 23:30:28 +08:00
def runTest ( self , path , workingDir , _stdout , _stderr , args = [ ] ) :
if self . error :
return
args = args [ : ]
timestamp = datetime . datetime . now ( )
logfile = self . getLogName ( path , timestamp )
exe = os . path . abspath ( path )
2012-06-25 19:24:06 +08:00
2011-09-06 23:30:28 +08:00
userlog = [ a for a in args if a . startswith ( " --gtest_output= " ) ]
if len ( userlog ) == 0 :
args . append ( " --gtest_output=xml: " + logfile )
else :
2011-11-30 19:30:45 +08:00
logfile = userlog [ 0 ] [ userlog [ 0 ] . find ( " : " ) + 1 : ]
2012-06-25 19:24:06 +08:00
2012-04-14 05:50:59 +08:00
if self . targetos == " android " and exe . endswith ( " .apk " ) :
2012-12-08 19:43:23 +08:00
print " Run java tests: " , exe
2012-04-14 05:50:59 +08:00
try :
# get package info
output = Popen ( self . aapt + [ " dump " , " xmltree " , exe , " AndroidManifest.xml " ] , stdout = PIPE , stderr = _stderr ) . communicate ( )
if not output [ 0 ] :
2012-12-08 19:43:23 +08:00
print >> _stderr , " fail to dump manifest from " , exe
2012-04-14 05:50:59 +08:00
return
tags = re . split ( r " [ ]+E: " , output [ 0 ] )
2012-12-08 19:43:23 +08:00
# get package name
2012-04-14 05:50:59 +08:00
manifest_tag = [ t for t in tags if t . startswith ( " manifest " ) ]
if not manifest_tag :
2012-12-08 19:43:23 +08:00
print >> _stderr , " fail to read package name from " , exe
2012-04-14 05:50:59 +08:00
return
2012-05-03 15:50:24 +08:00
pkg_name = re . search ( r " ^[ ]+A: package= \" (?P<pkg>.*?) \" \ (Raw: \" (?P=pkg) \" \ ) \ r?$ " , manifest_tag [ 0 ] , flags = re . MULTILINE ) . group ( " pkg " )
2012-12-08 19:43:23 +08:00
# get test instrumentation info
2012-04-14 05:50:59 +08:00
instrumentation_tag = [ t for t in tags if t . startswith ( " instrumentation " ) ]
if not instrumentation_tag :
print >> _stderr , " can not find instrumentation detials in " , exe
return
2012-05-03 15:50:24 +08:00
pkg_runner = re . search ( r " ^[ ]+A: android:name \ (0x[0-9a-f] {8} \ )= \" (?P<runner>.*?) \" \ (Raw: \" (?P=runner) \" \ ) \ r?$ " , instrumentation_tag [ 0 ] , flags = re . MULTILINE ) . group ( " runner " )
pkg_target = re . search ( r " ^[ ]+A: android:targetPackage \ (0x[0-9a-f] {8} \ )= \" (?P<pkg>.*?) \" \ (Raw: \" (?P=pkg) \" \ ) \ r?$ " , instrumentation_tag [ 0 ] , flags = re . MULTILINE ) . group ( " pkg " )
2012-04-14 05:50:59 +08:00
if not pkg_name or not pkg_runner or not pkg_target :
print >> _stderr , " can not find instrumentation detials in " , exe
return
if self . options . junit_package :
if self . options . junit_package . startswith ( " . " ) :
pkg_target + = self . options . junit_package
else :
pkg_target = self . options . junit_package
2012-12-08 19:43:23 +08:00
# uninstall previously installed package
2012-04-14 05:50:59 +08:00
print >> _stderr , " Uninstalling old " , pkg_name , " from device... "
2012-05-03 15:50:24 +08:00
Popen ( self . adb + [ " uninstall " , pkg_name ] , stdout = PIPE , stderr = _stderr ) . communicate ( )
print >> _stderr , " Installing new " , exe , " to device... " ,
output = Popen ( self . adb + [ " install " , exe ] , stdout = PIPE , stderr = PIPE ) . communicate ( )
if output [ 0 ] and output [ 0 ] . strip ( ) . endswith ( " Success " ) :
print >> _stderr , " Success "
else :
print >> _stderr , " Failure "
print >> _stderr , " Failed to install " , exe , " to device "
2012-04-14 05:50:59 +08:00
return
print >> _stderr , " Running jUnit tests for " , pkg_target
2012-12-08 19:43:23 +08:00
if self . setUp :
2012-04-14 05:50:59 +08:00
self . setUp ( )
Popen ( self . adb + [ " shell " , " am instrument -w -e package " + pkg_target + " " + pkg_name + " / " + pkg_runner ] , stdout = _stdout , stderr = _stderr ) . wait ( )
2012-12-08 19:43:23 +08:00
if self . tearDown :
2012-04-14 05:50:59 +08:00
self . tearDown ( )
except OSError :
pass
return
elif self . targetos == " android " :
2012-03-15 16:31:57 +08:00
hostlogpath = " "
2012-04-30 22:33:52 +08:00
usercolor = [ a for a in args if a . startswith ( " --gtest_color= " ) ]
2012-06-25 19:24:06 +08:00
if len ( usercolor ) == 0 and _stdout . isatty ( ) and hostos != " nt " :
2012-04-30 22:33:52 +08:00
args . append ( " --gtest_color=yes " )
2011-09-06 23:30:28 +08:00
try :
2012-06-25 19:24:06 +08:00
tempdir = " /data/local/tmp/ "
andoidcwd = tempdir + getpass . getuser ( ) . replace ( " " , " " ) + " _ " + self . options . mode + " / "
2011-09-06 23:30:28 +08:00
exename = os . path . basename ( exe )
androidexe = andoidcwd + exename
2012-12-08 19:43:23 +08:00
# upload
2012-11-24 18:11:07 +08:00
_stderr . write ( " Uploading... " )
2011-12-19 15:43:07 +08:00
output = Popen ( self . adb + [ " push " , exe , androidexe ] , stdout = _stdout , stderr = _stderr ) . wait ( )
2011-09-06 23:30:28 +08:00
if output != 0 :
print >> _stderr , " adb finishes unexpectedly with error code " , output
return
2012-12-08 19:43:23 +08:00
# chmod
2011-12-19 15:43:07 +08:00
output = Popen ( self . adb + [ " shell " , " chmod 777 " + androidexe ] , stdout = _stdout , stderr = _stderr ) . wait ( )
2011-09-06 23:30:28 +08:00
if output != 0 :
print >> _stderr , " adb finishes unexpectedly with error code " , output
return
2012-12-08 19:43:23 +08:00
# run
2012-03-15 16:31:57 +08:00
if self . options . help :
command = exename + " --help "
else :
command = exename + " " + " " . join ( args )
2012-11-24 18:11:07 +08:00
print >> _stderr , " Run command: " , command
2012-12-08 19:43:23 +08:00
if self . setUp :
2012-04-14 05:50:59 +08:00
self . setUp ( )
2012-12-08 19:43:23 +08:00
Popen ( self . adb + [ " shell " , " export OPENCV_TEST_DATA_PATH= " + self . options . test_data_path + " && cd " + andoidcwd + " && ./ " + command ] , stdout = _stdout , stderr = _stderr ) . wait ( )
if self . tearDown :
2012-04-14 05:50:59 +08:00
self . tearDown ( )
2011-09-06 23:30:28 +08:00
# try get log
2012-03-15 16:31:57 +08:00
if not self . options . help :
2012-11-24 18:11:07 +08:00
#_stderr.write("Pull log... ")
2012-03-15 16:31:57 +08:00
hostlogpath = os . path . join ( workingDir , logfile )
2012-11-24 18:11:07 +08:00
output = Popen ( self . adb + [ " pull " , andoidcwd + logfile , hostlogpath ] , stdout = _stdout , stderr = PIPE ) . wait ( )
2012-03-15 16:31:57 +08:00
if output != 0 :
print >> _stderr , " adb finishes unexpectedly with error code " , output
return
#rm log
2012-11-24 18:11:07 +08:00
Popen ( self . adb + [ " shell " , " rm " + andoidcwd + logfile ] , stdout = PIPE , stderr = PIPE ) . wait ( )
2012-06-25 19:24:06 +08:00
# clean temporary files
2012-11-24 18:11:07 +08:00
Popen ( self . adb + [ " shell " , " rm " + tempdir + " __opencv_temp.* " ] , stdout = PIPE , stderr = PIPE ) . wait ( )
2011-09-06 23:30:28 +08:00
except OSError :
pass
if os . path . isfile ( hostlogpath ) :
return hostlogpath
return None
else :
cmd = [ exe ]
2012-03-15 16:31:57 +08:00
if self . options . help :
cmd . append ( " --help " )
else :
cmd . extend ( args )
2012-07-03 05:07:32 +08:00
orig_temp_path = os . environ . get ( ' OPENCV_TEMP_PATH ' )
temp_path = tempfile . mkdtemp ( prefix = " __opencv_temp. " , dir = orig_temp_path or None )
os . environ [ ' OPENCV_TEMP_PATH ' ] = temp_path
2012-11-24 18:11:07 +08:00
print >> _stderr , " Run command: " , " " . join ( cmd )
2012-06-25 19:24:06 +08:00
try :
2011-09-06 23:30:28 +08:00
Popen ( cmd , stdout = _stdout , stderr = _stderr , cwd = workingDir ) . wait ( )
except OSError :
pass
2012-06-25 19:24:06 +08:00
# clean temporary files
2012-07-03 05:07:32 +08:00
if orig_temp_path :
os . environ [ ' OPENCV_TEMP_PATH ' ] = orig_temp_path
else :
del os . environ [ ' OPENCV_TEMP_PATH ' ]
2012-06-25 19:24:06 +08:00
2012-07-02 20:23:57 +08:00
try :
2012-07-03 05:07:32 +08:00
shutil . rmtree ( temp_path )
2012-12-08 19:43:23 +08:00
pass
2012-07-02 20:23:57 +08:00
except :
pass
2012-06-25 19:24:06 +08:00
2011-09-06 23:30:28 +08:00
logpath = os . path . join ( workingDir , logfile )
if os . path . isfile ( logpath ) :
return logpath
return None
2012-06-25 19:24:06 +08:00
2011-09-06 23:30:28 +08:00
def runTests ( self , tests , _stdout , _stderr , workingDir , args = [ ] ) :
2012-12-08 19:43:23 +08:00
if not self . isRunnable ( ) :
print >> _stderr , " Error: " , self . error
2011-09-06 23:30:28 +08:00
if self . error :
return [ ]
2012-12-08 19:43:23 +08:00
if self . adb and self . targetos == " android " :
print " adb command: " , " " . join ( self . adb )
2011-09-06 23:30:28 +08:00
if not tests :
tests = self . tests
logs = [ ]
for test in tests :
t = self . getTest ( test )
if t :
logfile = self . runTest ( t , workingDir , _stdout , _stderr , args )
if logfile :
logs . append ( os . path . relpath ( logfile , " . " ) )
else :
print >> _stderr , " Error: Test \" %s \" is not found in %s " % ( test , self . tests_dir )
return logs
2012-04-14 05:50:59 +08:00
def getRunArgs ( args ) :
run_args = [ ]
for path in args :
path = os . path . abspath ( path )
while ( True ) :
if os . path . isdir ( path ) and os . path . isfile ( os . path . join ( path , " CMakeCache.txt " ) ) :
run_args . append ( path )
break
npath = os . path . dirname ( path )
if npath == path :
break
path = npath
return run_args
2011-09-06 23:30:28 +08:00
if __name__ == " __main__ " :
test_args = [ a for a in sys . argv if a . startswith ( " --perf_ " ) or a . startswith ( " --gtest_ " ) ]
argv = [ a for a in sys . argv if not ( a . startswith ( " --perf_ " ) or a . startswith ( " --gtest_ " ) ) ]
2012-06-25 19:24:06 +08:00
2011-09-06 23:30:28 +08:00
parser = OptionParser ( )
parser . add_option ( " -t " , " --tests " , dest = " tests " , help = " comma-separated list of modules to test " , metavar = " SUITS " , default = " " )
parser . add_option ( " -w " , " --cwd " , dest = " cwd " , help = " working directory for tests " , metavar = " PATH " , default = " . " )
2012-04-14 05:50:59 +08:00
parser . add_option ( " -a " , " --accuracy " , dest = " accuracy " , help = " look for accuracy tests instead of performance tests " , action = " store_true " , default = False )
2012-01-24 00:28:46 +08:00
parser . add_option ( " -l " , " --longname " , dest = " useLongNames " , action = " store_true " , help = " generate log files with long names " , default = False )
2011-09-06 23:30:28 +08:00
parser . add_option ( " " , " --android_test_data_path " , dest = " test_data_path " , help = " OPENCV_TEST_DATA_PATH for Android run " , metavar = " PATH " , default = " /sdcard/opencv_testdata/ " )
2012-04-30 22:33:52 +08:00
parser . add_option ( " " , " --configuration " , dest = " configuration " , help = " force Debug or Release configuration " , metavar = " CFG " , default = " " )
2011-12-19 15:43:07 +08:00
parser . add_option ( " " , " --serial " , dest = " adb_serial " , help = " Android: directs command to the USB device or emulator with the given serial number " , metavar = " serial number " , default = " " )
2012-04-14 05:50:59 +08:00
parser . add_option ( " " , " --package " , dest = " junit_package " , help = " Android: run jUnit tests for specified package " , metavar = " package " , default = " " )
2012-03-15 16:31:57 +08:00
parser . add_option ( " " , " --help-tests " , dest = " help " , help = " Show help for test executable " , action = " store_true " , default = False )
2012-11-24 18:12:32 +08:00
parser . add_option ( " " , " --check " , dest = " check " , help = " Shortcut for ' --perf_min_samples=1 --perf_force_samples=1 ' " , action = " store_true " , default = False )
2012-12-08 19:43:23 +08:00
parser . add_option ( " " , " --list " , dest = " list " , help = " List available tests " , action = " store_true " , default = False )
2012-06-25 19:24:06 +08:00
2011-09-06 23:30:28 +08:00
( options , args ) = parser . parse_args ( argv )
2012-04-14 05:50:59 +08:00
if options . accuracy :
options . mode = " test "
else :
options . mode = " perf "
2012-06-25 19:24:06 +08:00
2012-04-30 22:33:52 +08:00
run_args = getRunArgs ( args [ 1 : ] or [ ' . ' ] )
2012-06-25 19:24:06 +08:00
2011-09-06 23:30:28 +08:00
if len ( run_args ) == 0 :
2012-12-08 19:43:23 +08:00
print >> sys . stderr , " Usage: " , os . path . basename ( sys . argv [ 0 ] ) , " [options] [build_path] "
2011-09-06 23:30:28 +08:00
exit ( 1 )
2012-06-25 19:24:06 +08:00
2011-09-06 23:30:28 +08:00
tests = [ s . strip ( ) for s in options . tests . split ( " , " ) if s ]
2012-06-25 19:24:06 +08:00
2011-09-06 23:30:28 +08:00
if len ( tests ) != 1 or len ( run_args ) != 1 :
2012-11-24 18:11:07 +08:00
# remove --gtest_output from params
2011-09-06 23:30:28 +08:00
test_args = [ a for a in test_args if not a . startswith ( " --gtest_output= " ) ]
2012-06-25 19:24:06 +08:00
2012-11-24 18:12:32 +08:00
if options . check :
2012-12-08 19:43:23 +08:00
if not [ a for a in test_args if a . startswith ( " --perf_min_samples= " ) ] :
test_args . extend ( [ " --perf_min_samples=1 " ] )
if not [ a for a in test_args if a . startswith ( " --perf_force_samples= " ) ] :
test_args . extend ( [ " --perf_force_samples=1 " ] )
2012-12-11 21:16:27 +08:00
if not [ a for a in test_args if a . startswith ( " --perf_verify_sanity " ) ] :
test_args . extend ( [ " --perf_verify_sanity " ] )
2012-11-24 18:12:32 +08:00
2011-09-06 23:30:28 +08:00
logs = [ ]
2012-12-08 19:43:23 +08:00
test_list = [ ]
2011-09-06 23:30:28 +08:00
for path in run_args :
2012-12-08 19:43:23 +08:00
suite = TestSuite ( options , path )
#print vars(suite),"\n"
if options . list :
test_list . extend ( suite . tests )
2011-09-06 23:30:28 +08:00
else :
2012-12-08 19:43:23 +08:00
logs . extend ( suite . runTests ( tests , sys . stdout , sys . stderr , options . cwd , test_args ) )
if options . list :
print os . linesep . join ( test_list ) or " No tests found "
2011-09-06 23:30:28 +08:00
2012-06-25 19:24:06 +08:00
if logs :
2012-11-24 18:11:07 +08:00
print >> sys . stderr , " Collected: " , " " . join ( logs )