From ad58e9658130664bd1523f761f3f92e1465ff984 Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Tue, 2 Oct 2012 14:59:00 +0400 Subject: [PATCH] Automation for build and test OpenCV Manager on several devices added. --- android/service/all.py | 43 ++++++++++++++++++++++++++++++++++ android/service/device.conf | 3 +++ android/service/push_native.py | 12 +++++++--- android/service/test_native.py | 19 +++++++++------ 4 files changed, 67 insertions(+), 10 deletions(-) create mode 100755 android/service/all.py create mode 100644 android/service/device.conf diff --git a/android/service/all.py b/android/service/all.py new file mode 100755 index 000000000..98912fd7d --- /dev/null +++ b/android/service/all.py @@ -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 index 000000000..2953b5451 --- /dev/null +++ b/android/service/device.conf @@ -0,0 +1,3 @@ +armeabi;15c000000581404; +x86;0123456789ABCDEF; +mips;Novo7 Basic; \ No newline at end of file diff --git a/android/service/push_native.py b/android/service/push_native.py index ada62e6df..a8d12be98 100755 --- a/android/service/push_native.py +++ b/android/service/push_native.py @@ -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)) diff --git a/android/service/test_native.py b/android/service/test_native.py index 3c84c7cdc..120bbce29 100755 --- a/android/service/test_native.py +++ b/android/service/test_native.py @@ -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))