Bug 859705 - Un-szip libraries before pushing them on the device for xpcshell tests. r=ted
authorMike Hommey <mh+mozilla@glandium.org>
Thu, 18 Apr 2013 09:14:38 +0200
changeset 140978 91e97665da3e482c35c9a0db5f30597262d46b51
parent 140977 f60097ccd2a2f61121cf5c7f31b42f9259add5f0
child 140979 825ac604a69b6dd1d2f3dee774dcf1390182a092
push id2579
push userakeybl@mozilla.com
push dateMon, 24 Jun 2013 18:52:47 +0000
treeherdermozilla-beta@b69b7de8a05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersted
bugs859705
milestone23.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 859705 - Un-szip libraries before pushing them on the device for xpcshell tests. r=ted
testing/testsuite-targets.mk
testing/xpcshell/remotexpcshelltests.py
--- a/testing/testsuite-targets.mk
+++ b/testing/testsuite-targets.mk
@@ -449,16 +449,20 @@ stage-reftest: make-stage-dir
 
 stage-xpcshell: make-stage-dir
 	$(MAKE) -C $(DEPTH)/testing/xpcshell stage-package
 
 stage-jstests: make-stage-dir
 	$(MAKE) -C $(DEPTH)/js/src/tests stage-package
 
 stage-android: make-stage-dir
+ifdef MOZ_ENABLE_SZIP
+# Tinderbox scripts are not unzipping everything, so the file needs to be in a directory it unzips
+	$(NSINSTALL) $(DIST)/host/bin/szip $(PKG_STAGE)/bin/host
+endif
 	$(NSINSTALL) $(DEPTH)/build/mobile/sutagent/android/sutAgentAndroid.apk $(PKG_STAGE)/bin
 	$(NSINSTALL) $(DEPTH)/build/mobile/sutagent/android/watcher/Watcher.apk $(PKG_STAGE)/bin
 	$(NSINSTALL) $(DEPTH)/build/mobile/sutagent/android/fencp/FenCP.apk $(PKG_STAGE)/bin
 	$(NSINSTALL) $(DEPTH)/build/mobile/sutagent/android/ffxcp/FfxCP.apk $(PKG_STAGE)/bin
 
 stage-jetpack: make-stage-dir
 	$(NSINSTALL) $(topsrcdir)/testing/jetpack/jetpack-location.txt $(PKG_STAGE)/jetpack
 	$(MAKE) -C $(DEPTH)/addon-sdk stage-tests-package
--- a/testing/xpcshell/remotexpcshelltests.py
+++ b/testing/xpcshell/remotexpcshelltests.py
@@ -5,16 +5,18 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 import sys, os
 import subprocess
 import runxpcshelltests as xpcshell
 import tempfile
 from automationutils import replaceBackSlashes
 import devicemanagerADB, devicemanagerSUT, devicemanager
+from zipfile import ZipFile
+import shutil
 
 here = os.path.dirname(os.path.abspath(__file__))
 
 # A specialization of XPCShellTests that runs tests on an Android device
 # via devicemanager.
 class XPCShellRemote(xpcshell.XPCShellTests, object):
 
     def __init__(self, devmgr, options, args):
@@ -47,32 +49,34 @@ class XPCShellRemote(xpcshell.XPCShellTe
         if self.options.objdir:
             self.xpcDir = os.path.join(self.options.objdir, "_tests/xpcshell")
         elif os.path.isdir(os.path.join(here, 'tests')):
             self.xpcDir = os.path.join(here, 'tests')
         else:
             print >> sys.stderr, "Couldn't find local xpcshell test directory"
             sys.exit(1)
 
+        if options.localAPK:
+            self.localAPKContents = ZipFile(options.localAPK)
         if options.setup:
             self.setupUtilities()
             self.setupModules()
             self.setupTestDir()
         if options.localAPK:
             self.remoteAPK = self.remoteJoin(self.remoteBinDir, os.path.basename(options.localAPK))
             self.setAppRoot()
 
     def setAppRoot(self):
         # Determine the application root directory associated with the package
         # name used by the Fennec APK.
         self.appRoot = None
         packageName = None
         if self.options.localAPK:
             try:
-                packageName = subprocess.check_output(["unzip", "-p", self.options.localAPK, "package-name.txt"])
+                packageName = self.localAPKContents.read("package-name.txt")
                 if packageName:
                     self.appRoot = self.device.getAppRoot(packageName.strip())
             except Exception as detail:
                 print "unable to determine app root: " + str(detail)
                 pass
         return None
 
     def remoteJoin(self, path1, path2):
@@ -124,30 +128,55 @@ class XPCShellRemote(xpcshell.XPCShellTe
 
         if self.options.localAPK:
             remoteFile = self.remoteJoin(self.remoteBinDir, os.path.basename(self.options.localAPK))
             self.device.pushFile(self.options.localAPK, remoteFile)
 
         self.pushLibs()
 
     def pushLibs(self):
+        if self.options.localAPK:
+            try:
+                dir = tempfile.mkdtemp()
+                szip = os.path.join(self.localBin, '..', 'host', 'bin', 'szip')
+                if not os.path.exists(szip):
+                    # Tinderbox builds must run szip from the test package
+                    szip = os.path.join(self.localBin, 'host', 'szip')
+                if not os.path.exists(szip):
+                    # If the test package doesn't contain szip, it means files
+                    # are not szipped in the test package.
+                    szip = None
+                for info in self.localAPKContents.infolist():
+                    if info.filename.endswith(".so"):
+                        print >> sys.stderr, "Pushing %s.." % info.filename
+                        remoteFile = self.remoteJoin(self.remoteBinDir, os.path.basename(info.filename))
+                        self.localAPKContents.extract(info, dir)
+                        file = os.path.join(dir, info.filename)
+                        if szip:
+                            out = subprocess.check_output([szip, '-d', file], stderr=subprocess.STDOUT)
+                        self.device.pushFile(os.path.join(dir, info.filename), remoteFile)
+            finally:
+                shutil.rmtree(dir)
+            return
+
         for file in os.listdir(self.localLib):
             if (file.endswith(".so")):
                 print >> sys.stderr, "Pushing %s.." % file
                 if 'libxul' in file:
                     print >> sys.stderr, "This is a big file, it could take a while."
                 remoteFile = self.remoteJoin(self.remoteBinDir, file)
                 self.device.pushFile(os.path.join(self.localLib, file), remoteFile)
 
         # Additional libraries may be found in a sub-directory such as "lib/armeabi-v7a"
         localArmLib = os.path.join(self.localLib, "lib")
         if os.path.exists(localArmLib):
             for root, dirs, files in os.walk(localArmLib):
                 for file in files:
                     if (file.endswith(".so")):
+                        print >> sys.stderr, "Pushing %s.." % file
                         remoteFile = self.remoteJoin(self.remoteBinDir, file)
                         self.device.pushFile(os.path.join(root, file), remoteFile)
 
     def setupModules(self):
         if self.testingModulesDir:
             self.device.pushDir(self.testingModulesDir, self.remoteModulesDir)
 
     def setupTestDir(self):