Automation for build and test OpenCV Manager on several devices added.
authorAlexander Smorkalov <alexander.smorkalov@itseez.com>
Tue, 2 Oct 2012 10:59:00 +0000 (14:59 +0400)
committerAlexander Smorkalov <alexander.smorkalov@itseez.com>
Tue, 2 Oct 2012 12:21:53 +0000 (16:21 +0400)
android/service/all.py [new file with mode: 0755]
android/service/device.conf [new file with mode: 0644]
android/service/push_native.py
android/service/test_native.py

diff --git a/android/service/all.py b/android/service/all.py
new file mode 100755 (executable)
index 0000000..98912fd
--- /dev/null
@@ -0,0 +1,43 @@
+#!/usr/bin/python
+
+import os
+import sys
+import shutil
+
+LOCAL_LOG_PATH = os.path.join(os.getcwd(), "logs")
+
+if (__name__ ==  "__main__"):
+    if (not os.path.exists(LOCAL_LOG_PATH)):
+       os.makedirs(LOCAL_LOG_PATH)
+    
+    print("Building native part of OpenCV Manager...")
+    HomeDir = os.getcwd()
+    os.chdir(os.path.join(HomeDir, "engine"))
+    shutil.rmtree(os.path.join(HomeDir, "engine", "libs"), ignore_errors=True)
+    shutil.rmtree(os.path.join(HomeDir, "engine", "obj"), ignore_errors=True)
+    BuildCommand = "ndk-build V=1 > \"%s\" 2>&1" % os.path.join(LOCAL_LOG_PATH, "build.log")
+    #print(BuildCommand)
+    res = os.system(BuildCommand)
+    if (0 == res):
+       print("Build\t[OK]")
+    else:
+       print("Build\t[FAILED]")
+       sys.exit(-1)
+       
+    os.chdir(HomeDir)
+    ConfFile = open("device.conf", "rt")
+    
+    for s in ConfFile.readlines():
+       keys = s.split(";")
+       if (len(keys) < 2):
+           print("Error: invalid config line: \"%s\"" % s)
+           continue
+       Arch = keys[0]
+       Name = keys[1]
+       print("testing \"%s\" arch" % Arch)
+       print("Pushing to device \"%s\"" % Name)
+       PushCommand = "%s \"%s\" \"%s\" 2>&1" % (os.path.join(HomeDir, "push_native.py"), Arch, Name)
+       os.system(PushCommand)
+       print("Testing on device \"%s\"" % Name)
+       TestCommand = "%s \"%s\" \"%s\" 2>&1" % (os.path.join(HomeDir, "test_native.py"), Arch, Name)
+       os.system(TestCommand)
\ No newline at end of file
diff --git a/android/service/device.conf b/android/service/device.conf
new file mode 100644 (file)
index 0000000..2953b54
--- /dev/null
@@ -0,0 +1,3 @@
+armeabi;15c000000581404;
+x86;0123456789ABCDEF;
+mips;Novo7 Basic;
\ No newline at end of file
index ada62e6..a8d12be 100755 (executable)
@@ -1,16 +1,22 @@
 #!/usr/bin/python
 
 import os
+import sys
 
 TARGET_DEVICE_PATH = "/data/data/EngineTest"
 DEVICE_NAME = ""
 DEVICE_STR = ""
 DEVICE_ARCH = "armeabi"
-if (DEVICE_NAME != ""):
-    DEVICE_STR = "-s " + DEVICE_NAME
 
 if (__name__ ==  "__main__"):
-    print("Waiting for device ...")
+    if (len(sys.argv) >= 3):
+       DEVICE_ARCH = sys.argv[1]
+       DEVICE_NAME = sys.argv[2]
+
+       if (DEVICE_NAME != ""):
+           DEVICE_STR = "-s \"" + DEVICE_NAME + "\""
+
+    print("Waiting for device \"%s\" with arch \"%s\" ..." % (DEVICE_NAME, DEVICE_ARCH))
     os.system("adb %s wait-for-device" % DEVICE_STR)
     os.system("adb %s shell mkdir -p %s" % (DEVICE_STR, TARGET_DEVICE_PATH))
     os.system("adb %s push ./engine/libs/%s/libOpenCVEngine.so %s" % (DEVICE_STR, DEVICE_ARCH, TARGET_DEVICE_PATH))
index 3c84c7c..120bbce 100755 (executable)
@@ -5,26 +5,31 @@ import sys
 
 DEVICE_NAME = ""
 DEVICE_STR = ""
-if (DEVICE_NAME != ""):
-    DEVICE_STR = "-s " + DEVICE_NAME
+DEVICE_ARCH = "armeabi"
 
 LOCAL_LOG_PATH = os.path.join(os.getcwd(), "logs")
 DEVICE_LOG_PATH = "/sdcard/OpenCVEngineLogs"
 DEVICE_BIN_PATH = "/data/data/EngineTest"
 
 def RunTestApp(AppName):
-    TestLog = os.path.join(DEVICE_LOG_PATH, AppName + ".xml")
+    TestLog = os.path.join(DEVICE_LOG_PATH, AppName + "_" + DEVICE_ARCH + ".xml")
     os.system("adb %s shell \"LD_LIBRARY_PATH=%s:$LD_LIBRARY_PATH;%s --gtest_output=\"xml:%s\"\"" % (DEVICE_STR, DEVICE_BIN_PATH, os.path.join(DEVICE_BIN_PATH, AppName), TestLog))
     os.system("adb %s pull \"%s\" \"%s\"" % (DEVICE_STR, TestLog, LOCAL_LOG_PATH))
 
 if (__name__ ==  "__main__"):
-    
+    if (3 == len(sys.argv)):
+       DEVICE_ARCH = sys.argv[1]
+       DEVICE_NAME = sys.argv[2]
+
+       if (DEVICE_NAME != ""):
+           DEVICE_STR = "-s \"" + DEVICE_NAME + "\""
+
     if (not os.path.exists(LOCAL_LOG_PATH)):
        os.makedirs(LOCAL_LOG_PATH)
-    
-    print("Waiting for device ...")
+
+    print("Waiting for device \"%s\" with arch \"%s\" ..." % (DEVICE_NAME, DEVICE_ARCH))
     os.system("adb %s wait-for-device" % DEVICE_STR)
-    
+
     os.system("adb %s shell rm -r \"%s\"" % (DEVICE_STR, DEVICE_LOG_PATH))
     os.system("adb %s shell mkdir -p \"%s\"" % (DEVICE_STR, DEVICE_LOG_PATH))