From 663678b9de0a1fc32e606b6d1c83a83f7f0f7012 Mon Sep 17 00:00:00 2001 From: Jason Simmons Date: Tue, 29 Jun 2021 07:31:02 -0700 Subject: [PATCH] Use unstripped executables when running tests on Linux (flutter/engine#26921) --- .../src/flutter/benchmarking/benchmarking.cc | 6 +++- engine/src/flutter/testing/run_tests.py | 33 +++++++++++++------ .../txt/benchmarks/txt_run_all_benchmarks.cc | 4 ++- .../txt/tests/txt_run_all_unittests.cc | 4 ++- 4 files changed, 34 insertions(+), 13 deletions(-) diff --git a/engine/src/flutter/benchmarking/benchmarking.cc b/engine/src/flutter/benchmarking/benchmarking.cc index 97b7f868e3..d364fc9687 100644 --- a/engine/src/flutter/benchmarking/benchmarking.cc +++ b/engine/src/flutter/benchmarking/benchmarking.cc @@ -5,14 +5,18 @@ #include "benchmarking.h" #include "flutter/fml/backtrace.h" +#include "flutter/fml/command_line.h" #include "flutter/fml/icu_util.h" namespace benchmarking { int Main(int argc, char** argv) { fml::InstallCrashHandler(); + fml::CommandLine cmd = fml::CommandLineFromArgcArgv(argc, argv); benchmark::Initialize(&argc, argv); - fml::icu::InitializeICU("icudtl.dat"); + std::string icudtl_path = + cmd.GetOptionValueWithDefault("icu-data-file-path", "icudtl.dat"); + fml::icu::InitializeICU(icudtl_path); ::benchmark::RunSpecifiedBenchmarks(); return 0; } diff --git a/engine/src/flutter/testing/run_tests.py b/engine/src/flutter/testing/run_tests.py index 5b3dd93334..fa41d30d4f 100755 --- a/engine/src/flutter/testing/run_tests.py +++ b/engine/src/flutter/testing/run_tests.py @@ -32,7 +32,7 @@ def PrintDivider(char='='): print '\n' -def RunCmd(cmd, forbidden_output=[], expect_failure=False, **kwargs): +def RunCmd(cmd, forbidden_output=[], expect_failure=False, env=None, **kwargs): command_string = ' '.join(cmd) PrintDivider('>') @@ -41,7 +41,7 @@ def RunCmd(cmd, forbidden_output=[], expect_failure=False, **kwargs): start_time = time.time() stdout_pipe = sys.stdout if not forbidden_output else subprocess.PIPE stderr_pipe = sys.stderr if not forbidden_output else subprocess.PIPE - process = subprocess.Popen(cmd, stdout=stdout_pipe, stderr=stderr_pipe, **kwargs) + process = subprocess.Popen(cmd, stdout=stdout_pipe, stderr=stderr_pipe, env=env, **kwargs) stdout, stderr = process.communicate() end_time = time.time() @@ -110,12 +110,21 @@ def RunEngineExecutable(build_dir, executable_name, filter, flags=[], print('Skipping %s due to filter.' % executable_name) return - executable = FindExecutablePath(os.path.join(build_dir, executable_name)) + unstripped_exe = os.path.join(build_dir, 'exe.unstripped', executable_name) + if IsLinux() and os.path.exists(unstripped_exe): + # Use unstripped executables in order to get better symbolized crash + # stack traces on Linux. + executable = unstripped_exe + # Some tests depend on the EGL/GLES libraries placed in the build directory. + env = {'LD_LIBRARY_PATH': os.path.join(build_dir, 'lib.unstripped')} + else: + executable = FindExecutablePath(os.path.join(build_dir, executable_name)) + env = None print('Running %s in %s' % (executable_name, cwd)) test_command = [ executable ] + flags print(' '.join(test_command)) - RunCmd(test_command, cwd=cwd, forbidden_output=forbidden_output, expect_failure=expect_failure) + RunCmd(test_command, cwd=cwd, forbidden_output=forbidden_output, expect_failure=expect_failure, env=env) def RunCCTests(build_dir, filter): @@ -185,7 +194,8 @@ def RunCCTests(build_dir, filter): # https://github.com/flutter/flutter/issues/36296 if IsLinux(): - RunEngineExecutable(build_dir, 'txt_unittests', filter, shuffle_flags) + icu_flags = ['--icu-data-file-path=%s' % os.path.join(build_dir, 'icudtl.dat')] + RunEngineExecutable(build_dir, 'txt_unittests', filter, icu_flags + shuffle_flags) if IsLinux(): RunEngineExecutable(build_dir, 'flutter_linux_unittests', filter, non_repeatable_shuffle_flags) @@ -195,14 +205,16 @@ def RunCCTests(build_dir, filter): def RunEngineBenchmarks(build_dir, filter): print("Running Engine Benchmarks.") - RunEngineExecutable(build_dir, 'shell_benchmarks', filter) + icu_flags = ['--icu-data-file-path=%s' % os.path.join(build_dir, 'icudtl.dat')] - RunEngineExecutable(build_dir, 'fml_benchmarks', filter) + RunEngineExecutable(build_dir, 'shell_benchmarks', filter, icu_flags) - RunEngineExecutable(build_dir, 'ui_benchmarks', filter) + RunEngineExecutable(build_dir, 'fml_benchmarks', filter, icu_flags) + + RunEngineExecutable(build_dir, 'ui_benchmarks', filter, icu_flags) if IsLinux(): - RunEngineExecutable(build_dir, 'txt_benchmarks', filter) + RunEngineExecutable(build_dir, 'txt_benchmarks', filter, icu_flags) def SnapshotTest(build_dir, test_packages, dart_file, kernel_file_output, verbose_dart_snapshot): @@ -266,7 +278,8 @@ def RunDartTest(build_dir, test_packages, dart_file, verbose_dart_snapshot, mult command_args += [ '--use-test-fonts', - kernel_file_output + '--icu-data-file-path=%s' % os.path.join(build_dir, 'icudtl.dat'), + kernel_file_output, ] if multithreaded: diff --git a/engine/src/flutter/third_party/txt/benchmarks/txt_run_all_benchmarks.cc b/engine/src/flutter/third_party/txt/benchmarks/txt_run_all_benchmarks.cc index 69da7b6a06..51f9a5902f 100644 --- a/engine/src/flutter/third_party/txt/benchmarks/txt_run_all_benchmarks.cc +++ b/engine/src/flutter/third_party/txt/benchmarks/txt_run_all_benchmarks.cc @@ -32,7 +32,9 @@ int main(int argc, char** argv) { } FML_DCHECK(txt::GetFontDir().length() > 0); - fml::icu::InitializeICU("icudtl.dat"); + std::string icudtl_path = + cmd.GetOptionValueWithDefault("icu-data-file-path", "icudtl.dat"); + fml::icu::InitializeICU(icudtl_path); ::benchmark::RunSpecifiedBenchmarks(); } diff --git a/engine/src/flutter/third_party/txt/tests/txt_run_all_unittests.cc b/engine/src/flutter/third_party/txt/tests/txt_run_all_unittests.cc index dceb19277c..0e791c3c67 100644 --- a/engine/src/flutter/third_party/txt/tests/txt_run_all_unittests.cc +++ b/engine/src/flutter/third_party/txt/tests/txt_run_all_unittests.cc @@ -37,7 +37,9 @@ int main(int argc, char** argv) { #if defined(OS_FUCHSIA) fml::icu::InitializeICU("/pkg/data/icudtl.dat"); #else - fml::icu::InitializeICU("icudtl.dat"); + std::string icudtl_path = + cmd.GetOptionValueWithDefault("icu-data-file-path", "icudtl.dat"); + fml::icu::InitializeICU(icudtl_path); #endif SkGraphics::Init(); testing::InitGoogleTest(&argc, argv);