Bug 1202102 - Apply szip to libs pushed for Android cppunit and xpcshell tests; r=dminor
authorGeoff Brown <gbrown@mozilla.com>
Wed, 09 Sep 2015 07:12:58 -0600
changeset 294188 6422d6fcc6ae4541c4bb7b560dcd341f2580c4c9
parent 294187 f0449939f79ed8ed95dca7f681a0fc04bc6c4e81
child 294189 71a0983417c2549b09aa68677c7f2a2c954311fc
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdminor
bugs1202102
milestone43.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 1202102 - Apply szip to libs pushed for Android cppunit and xpcshell tests; r=dminor
testing/remotecppunittests.py
testing/xpcshell/remotexpcshelltests.py
--- a/testing/remotecppunittests.py
+++ b/testing/remotecppunittests.py
@@ -47,54 +47,78 @@ class RemoteCPPUnitTests(cppunittests.CP
         if self.device.dirExists(self.remote_home_dir):
             self.device.removeDir(self.remote_home_dir)
         self.device.mkDir(self.remote_home_dir)
         self.push_libs()
         self.push_progs(progs)
         self.device.chmodDir(self.remote_bin_dir)
 
     def push_libs(self):
+        if self.options.local_bin is not None:
+            szip = os.path.join(self.options.local_bin, '..', 'host', 'bin', 'szip')
+            if not os.path.exists(szip):
+                # Tinderbox builds must run szip from the test package
+                szip = os.path.join(self.options.local_bin, '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
+        else:
+            szip = None
         if self.options.local_apk:
             with mozfile.TemporaryDirectory() as tmpdir:
                 apk_contents = ZipFile(self.options.local_apk)
-                szip = os.path.join(self.options.local_bin, '..', 'host', 'bin', 'szip')
-                if not os.path.exists(szip):
-                    # Tinderbox builds must run szip from the test package
-                    szip = os.path.join(self.options.local_bin, '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 apk_contents.infolist():
                     if info.filename.endswith(".so"):
                         print >> sys.stderr, "Pushing %s.." % info.filename
                         remote_file = posixpath.join(self.remote_bin_dir, os.path.basename(info.filename))
                         apk_contents.extract(info, tmpdir)
-                        file = os.path.join(tmpdir, info.filename)
+                        local_file = os.path.join(tmpdir, info.filename)
                         if szip:
-                            out = subprocess.check_output([szip, '-d', file], stderr=subprocess.STDOUT)
-                        self.device.pushFile(os.path.join(tmpdir, info.filename), remote_file)
-            return
+                            try:
+                                out = subprocess.check_output([szip, '-d', local_file], stderr=subprocess.STDOUT)
+                            except CalledProcessError:
+                                print >> sys.stderr, "Error calling %s on %s.." % (szip, local_file)
+                                if out:
+                                    print >> sys.stderr, out
+                        self.device.pushFile(local_file, remote_file)
 
         elif self.options.local_lib:
             for file in os.listdir(self.options.local_lib):
                 if file.endswith(".so"):
                     print >> sys.stderr, "Pushing %s.." % file
                     remote_file = posixpath.join(self.remote_bin_dir, file)
-                    self.device.pushFile(os.path.join(self.options.local_lib, file), remote_file)
+                    local_file = os.path.join(self.options.local_lib, file)
+                    if szip:
+                        try:
+                            out = subprocess.check_output([szip, '-d', local_file], stderr=subprocess.STDOUT)
+                        except CalledProcessError:
+                            print >> sys.stderr, "Error calling %s on %s.." % (szip, local_file)
+                            if out:
+                                print >> sys.stderr, out
+                    self.device.pushFile(local_file, remote_file)
             # Additional libraries may be found in a sub-directory such as "lib/armeabi-v7a"
             for subdir in ["assets", "lib"]:
                 local_arm_lib = os.path.join(self.options.local_lib, subdir)
                 if os.path.isdir(local_arm_lib):
                     for root, dirs, files in os.walk(local_arm_lib):
                         for file in files:
                             if (file.endswith(".so")):
+                                print >> sys.stderr, "Pushing %s.." % file
                                 remote_file = posixpath.join(self.remote_bin_dir, file)
-                                self.device.pushFile(os.path.join(root, file), remote_file)
+                                local_file = os.path.join(root, file)
+                                if szip:
+                                    try:
+                                        out = subprocess.check_output([szip, '-d', local_file], stderr=subprocess.STDOUT)
+                                    except CalledProcessError:
+                                        print >> sys.stderr, "Error calling %s on %s.." % (szip, local_file)
+                                        if out:
+                                            print >> sys.stderr, out
+                                self.device.pushFile(local_file, remote_file)
 
     def push_progs(self, progs):
         for local_file in progs:
             remote_file = posixpath.join(self.remote_bin_dir, os.path.basename(local_file))
             self.device.pushFile(local_file, remote_file)
 
     def build_environment(self):
         env = self.build_core_environment()
--- a/testing/xpcshell/remotexpcshelltests.py
+++ b/testing/xpcshell/remotexpcshelltests.py
@@ -420,60 +420,84 @@ class XPCShellRemote(xpcshell.XPCShellTe
 
         if self.options.localAPK:
             remoteFile = remoteJoin(self.remoteBinDir, os.path.basename(self.options.localAPK))
             self.device.pushFile(self.options.localAPK, remoteFile)
 
         self.pushLibs()
 
     def pushLibs(self):
+        if self.localBin is not None:
+            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
+        else:
+            szip = None
         pushed_libs_count = 0
         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 = remoteJoin(self.remoteBinDir, os.path.basename(info.filename))
                         self.localAPKContents.extract(info, dir)
-                        file = os.path.join(dir, info.filename)
+                        localFile = 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)
+                            try:
+                                out = subprocess.check_output([szip, '-d', localFile], stderr=subprocess.STDOUT)
+                            except CalledProcessError:
+                                print >> sys.stderr, "Error calling %s on %s.." % (szip, localFile)
+                                if out:
+                                    print >> sys.stderr, out
+                        self.device.pushFile(localFile, remoteFile)
                         pushed_libs_count += 1
             finally:
                 shutil.rmtree(dir)
             return pushed_libs_count
 
         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."
+                localFile = os.path.join(self.localLib, file)
                 remoteFile = remoteJoin(self.remoteBinDir, file)
-                self.device.pushFile(os.path.join(self.localLib, file), remoteFile)
+                if szip:
+                    try:
+                        out = subprocess.check_output([szip, '-d', localFile], stderr=subprocess.STDOUT)
+                    except CalledProcessError:
+                        print >> sys.stderr, "Error calling %s on %s.." % (szip, localFile)
+                        if out:
+                            print >> sys.stderr, out
+                self.device.pushFile(localFile, remoteFile)
                 pushed_libs_count += 1
 
         # 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
+                        localFile = os.path.join(root, file)
                         remoteFile = remoteJoin(self.remoteBinDir, file)
-                        self.device.pushFile(os.path.join(root, file), remoteFile)
+                        if szip:
+                            try:
+                                out = subprocess.check_output([szip, '-d', localFile], stderr=subprocess.STDOUT)
+                            except CalledProcessError:
+                                print >> sys.stderr, "Error calling %s on %s.." % (szip, localFile)
+                                if out:
+                                    print >> sys.stderr, out
+                        self.device.pushFile(localFile, remoteFile)
                         pushed_libs_count += 1
 
         return pushed_libs_count
 
     def setupModules(self):
         if self.testingModulesDir:
             self.device.pushDir(self.testingModulesDir, self.remoteModulesDir)