Skip to content

Commit

Permalink
android: Require exe unittests to have a foo_unittest_stripped target.
Browse files Browse the repository at this point in the history
This allows the test runner to not depend on the STRIP env var, which is going away.

Other approaches considered:
1. Converting the remaining exe-based tests to apk tests. The apk versions
   were slower, and didn't pass without other changes though.
2. Just don't strip. But that slows down these two tests by over 100%
   (due to copying data to the device is slow, and stripped size is 0.5MB while
   unstripped size is on the order of 10MB).
3. Try to get a trip binary from third_party/android_tools/ndk. That's fiddly
   since it requires getting the right arch.

Since there are only two exe-based tests left, just strip them from gyp.
Medium-term, maybe gyp/mac's postbuild stuff can be brought to android,
it looks like there are various things that could be made simpler with that.

BUG=142642
TEST=
build/android/test_runner.py gtest -s sandbox_linux_unittests &&
build/android/test_runner.py gtest -s breakpad_unittests

R=bulach@chromium.org, frankf@chromium.org
TBR=jln, thestig

Review URL: https://codereview.chromium.org/157743004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@250035 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
thakis@chromium.org committed Feb 10, 2014
1 parent e666228 commit 100df29
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 23 deletions.
15 changes: 15 additions & 0 deletions breakpad/breakpad.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -855,5 +855,20 @@
}
],
}],
['OS=="android"', {
'targets': [
{
'target_name': 'breakpad_unittests_stripped',
'type': 'none',
'dependencies': [ 'breakpad_unittests' ],
'actions': [{
'action_name': 'strip breakpad_unittests',
'inputs': [ '<(PRODUCT_DIR)/breakpad_unittests' ],
'outputs': [ '<(PRODUCT_DIR)/breakpad_unittests_stripped' ],
'action': [ '<(android_strip)', '<@(_inputs)', '-o', '<@(_outputs)' ],
}],
}
],
}],
],
}
4 changes: 2 additions & 2 deletions build/all.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@
'../android_webview/android_webview.gyp:android_webview_unittests',
'../base/android/jni_generator/jni_generator.gyp:jni_generator_tests',
'../base/base.gyp:base_unittests',
'../breakpad/breakpad.gyp:breakpad_unittests',
'../breakpad/breakpad.gyp:breakpad_unittests_stripped',
# Also compile the tools needed to deal with minidumps, they are
# needed to run minidump tests upstream.
'../breakpad/breakpad.gyp:dump_syms#host',
Expand All @@ -742,7 +742,7 @@
'../media/media.gyp:media_perftests_apk',
'../media/media.gyp:media_unittests',
'../net/net.gyp:net_unittests',
'../sandbox/sandbox.gyp:sandbox_linux_unittests',
'../sandbox/sandbox.gyp:sandbox_linux_unittests_stripped',
'../sql/sql.gyp:sql_unittests',
'../sync/sync.gyp:sync_unit_tests',
'../third_party/WebKit/public/all.gyp:*',
Expand Down
37 changes: 16 additions & 21 deletions build/android/pylib/gtest/test_package_exe.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,26 +122,21 @@ def Install(self, adb):
if self.tool.NeedsDebugInfo():
target_name = self.suite_path
else:
target_name = self.suite_path + '_' + adb.GetDevice() + '_stripped'
should_strip = True
if os.path.isfile(target_name):
logging.info('Found target file %s' % target_name)
target_mtime = os.stat(target_name).st_mtime
source_mtime = os.stat(self.suite_path).st_mtime
if target_mtime > source_mtime:
logging.info('Target mtime (%d) is newer than source (%d), assuming '
'no change.' % (target_mtime, source_mtime))
should_strip = False

if should_strip:
logging.info('Did not find up-to-date stripped binary. Generating a '
'new one (%s).' % target_name)
# Whenever we generate a stripped binary, copy to the symbols dir. If we
# aren't stripping a new binary, assume it's there.
if not os.path.exists(self._symbols_dir):
os.makedirs(self._symbols_dir)
shutil.copy(self.suite_path, self._symbols_dir)
strip = os.environ['STRIP']
cmd_helper.RunCmd([strip, self.suite_path, '-o', target_name])
target_name = self.suite_path + '_stripped'
if not os.path.isfile(target_name):
logging.critical('Did not find %s, build target %s',
target_name, self.suite_name + '_stripped')
sys.exit(1)

target_mtime = os.stat(target_name).st_mtime
source_mtime = os.stat(self.suite_path).st_mtime
if target_mtime < source_mtime:
logging.critical(
'stripped binary (%s, timestamp %d) older than '
'source binary (%s, timestamp %d), build target %s',
target_name, target_mtime, self.suite_path, source_mtime,
self.suite_name + '_stripped')
sys.exit(1)

test_binary = constants.TEST_EXECUTABLE_DIR + '/' + self.suite_name
adb.PushIfNeeded(target_name, test_binary)
15 changes: 15 additions & 0 deletions sandbox/linux/sandbox_linux.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,21 @@
},
],
'conditions': [
[ 'OS=="android"', {
'targets': [
{
'target_name': 'sandbox_linux_unittests_stripped',
'type': 'none',
'dependencies': [ 'sandbox_linux_unittests' ],
'actions': [{
'action_name': 'strip sandbox_linux_unittests',
'inputs': [ '<(PRODUCT_DIR)/sandbox_linux_unittests' ],
'outputs': [ '<(PRODUCT_DIR)/sandbox_linux_unittests_stripped' ],
'action': [ '<(android_strip)', '<@(_inputs)', '-o', '<@(_outputs)' ],
}],
}
],
}],
# Strategy copied from base_unittests_apk in base/base.gyp.
[ 'OS=="android" and gtest_target_type == "shared_library"', {
'targets': [
Expand Down

0 comments on commit 100df29

Please sign in to comment.