This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
Add a run_tests flag that captures core dumps from engine unit tests and runs a GDB script #27742
Merged
fluttergithubbot
merged 1 commit into
flutter:master
from
jason-simmons:luci_core_capture
Jul 30, 2021
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Gather information from a core dump. | ||
| # | ||
| # This script can be invoked by the run_tests.py script after an | ||
| # engine test crashes. | ||
|
|
||
| BUILDROOT=$1 | ||
| EXE=$2 | ||
| CORE=$3 | ||
| OUTPUT=$4 | ||
|
|
||
| UNAME=$(uname) | ||
| if [ "$UNAME" == "Linux" ]; then | ||
| if [ -x "$(command -v gdb)" ]; then | ||
| GDB=gdb | ||
| else | ||
| GDB=$BUILDROOT/third_party/android_tools/ndk/prebuilt/linux-x86_64/bin/gdb | ||
| fi | ||
| echo "GDB=$GDB" | ||
| $GDB $EXE $CORE --batch -ex "thread apply all bt" > $OUTPUT | ||
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ | |
| import glob | ||
| import os | ||
| import re | ||
| import shutil | ||
| import subprocess | ||
| import sys | ||
| import time | ||
|
|
@@ -134,12 +135,33 @@ def RunEngineExecutable(build_dir, executable_name, filter, flags=[], | |
| else: | ||
| test_command = [ executable ] + flags | ||
|
|
||
| RunCmd(test_command, cwd=cwd, forbidden_output=forbidden_output, expect_failure=expect_failure, env=env) | ||
|
|
||
|
|
||
| def RunCCTests(build_dir, filter, coverage): | ||
| try: | ||
| RunCmd(test_command, cwd=cwd, forbidden_output=forbidden_output, expect_failure=expect_failure, env=env) | ||
| except: | ||
| # The LUCI environment may provide a variable containing a directory path | ||
| # for additional output files that will be uploaded to cloud storage. | ||
| # If the command generated a core dump, then run a script to analyze | ||
| # the dump and output a report that will be uploaded. | ||
| luci_test_outputs_path = os.environ.get('FLUTTER_TEST_OUTPUTS_DIR') | ||
| core_path = os.path.join(cwd, 'core') | ||
| if luci_test_outputs_path and os.path.exists(core_path) and os.path.exists(unstripped_exe): | ||
| dump_path = os.path.join(luci_test_outputs_path, '%s_%s.txt' % (executable_name, sys.platform)) | ||
| print 'Writing core dump analysis to %s' % dump_path | ||
| subprocess.call([ | ||
| os.path.join(buildroot_dir, 'flutter', 'testing', 'analyze_core_dump.sh'), | ||
| buildroot_dir, unstripped_exe, core_path, dump_path, | ||
| ]) | ||
| os.unlink(core_path) | ||
| raise | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: need two newlines between functions |
||
|
|
||
| def RunCCTests(build_dir, filter, coverage, capture_core_dump): | ||
| print("Running Engine Unit-tests.") | ||
|
|
||
| if capture_core_dump and IsLinux(): | ||
| import resource | ||
| resource.setrlimit(resource.RLIMIT_CORE, (resource.RLIM_INFINITY, resource.RLIM_INFINITY)) | ||
|
|
||
| # Not all of the engine unit tests are designed to be run more than once. | ||
| non_repeatable_shuffle_flags = [ | ||
| "--gtest_shuffle", | ||
|
|
@@ -523,6 +545,8 @@ def main(): | |
| help='Filter parameter for which objc tests to run (example: "IosUnitTestsTests/SemanticsObjectTest/testShouldTriggerAnnouncement")') | ||
| parser.add_argument('--coverage', action='store_true', default=None, | ||
| help='Generate coverage reports for each unit test framework run.') | ||
| parser.add_argument('--engine-capture-core-dump', dest='engine_capture_core_dump', action='store_true', | ||
| default=False, help='Capture core dumps from crashes of engine tests.') | ||
|
|
||
| args = parser.parse_args() | ||
|
|
||
|
|
@@ -537,7 +561,7 @@ def main(): | |
|
|
||
| engine_filter = args.engine_filter.split(',') if args.engine_filter else None | ||
| if 'engine' in types: | ||
| RunCCTests(build_dir, engine_filter, args.coverage) | ||
| RunCCTests(build_dir, engine_filter, args.coverage, args.engine_capture_core_dump) | ||
|
|
||
| if 'dart' in types: | ||
| assert not IsWindows(), "Dart tests can't be run on windows. https://github.com/flutter/flutter/issues/36301." | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: remove extra newline above.