Bug 1202102 - Apply szip to libs pushed for Android cppunit and xpcshell tests; r=dminor

This commit is contained in:
Geoff Brown 2015-09-09 07:12:58 -06:00
parent 4cf36cad13
commit 6725eb5919
2 changed files with 75 additions and 27 deletions

View File

@ -52,35 +52,50 @@ class RemoteCPPUnitTests(cppunittests.CPPUnitTests):
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)
@ -88,8 +103,17 @@ class RemoteCPPUnitTests(cppunittests.CPPUnitTests):
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:

View File

@ -425,27 +425,35 @@ class XPCShellRemote(xpcshell.XPCShellTests, object):
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)
@ -456,8 +464,16 @@ class XPCShellRemote(xpcshell.XPCShellTests, object):
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"
@ -467,8 +483,16 @@ class XPCShellRemote(xpcshell.XPCShellTests, object):
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