From 77a71f85c13f24b0adece4219800e4c0620c8e1f Mon Sep 17 00:00:00 2001 From: Michael Achenbach Date: Wed, 28 Mar 2018 10:57:12 +0000 Subject: [PATCH] Revert "[build] Remove legacy isolate configurations" This reverts commit 712b66da8168c36d350f2f7401f11440c8495830. Reason for revert: https://build.chromium.org/p/client.v8/builders/V8%20Linux64%20-%20builder/builds/32049 Original change's description: > [build] Remove legacy isolate configurations > > Bug: chromium:669910 > Cq-Include-Trybots: luci.v8.try:v8_linux_noi18n_rel_ng > Change-Id: Iad58563fd4bb35501493f88af83362b1206a186c > Reviewed-on: https://chromium-review.googlesource.com/982630 > Reviewed-by: Sergiy Byelozyorov > Commit-Queue: Michael Achenbach > Cr-Commit-Position: refs/heads/master@{#52267} TBR=machenbach@chromium.org,yangguo@chromium.org,sergiyb@chromium.org,jgruber@chromium.org Change-Id: I1955325b0b419b38d793ab205131de8de08cb50a No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: chromium:669910 Cq-Include-Trybots: luci.v8.try:v8_linux_noi18n_rel_ng Reviewed-on: https://chromium-review.googlesource.com/983418 Reviewed-by: Michael Achenbach Commit-Queue: Michael Achenbach Cr-Commit-Position: refs/heads/master@{#52268} --- BUILD.gn | 20 ++ gni/isolate.gni | 203 +++++++++++ gni/msvs_dependencies.isolate | 97 ++++++ src/base.isolate | 46 +++ src/d8.isolate | 16 + test/BUILD.gn | 211 ++++++++++++ test/benchmarks/benchmarks.isolate | 14 + test/bot_default.isolate | 24 ++ test/cctest/cctest.isolate | 16 + test/cctest/cctest_exe.isolate | 13 + test/d8_default.isolate | 18 + test/debugger/debugger.isolate | 15 + test/default.isolate | 23 ++ test/fuzzer/fuzzer.isolate | 48 +++ test/inspector/inspector.isolate | 27 ++ test/intl/intl.isolate | 14 + test/message/message.isolate | 14 + test/mjsunit/mjsunit.isolate | 28 ++ test/mkgrokdump/mkgrokdump.isolate | 17 + test/mozilla/mozilla.isolate | 14 + test/optimize_for_size.isolate | 18 + test/perf.isolate | 27 ++ test/preparser/preparser.isolate | 14 + test/test262/BUILD.gn | 31 ++ test/test262/archive.py | 38 +++ test/test262/list.py | 26 ++ test/test262/test262.isolate | 20 ++ test/unittests/unittests.isolate | 16 + test/wasm-spec-tests/wasm-spec-tests.isolate | 15 + test/webkit/webkit.isolate | 14 + tools/BUILD.gn | 43 +++ tools/check-static-initializers.isolate | 16 + tools/gcmole/run-gcmole.isolate | 36 ++ tools/isolate_driver.py | 340 +++++++++++++++++++ tools/jsfunfuzz/jsfunfuzz.isolate | 18 + tools/run-num-fuzzer.isolate | 20 ++ tools/testrunner/testrunner.isolate | 25 ++ 37 files changed, 1595 insertions(+) create mode 100644 gni/isolate.gni create mode 100644 gni/msvs_dependencies.isolate create mode 100644 src/base.isolate create mode 100644 src/d8.isolate create mode 100644 test/benchmarks/benchmarks.isolate create mode 100644 test/bot_default.isolate create mode 100644 test/cctest/cctest.isolate create mode 100644 test/cctest/cctest_exe.isolate create mode 100644 test/d8_default.isolate create mode 100644 test/debugger/debugger.isolate create mode 100644 test/default.isolate create mode 100644 test/fuzzer/fuzzer.isolate create mode 100644 test/inspector/inspector.isolate create mode 100644 test/intl/intl.isolate create mode 100644 test/message/message.isolate create mode 100644 test/mjsunit/mjsunit.isolate create mode 100644 test/mkgrokdump/mkgrokdump.isolate create mode 100644 test/mozilla/mozilla.isolate create mode 100644 test/optimize_for_size.isolate create mode 100644 test/perf.isolate create mode 100644 test/preparser/preparser.isolate create mode 100755 test/test262/archive.py create mode 100755 test/test262/list.py create mode 100644 test/test262/test262.isolate create mode 100644 test/unittests/unittests.isolate create mode 100644 test/wasm-spec-tests/wasm-spec-tests.isolate create mode 100644 test/webkit/webkit.isolate create mode 100644 tools/check-static-initializers.isolate create mode 100644 tools/gcmole/run-gcmole.isolate create mode 100644 tools/isolate_driver.py create mode 100644 tools/jsfunfuzz/jsfunfuzz.isolate create mode 100644 tools/run-num-fuzzer.isolate create mode 100644 tools/testrunner/testrunner.isolate diff --git a/BUILD.gn b/BUILD.gn index ad003f194e..cb35b23730 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -17,6 +17,7 @@ if (is_android) { } import("gni/v8.gni") +import("gni/isolate.gni") import("snapshot_toolchain.gni") declare_args() { @@ -3004,6 +3005,10 @@ group("gn_all") { if (want_v8_shell) { deps += [ ":v8_shell" ] } + + if (v8_test_isolation_mode != "noop") { + deps += [ ":d8_run" ] + } } group("v8_clusterfuzz") { @@ -3021,6 +3026,13 @@ group("v8_clusterfuzz") { ":d8(//build/toolchain/linux:clang_x86_v8_arm)", ] } + + if (v8_test_isolation_mode != "noop") { + deps += [ + "test:d8_default_run", + "tools:run-num-fuzzer_run", + ] + } } group("v8_archive") { @@ -3155,6 +3167,14 @@ v8_executable("d8") { } } +v8_isolate_run("d8") { + deps = [ + ":d8", + ] + + isolate = "//src/d8.isolate" +} + v8_executable("v8_hello_world") { sources = [ "samples/hello-world.cc", diff --git a/gni/isolate.gni b/gni/isolate.gni new file mode 100644 index 0000000000..331b3de288 --- /dev/null +++ b/gni/isolate.gni @@ -0,0 +1,203 @@ +# Copyright 2016 the V8 project authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import("//build/config/sanitizers/sanitizers.gni") +import("//third_party/icu/config.gni") +import("v8.gni") + +declare_args() { + # Sets the test isolation mode (noop|prepare|check). + v8_test_isolation_mode = "noop" +} + +template("v8_isolate_run") { + forward_variables_from(invoker, + "*", + [ + "deps", + "isolate", + ]) + + # Remember target name as within the action scope the target name will be + # different. + name = target_name + + assert(defined(invoker.deps)) + assert(defined(invoker.isolate)) + + if (name != "" && v8_test_isolation_mode != "noop") { + action(name + "_run") { + testonly = true + + deps = invoker.deps + + script = "//tools/isolate_driver.py" + + sources = [ + invoker.isolate, + ] + + inputs = [ + # Files that are known to be involved in this step. + "//tools/swarming_client/isolate.py", + "//tools/swarming_client/run_isolated.py", + ] + + if (v8_test_isolation_mode == "prepare") { + outputs = [ + "$root_out_dir/$name.isolated.gen.json", + ] + } else if (v8_test_isolation_mode == "check") { + outputs = [ + "$root_out_dir/$name.isolated", + "$root_out_dir/$name.isolated.state", + ] + } + + # Translate gn to gyp variables. + if (v8_code_coverage) { + coverage = "1" + } else { + coverage = "0" + } + if (is_asan) { + asan = "1" + } else { + asan = "0" + } + if (is_msan) { + msan = "1" + } else { + msan = "0" + } + if (is_tsan) { + tsan = "1" + } else { + tsan = "0" + } + if (is_cfi) { + cfi_vptr = "1" + } else { + cfi_vptr = "0" + } + if (target_cpu == "x86") { + target_arch = "ia32" + } else { + target_arch = target_cpu + } + if (is_debug) { + configuration_name = "Debug" + } else { + configuration_name = "Release" + } + if (is_component_build) { + component = "shared_library" + } else { + component = "static_library" + } + if (icu_use_data_file) { + icu_use_data_file_flag = "1" + } else { + icu_use_data_file_flag = "0" + } + if (v8_use_external_startup_data) { + use_external_startup_data = "1" + } else { + use_external_startup_data = "0" + } + if (is_ubsan_vptr) { + ubsan_vptr = "1" + } else { + ubsan_vptr = "0" + } + if (v8_use_snapshot) { + use_snapshot = "true" + } else { + use_snapshot = "false" + } + if (v8_use_multi_snapshots) { + multi_snapshots = "1" + } else { + multi_snapshots = "0" + } + if (v8_has_valgrind) { + has_valgrind = "1" + } else { + has_valgrind = "0" + } + if (v8_gcmole) { + gcmole = "1" + } else { + gcmole = "0" + } + + # Note, all paths will be rebased in isolate_driver.py to be relative to + # the isolate file. + args = [ + v8_test_isolation_mode, + "--isolated", + rebase_path("$root_out_dir/$name.isolated", root_build_dir), + "--isolate", + rebase_path(invoker.isolate, root_build_dir), + + # Path variables are used to replace file paths when loading a .isolate + # file + "--path-variable", + "DEPTH", + rebase_path("//", root_build_dir), + "--path-variable", + "PRODUCT_DIR", + rebase_path(root_out_dir, root_build_dir), + + # TODO(machenbach): Set variables for remaining features. + "--config-variable", + "CONFIGURATION_NAME=$configuration_name", + "--config-variable", + "OS=$target_os", + "--config-variable", + "asan=$asan", + "--config-variable", + "cfi_vptr=$cfi_vptr", + "--config-variable", + "gcmole=$gcmole", + "--config-variable", + "has_valgrind=$has_valgrind", + "--config-variable", + "icu_use_data_file_flag=$icu_use_data_file_flag", + "--config-variable", + "msan=$msan", + "--config-variable", + "tsan=$tsan", + "--config-variable", + "coverage=$coverage", + "--config-variable", + "sanitizer_coverage=$sanitizer_coverage_flags", + "--config-variable", + "component=$component", + "--config-variable", + "target_arch=$target_arch", + "--config-variable", + "ubsan_vptr=$ubsan_vptr", + "--config-variable", + "v8_use_multi_snapshots=$multi_snapshots", + "--config-variable", + "v8_use_external_startup_data=$use_external_startup_data", + "--config-variable", + "v8_use_snapshot=$use_snapshot", + ] + + if (is_win) { + args += [ + "--config-variable", + "msvs_version=2017", + ] + } else { + args += [ + "--config-variable", + "msvs_version=0", + ] + } + } + } +} diff --git a/gni/msvs_dependencies.isolate b/gni/msvs_dependencies.isolate new file mode 100644 index 0000000000..2859126659 --- /dev/null +++ b/gni/msvs_dependencies.isolate @@ -0,0 +1,97 @@ +# Copyright 2016 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# TODO(machenbach): Remove this when crbug.com/669910 is resolved. +{ + 'conditions': [ + # Copy the VS runtime DLLs into the isolate so that they + # don't have to be preinstalled on the target machine. + # + # VS2013 runtimes + ['OS=="win" and msvs_version==2013 and component=="shared_library" and (CONFIGURATION_NAME=="Debug" or CONFIGURATION_NAME=="Debug_x64")', { + 'variables': { + 'files': [ + '<(PRODUCT_DIR)/msvcp120d.dll', + '<(PRODUCT_DIR)/msvcr120d.dll', + ], + }, + }], + ['OS=="win" and msvs_version==2013 and component=="shared_library" and (CONFIGURATION_NAME=="Release" or CONFIGURATION_NAME=="Release_x64")', { + 'variables': { + 'files': [ + '<(PRODUCT_DIR)/msvcp120.dll', + '<(PRODUCT_DIR)/msvcr120.dll', + ], + }, + }], + # VS2015/2017 runtimes + ['OS=="win" and (msvs_version==2015 or msvs_version==2017) and component=="shared_library" and (CONFIGURATION_NAME=="Debug" or CONFIGURATION_NAME=="Debug_x64")', { + 'variables': { + 'files': [ + '<(PRODUCT_DIR)/msvcp140d.dll', + '<(PRODUCT_DIR)/vccorlib140d.dll', + '<(PRODUCT_DIR)/vcruntime140d.dll', + '<(PRODUCT_DIR)/ucrtbased.dll', + ], + }, + }], + ['OS=="win" and (msvs_version==2015 or msvs_version==2017) and component=="shared_library" and (CONFIGURATION_NAME=="Release" or CONFIGURATION_NAME=="Release_x64")', { + 'variables': { + 'files': [ + '<(PRODUCT_DIR)/msvcp140.dll', + '<(PRODUCT_DIR)/vccorlib140.dll', + '<(PRODUCT_DIR)/vcruntime140.dll', + '<(PRODUCT_DIR)/ucrtbase.dll', + ], + }, + }], + ['OS=="win" and (msvs_version==2015 or msvs_version==2017) and component=="shared_library"', { + # Windows 10 Universal C Runtime binaries. + 'variables': { + 'files': [ + '<(PRODUCT_DIR)/api-ms-win-core-console-l1-1-0.dll', + '<(PRODUCT_DIR)/api-ms-win-core-datetime-l1-1-0.dll', + '<(PRODUCT_DIR)/api-ms-win-core-debug-l1-1-0.dll', + '<(PRODUCT_DIR)/api-ms-win-core-errorhandling-l1-1-0.dll', + '<(PRODUCT_DIR)/api-ms-win-core-file-l1-1-0.dll', + '<(PRODUCT_DIR)/api-ms-win-core-file-l1-2-0.dll', + '<(PRODUCT_DIR)/api-ms-win-core-file-l2-1-0.dll', + '<(PRODUCT_DIR)/api-ms-win-core-handle-l1-1-0.dll', + '<(PRODUCT_DIR)/api-ms-win-core-heap-l1-1-0.dll', + '<(PRODUCT_DIR)/api-ms-win-core-interlocked-l1-1-0.dll', + '<(PRODUCT_DIR)/api-ms-win-core-libraryloader-l1-1-0.dll', + '<(PRODUCT_DIR)/api-ms-win-core-localization-l1-2-0.dll', + '<(PRODUCT_DIR)/api-ms-win-core-memory-l1-1-0.dll', + '<(PRODUCT_DIR)/api-ms-win-core-namedpipe-l1-1-0.dll', + '<(PRODUCT_DIR)/api-ms-win-core-processenvironment-l1-1-0.dll', + '<(PRODUCT_DIR)/api-ms-win-core-processthreads-l1-1-0.dll', + '<(PRODUCT_DIR)/api-ms-win-core-processthreads-l1-1-1.dll', + '<(PRODUCT_DIR)/api-ms-win-core-profile-l1-1-0.dll', + '<(PRODUCT_DIR)/api-ms-win-core-rtlsupport-l1-1-0.dll', + '<(PRODUCT_DIR)/api-ms-win-core-string-l1-1-0.dll', + '<(PRODUCT_DIR)/api-ms-win-core-synch-l1-1-0.dll', + '<(PRODUCT_DIR)/api-ms-win-core-synch-l1-2-0.dll', + '<(PRODUCT_DIR)/api-ms-win-core-sysinfo-l1-1-0.dll', + '<(PRODUCT_DIR)/api-ms-win-core-timezone-l1-1-0.dll', + '<(PRODUCT_DIR)/api-ms-win-core-util-l1-1-0.dll', + '<(PRODUCT_DIR)/api-ms-win-crt-conio-l1-1-0.dll', + '<(PRODUCT_DIR)/api-ms-win-crt-convert-l1-1-0.dll', + '<(PRODUCT_DIR)/api-ms-win-crt-environment-l1-1-0.dll', + '<(PRODUCT_DIR)/api-ms-win-crt-filesystem-l1-1-0.dll', + '<(PRODUCT_DIR)/api-ms-win-crt-heap-l1-1-0.dll', + '<(PRODUCT_DIR)/api-ms-win-crt-locale-l1-1-0.dll', + '<(PRODUCT_DIR)/api-ms-win-crt-math-l1-1-0.dll', + '<(PRODUCT_DIR)/api-ms-win-crt-multibyte-l1-1-0.dll', + '<(PRODUCT_DIR)/api-ms-win-crt-private-l1-1-0.dll', + '<(PRODUCT_DIR)/api-ms-win-crt-process-l1-1-0.dll', + '<(PRODUCT_DIR)/api-ms-win-crt-runtime-l1-1-0.dll', + '<(PRODUCT_DIR)/api-ms-win-crt-stdio-l1-1-0.dll', + '<(PRODUCT_DIR)/api-ms-win-crt-string-l1-1-0.dll', + '<(PRODUCT_DIR)/api-ms-win-crt-time-l1-1-0.dll', + '<(PRODUCT_DIR)/api-ms-win-crt-utility-l1-1-0.dll', + ], + }, + }], + ], +} diff --git a/src/base.isolate b/src/base.isolate new file mode 100644 index 0000000000..fb79709c6b --- /dev/null +++ b/src/base.isolate @@ -0,0 +1,46 @@ +# Copyright 2015 the V8 project authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +{ + 'includes': [ + '../third_party/icu/icu.isolate', + + # MSVS runtime libraries. + '../gni/msvs_dependencies.isolate', + ], + 'conditions': [ + ['v8_use_snapshot=="true" and v8_use_external_startup_data==1', { + 'variables': { + 'files': [ + '<(PRODUCT_DIR)/natives_blob.bin', + '<(PRODUCT_DIR)/snapshot_blob.bin', + ], + }, + }], + ['v8_use_snapshot=="true" and v8_use_external_startup_data==1 and v8_use_multi_snapshots==1', { + 'variables': { + 'files': [ + '<(PRODUCT_DIR)/snapshot_blob_trusted.bin', + ], + }, + }], + ['tsan==1', { + 'variables': { + 'files': [ + '../tools/sanitizers/tsan_suppressions.txt', + ], + }, + }], + ['asan==1 or cfi_vptr==1 or msan==1 or tsan==1 or ubsan_vptr==1', { + 'variables': { + 'files': [ + '../third_party/llvm-build/Release+Asserts/bin/llvm-symbolizer<(EXECUTABLE_SUFFIX)', + ], + }, + }], + # Workaround for https://code.google.com/p/swarming/issues/detail?id=211 + ['asan==0 or cfi_vptr==0 or msan==0 or tsan==0 or ubsan_vptr==0 ', { + 'variables': {}, + }], + ], +} diff --git a/src/d8.isolate b/src/d8.isolate new file mode 100644 index 0000000000..1c9bd9e35c --- /dev/null +++ b/src/d8.isolate @@ -0,0 +1,16 @@ +# Copyright 2015 the V8 project authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +{ + 'variables': { + 'command': [ + '<(PRODUCT_DIR)/d8<(EXECUTABLE_SUFFIX)', + ], + 'files': [ + '<(PRODUCT_DIR)/d8<(EXECUTABLE_SUFFIX)', + ], + }, + 'includes': [ + 'base.isolate', + ], +} \ No newline at end of file diff --git a/test/BUILD.gn b/test/BUILD.gn index c15413675e..45e1d64327 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -2,6 +2,7 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +import("../gni/isolate.gni") import("../gni/v8.gni") group("gn_all") { @@ -21,6 +22,7 @@ group("gn_all") { ] deps = [ + ":default_tests", "inspector:inspector-test", "mkgrokdump:mkgrokdump", ] @@ -33,6 +35,17 @@ group("gn_all") { "unittests:unittests", ] } + + if (v8_test_isolation_mode != "noop") { + deps += [ + ":benchmarks_run", + ":bot_default_run", + ":default_run", + ":d8_default_run", + ":mozilla_run", + "test262:test262_run", + ] + } } ############################################################################### @@ -134,3 +147,201 @@ group("v8_run_num_fuzzer") { "webkit:v8_webkit", ] } + +group("default_tests") { + testonly = true + + if (v8_test_isolation_mode != "noop") { + deps = [ + ":cctest_run", + ":debugger_run", + ":fuzzer_run", + ":inspector-test_run", + ":intl_run", + ":message_run", + ":mjsunit_run", + ":mkgrokdump_run", + ":preparser_run", + ":unittests_run", + ":wasm_spec_tests_run", + ] + } +} + +v8_isolate_run("bot_default") { + deps = [ + ":default_tests", + ":webkit_run", + ] + + isolate = "bot_default.isolate" +} + +v8_isolate_run("default") { + deps = [ + ":default_tests", + ] + + isolate = "default.isolate" +} + +v8_isolate_run("d8_default") { + deps = [ + ":debugger_run", + ":intl_run", + ":message_run", + ":mjsunit_run", + ":preparser_run", + ":webkit_run", + ] + + isolate = "d8_default.isolate" +} + +v8_isolate_run("optimize_for_size") { + deps = [ + ":cctest_run", + ":inspector-test_run", + ":intl_run", + ":mjsunit_run", + ":webkit_run", + ] + + isolate = "optimize_for_size.isolate" +} + +v8_isolate_run("perf") { + deps = [ + ":cctest_exe_run", + "..:d8_run", + ] + + isolate = "perf.isolate" +} + +############################################################################### +# Subtests +# + +v8_isolate_run("benchmarks") { + deps = [ + "..:d8_run", + ] + + isolate = "benchmarks/benchmarks.isolate" +} + +v8_isolate_run("cctest") { + deps = [ + ":cctest_exe_run", + ] + + isolate = "cctest/cctest.isolate" +} + +v8_isolate_run("cctest_exe") { + deps = [ + "cctest:cctest", + ] + + isolate = "cctest/cctest_exe.isolate" +} + +v8_isolate_run("debugger") { + deps = [ + "..:d8_run", + ] + + isolate = "debugger/debugger.isolate" +} + +v8_isolate_run("fuzzer") { + deps = [ + "..:v8_simple_json_fuzzer", + "..:v8_simple_parser_fuzzer", + "..:v8_simple_regexp_fuzzer", + "..:v8_simple_wasm_fuzzer", + ] + + isolate = "fuzzer/fuzzer.isolate" +} + +v8_isolate_run("inspector-test") { + deps = [ + "inspector:inspector-test", + ] + + isolate = "inspector/inspector.isolate" +} + +v8_isolate_run("intl") { + deps = [ + "..:d8_run", + ] + + isolate = "intl/intl.isolate" +} + +v8_isolate_run("message") { + deps = [ + "..:d8_run", + ] + + isolate = "message/message.isolate" +} + +v8_isolate_run("mjsunit") { + deps = [ + "..:d8_run", + ] + + isolate = "mjsunit/mjsunit.isolate" +} + +v8_isolate_run("mkgrokdump") { + deps = [ + "mkgrokdump:mkgrokdump", + ] + + isolate = "mkgrokdump/mkgrokdump.isolate" +} + +v8_isolate_run("mozilla") { + deps = [ + "..:d8_run", + ] + + isolate = "mozilla/mozilla.isolate" +} + +v8_isolate_run("preparser") { + deps = [ + "..:d8_run", + ] + + isolate = "preparser/preparser.isolate" +} + +v8_isolate_run("unittests") { + deps = [ + "unittests:unittests", + ] + + isolate = "unittests/unittests.isolate" +} + +v8_isolate_run("wasm_spec_tests") { + deps = [ + "..:d8_run", + ] + + isolate = "wasm-spec-tests/wasm-spec-tests.isolate" +} + +v8_isolate_run("webkit") { + deps = [ + "..:d8_run", + ] + + isolate = "webkit/webkit.isolate" +} diff --git a/test/benchmarks/benchmarks.isolate b/test/benchmarks/benchmarks.isolate new file mode 100644 index 0000000000..dbeca5e55c --- /dev/null +++ b/test/benchmarks/benchmarks.isolate @@ -0,0 +1,14 @@ +# Copyright 2015 the V8 project authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +{ + 'variables': { + 'files': [ + './', + ], + }, + 'includes': [ + '../../src/d8.isolate', + '../../tools/testrunner/testrunner.isolate', + ], +} \ No newline at end of file diff --git a/test/bot_default.isolate b/test/bot_default.isolate new file mode 100644 index 0000000000..c4db291cc0 --- /dev/null +++ b/test/bot_default.isolate @@ -0,0 +1,24 @@ +# Copyright 2015 the V8 project authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +{ + 'variables': { + 'command': [ + '../tools/run-tests.py', + ], + }, + 'includes': [ + 'cctest/cctest.isolate', + 'debugger/debugger.isolate', + 'fuzzer/fuzzer.isolate', + 'inspector/inspector.isolate', + 'intl/intl.isolate', + 'message/message.isolate', + 'mjsunit/mjsunit.isolate', + 'mkgrokdump/mkgrokdump.isolate', + 'preparser/preparser.isolate', + 'unittests/unittests.isolate', + 'wasm-spec-tests/wasm-spec-tests.isolate', + 'webkit/webkit.isolate', + ], +} diff --git a/test/cctest/cctest.isolate b/test/cctest/cctest.isolate new file mode 100644 index 0000000000..dd03ab8384 --- /dev/null +++ b/test/cctest/cctest.isolate @@ -0,0 +1,16 @@ +# Copyright 2015 the V8 project authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +{ + 'variables': { + 'files': [ + './cctest.status', + './testcfg.py', + './interpreter/bytecode_expectations/', + ], + }, + 'includes': [ + 'cctest_exe.isolate', + '../../tools/testrunner/testrunner.isolate', + ], +} diff --git a/test/cctest/cctest_exe.isolate b/test/cctest/cctest_exe.isolate new file mode 100644 index 0000000000..da5327846e --- /dev/null +++ b/test/cctest/cctest_exe.isolate @@ -0,0 +1,13 @@ +# Copyright 2016 the V8 project authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +{ + 'variables': { + 'files': [ + '<(PRODUCT_DIR)/cctest<(EXECUTABLE_SUFFIX)', + ], + }, + 'includes': [ + '../../src/base.isolate', + ], +} diff --git a/test/d8_default.isolate b/test/d8_default.isolate new file mode 100644 index 0000000000..efeae64cae --- /dev/null +++ b/test/d8_default.isolate @@ -0,0 +1,18 @@ +# Copyright 2018 the V8 project authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +{ + 'variables': { + 'command': [ + '../tools/run-tests.py', + ], + }, + 'includes': [ + 'debugger/debugger.isolate', + 'intl/intl.isolate', + 'message/message.isolate', + 'mjsunit/mjsunit.isolate', + 'preparser/preparser.isolate', + 'webkit/webkit.isolate', + ], +} diff --git a/test/debugger/debugger.isolate b/test/debugger/debugger.isolate new file mode 100644 index 0000000000..3843c73b2c --- /dev/null +++ b/test/debugger/debugger.isolate @@ -0,0 +1,15 @@ +# Copyright 2016 the V8 project authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +{ + 'variables': { + 'files': [ + './', + ], + }, + 'includes': [ + '../../src/d8.isolate', + '../../tools/testrunner/testrunner.isolate', + ], +} diff --git a/test/default.isolate b/test/default.isolate new file mode 100644 index 0000000000..e9104631d6 --- /dev/null +++ b/test/default.isolate @@ -0,0 +1,23 @@ +# Copyright 2015 the V8 project authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +{ + 'variables': { + 'command': [ + '../tools/run-tests.py', + ], + }, + 'includes': [ + 'cctest/cctest.isolate', + 'debugger/debugger.isolate', + 'fuzzer/fuzzer.isolate', + 'inspector/inspector.isolate' + 'intl/intl.isolate', + 'message/message.isolate', + 'mjsunit/mjsunit.isolate', + 'mkgrokdump/mkgrokdump.isolate', + 'preparser/preparser.isolate', + 'unittests/unittests.isolate', + 'wasm-spec-tests/wasm-spec-tests.isolate', + ], +} diff --git a/test/fuzzer/fuzzer.isolate b/test/fuzzer/fuzzer.isolate new file mode 100644 index 0000000000..adaf1f9f11 --- /dev/null +++ b/test/fuzzer/fuzzer.isolate @@ -0,0 +1,48 @@ +# Copyright 2016 the V8 project authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +{ + 'variables': { + 'files': [ + '<(PRODUCT_DIR)/v8_simple_json_fuzzer<(EXECUTABLE_SUFFIX)', + '<(PRODUCT_DIR)/v8_simple_parser_fuzzer<(EXECUTABLE_SUFFIX)', + '<(PRODUCT_DIR)/v8_simple_regexp_builtins_fuzzer<(EXECUTABLE_SUFFIX)', + '<(PRODUCT_DIR)/v8_simple_regexp_fuzzer<(EXECUTABLE_SUFFIX)', + '<(PRODUCT_DIR)/v8_simple_multi_return_fuzzer<(EXECUTABLE_SUFFIX)', + '<(PRODUCT_DIR)/v8_simple_wasm_fuzzer<(EXECUTABLE_SUFFIX)', + '<(PRODUCT_DIR)/v8_simple_wasm_async_fuzzer<(EXECUTABLE_SUFFIX)', + '<(PRODUCT_DIR)/v8_simple_wasm_code_fuzzer<(EXECUTABLE_SUFFIX)', + '<(PRODUCT_DIR)/v8_simple_wasm_compile_fuzzer<(EXECUTABLE_SUFFIX)', + '<(PRODUCT_DIR)/v8_simple_wasm_data_section_fuzzer<(EXECUTABLE_SUFFIX)', + '<(PRODUCT_DIR)/v8_simple_wasm_function_sigs_section_fuzzer<(EXECUTABLE_SUFFIX)', + '<(PRODUCT_DIR)/v8_simple_wasm_globals_section_fuzzer<(EXECUTABLE_SUFFIX)', + '<(PRODUCT_DIR)/v8_simple_wasm_imports_section_fuzzer<(EXECUTABLE_SUFFIX)', + '<(PRODUCT_DIR)/v8_simple_wasm_memory_section_fuzzer<(EXECUTABLE_SUFFIX)', + '<(PRODUCT_DIR)/v8_simple_wasm_names_section_fuzzer<(EXECUTABLE_SUFFIX)', + '<(PRODUCT_DIR)/v8_simple_wasm_types_section_fuzzer<(EXECUTABLE_SUFFIX)', + './fuzzer.status', + './testcfg.py', + './json/', + './parser/', + './regexp/', + './regexp_builtins/', + './multi_return/', + './wasm/', + './wasm_async/', + './wasm_code/', + './wasm_compile/', + './wasm_data_section/', + './wasm_function_sigs_section/', + './wasm_globals_section/', + './wasm_imports_section/', + './wasm_memory_section/', + './wasm_names_section/', + './wasm_types_section/', + ], + }, + 'includes': [ + '../../src/base.isolate', + '../../tools/testrunner/testrunner.isolate', + ], +} diff --git a/test/inspector/inspector.isolate b/test/inspector/inspector.isolate new file mode 100644 index 0000000000..38a96c57c6 --- /dev/null +++ b/test/inspector/inspector.isolate @@ -0,0 +1,27 @@ +# Copyright 2016 the V8 project authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +{ + 'variables': { + 'files': [ + './console/', + './cpu-profiler/', + './debugger/', + './heap-profiler/', + './inspector.status', + './json-parse-expected.txt', + './json-parse.js', + './protocol-test.js', + './runtime/', + './sessions/', + './testcfg.py', + './type-profiler/', + '../../src/inspector/injected-script-source.js', + '<(PRODUCT_DIR)/inspector-test<(EXECUTABLE_SUFFIX)', + ], + }, + 'includes': [ + '../../src/base.isolate', + '../../tools/testrunner/testrunner.isolate', + ], +} diff --git a/test/intl/intl.isolate b/test/intl/intl.isolate new file mode 100644 index 0000000000..dbeca5e55c --- /dev/null +++ b/test/intl/intl.isolate @@ -0,0 +1,14 @@ +# Copyright 2015 the V8 project authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +{ + 'variables': { + 'files': [ + './', + ], + }, + 'includes': [ + '../../src/d8.isolate', + '../../tools/testrunner/testrunner.isolate', + ], +} \ No newline at end of file diff --git a/test/message/message.isolate b/test/message/message.isolate new file mode 100644 index 0000000000..dbeca5e55c --- /dev/null +++ b/test/message/message.isolate @@ -0,0 +1,14 @@ +# Copyright 2015 the V8 project authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +{ + 'variables': { + 'files': [ + './', + ], + }, + 'includes': [ + '../../src/d8.isolate', + '../../tools/testrunner/testrunner.isolate', + ], +} \ No newline at end of file diff --git a/test/mjsunit/mjsunit.isolate b/test/mjsunit/mjsunit.isolate new file mode 100644 index 0000000000..a7d151aee6 --- /dev/null +++ b/test/mjsunit/mjsunit.isolate @@ -0,0 +1,28 @@ +# Copyright 2015 the V8 project authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +{ + 'variables': { + 'files': [ + './', + '../../tools/codemap.js', + '../../tools/consarray.js', + '../../tools/csvparser.js', + '../../tools/logreader.js', + '../../tools/arguments.js', + '../../tools/profile.js', + '../../tools/profile_view.js', + '../../tools/profviz/composer.js', + '../../tools/splaytree.js', + '../../tools/tickprocessor.js', + '../../tools/dumpcpp.js', + '../wasm-js/test/harness/wasm-constants.js', + '../wasm-js/test/harness/wasm-module-builder.js', + '../wasm-js/test/js-api/jsapi.js', + ], + }, + 'includes': [ + '../../src/d8.isolate', + '../../tools/testrunner/testrunner.isolate', + ], +} diff --git a/test/mkgrokdump/mkgrokdump.isolate b/test/mkgrokdump/mkgrokdump.isolate new file mode 100644 index 0000000000..b2cbc32551 --- /dev/null +++ b/test/mkgrokdump/mkgrokdump.isolate @@ -0,0 +1,17 @@ +# Copyright 2017 the V8 project authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +{ + 'variables': { + 'files': [ + './mkgrokdump.status', + './testcfg.py', + '../../tools/v8heapconst.py', + '<(PRODUCT_DIR)/mkgrokdump<(EXECUTABLE_SUFFIX)', + ], + }, + 'includes': [ + '../../src/base.isolate', + '../../tools/testrunner/testrunner.isolate', + ], +} diff --git a/test/mozilla/mozilla.isolate b/test/mozilla/mozilla.isolate new file mode 100644 index 0000000000..dbeca5e55c --- /dev/null +++ b/test/mozilla/mozilla.isolate @@ -0,0 +1,14 @@ +# Copyright 2015 the V8 project authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +{ + 'variables': { + 'files': [ + './', + ], + }, + 'includes': [ + '../../src/d8.isolate', + '../../tools/testrunner/testrunner.isolate', + ], +} \ No newline at end of file diff --git a/test/optimize_for_size.isolate b/test/optimize_for_size.isolate new file mode 100644 index 0000000000..6f3313e868 --- /dev/null +++ b/test/optimize_for_size.isolate @@ -0,0 +1,18 @@ +# Copyright 2015 the V8 project authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +{ + 'variables': { + 'command': [ + '../tools/run-tests.py', + ], + }, + 'includes': [ + 'cctest/cctest.isolate', + 'debugger/debugger.isolate', + 'inspector/inspector.isolate', + 'intl/intl.isolate', + 'mjsunit/mjsunit.isolate', + 'webkit/webkit.isolate', + ], +} diff --git a/test/perf.isolate b/test/perf.isolate new file mode 100644 index 0000000000..132bcc54f0 --- /dev/null +++ b/test/perf.isolate @@ -0,0 +1,27 @@ +# Copyright 2016 the V8 project authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +{ + 'variables': { + 'command': [ + '../tools/run_perf.py', + ], + 'files': [ + '../tools/run_perf.py', + # TODO(machenbach): These files are referenced by the perf runner. + # They should be transformed into a proper python module. + '../tools/testrunner/local/command.py', + '../tools/testrunner/local/utils.py', + '../tools/testrunner/objects/output.py', + # This is often used to trigger performance bots. We include it in the + # isolate to not get these builds deduped. + '../tools/whitespace.txt', + 'js-perf-test/', + 'memory/', + ], + }, + 'includes': [ + 'cctest/cctest_exe.isolate', + '../src/d8.isolate', + ], +} diff --git a/test/preparser/preparser.isolate b/test/preparser/preparser.isolate new file mode 100644 index 0000000000..dbeca5e55c --- /dev/null +++ b/test/preparser/preparser.isolate @@ -0,0 +1,14 @@ +# Copyright 2015 the V8 project authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +{ + 'variables': { + 'files': [ + './', + ], + }, + 'includes': [ + '../../src/d8.isolate', + '../../tools/testrunner/testrunner.isolate', + ], +} \ No newline at end of file diff --git a/test/test262/BUILD.gn b/test/test262/BUILD.gn index 334511168d..7f1dcf1efa 100644 --- a/test/test262/BUILD.gn +++ b/test/test262/BUILD.gn @@ -2,6 +2,8 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +import("../../gni/isolate.gni") + group("v8_test262") { testonly = true @@ -20,4 +22,33 @@ group("v8_test262") { "testcfg.py", "local-tests/", ] +} + +if (v8_test_isolation_mode != "noop") { + action("archive_test262") { + visibility = [ ":*" ] + + script = "archive.py" + + inputs = [ + "list.py", + ] + + sources = exec_script("list.py", [], "list lines") + + outputs = [ + "$target_gen_dir/test262_archiving.stamp", + ] + + args = rebase_path(outputs, root_build_dir) + } +} + +v8_isolate_run("test262") { + deps = [ + ":archive_test262", + "../..:d8_run", + ] + + isolate = "test262.isolate" } \ No newline at end of file diff --git a/test/test262/archive.py b/test/test262/archive.py new file mode 100755 index 0000000000..894853e208 --- /dev/null +++ b/test/test262/archive.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python +# Copyright 2016 the V8 project authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import os +import sys +import tarfile +import time + +# In GN we expect the path to a stamp file as an argument. +if len(sys.argv) == 2: + STAMP_FILE = os.path.abspath(sys.argv[1]) + +os.chdir(os.path.dirname(os.path.abspath(__file__))) + +# Workaround for slow grp and pwd calls. +tarfile.grp = None +tarfile.pwd = None + +def filter_git(tar_info): + if tar_info.name.startswith(os.path.join('data', '.git')) or \ + tar_info.name.startswith(os.path.join('harness', '.git')): + return None + else: + tar_info.uname = tar_info.gname = "test262" + return tar_info + +with tarfile.open('data.tar', 'w') as tar: + tar.add('data', filter=filter_git) + tar.add('harness', filter=filter_git) + +# Workaround for GN. We can't specify the tarfile as output because it's +# not in the product directory. Therefore we track running of this script +# with an extra stamp file in the product directory. +if len(sys.argv) == 2: + with open(STAMP_FILE, 'w') as f: + f.write(str(time.time())) diff --git a/test/test262/list.py b/test/test262/list.py new file mode 100755 index 0000000000..e99be68cd7 --- /dev/null +++ b/test/test262/list.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python +# Copyright 2016 the V8 project authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import os +import sys +import tarfile +from itertools import chain + +os.chdir(os.path.dirname(os.path.abspath(__file__))) + +for root, dirs, files in chain(os.walk("data"), os.walk("harness")): + dirs[:] = [d for d in dirs if not d.endswith('.git')] + for name in files: + # These names are for gyp, which expects slashes on all platforms. + pathname = '/'.join(root.split(os.sep) + [name]) + # For gyp, quote the name in case it includes spaces + if len(sys.argv) > 1 and sys.argv[1] == '--quoted': + pathname = '"' + pathname + '"' + # Temporary hack until we upgrade to gn swarming: + # gyp doesn't handle files containing $ in the name very well, so we just + # exclude them from the 'sources' list and hope that other changes cause + # the archive to be rebuilt. + if '$' in pathname: continue + print(pathname) diff --git a/test/test262/test262.isolate b/test/test262/test262.isolate new file mode 100644 index 0000000000..7631438e41 --- /dev/null +++ b/test/test262/test262.isolate @@ -0,0 +1,20 @@ +# Copyright 2015 the V8 project authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +{ + 'variables': { + 'files': [ + 'data.tar', + 'detachArrayBuffer.js', + 'harness-adapt.js', + 'harness-agent.js', + 'test262.status', + 'testcfg.py', + 'local-tests/', + ], + }, + 'includes': [ + '../../src/d8.isolate', + '../../tools/testrunner/testrunner.isolate', + ], +} diff --git a/test/unittests/unittests.isolate b/test/unittests/unittests.isolate new file mode 100644 index 0000000000..ec3bae42d3 --- /dev/null +++ b/test/unittests/unittests.isolate @@ -0,0 +1,16 @@ +# Copyright 2015 the V8 project authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +{ + 'variables': { + 'files': [ + '<(PRODUCT_DIR)/unittests<(EXECUTABLE_SUFFIX)', + './testcfg.py', + './unittests.status', + ], + }, + 'includes': [ + '../../src/base.isolate', + '../../tools/testrunner/testrunner.isolate', + ], +} diff --git a/test/wasm-spec-tests/wasm-spec-tests.isolate b/test/wasm-spec-tests/wasm-spec-tests.isolate new file mode 100644 index 0000000000..4c29f9fed7 --- /dev/null +++ b/test/wasm-spec-tests/wasm-spec-tests.isolate @@ -0,0 +1,15 @@ +# Copyright 2017 the V8 project authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +{ + 'variables': { + 'files': [ + './', + ], + }, + 'includes': [ + '../../src/d8.isolate', + '../../tools/testrunner/testrunner.isolate', + ], +} + diff --git a/test/webkit/webkit.isolate b/test/webkit/webkit.isolate new file mode 100644 index 0000000000..dbeca5e55c --- /dev/null +++ b/test/webkit/webkit.isolate @@ -0,0 +1,14 @@ +# Copyright 2015 the V8 project authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +{ + 'variables': { + 'files': [ + './', + ], + }, + 'includes': [ + '../../src/d8.isolate', + '../../tools/testrunner/testrunner.isolate', + ], +} \ No newline at end of file diff --git a/tools/BUILD.gn b/tools/BUILD.gn index 29d7b273f0..7dd9e63c15 100644 --- a/tools/BUILD.gn +++ b/tools/BUILD.gn @@ -3,6 +3,7 @@ # found in the LICENSE file. import("//build/config/sanitizers/sanitizers.gni") +import("../gni/isolate.gni") import("../gni/v8.gni") group("gn_all") { @@ -13,6 +14,15 @@ group("gn_all") { "gcmole:v8_run_gcmole", "jsfunfuzz:v8_jsfunfuzz", ] + + if (v8_test_isolation_mode != "noop") { + deps = [ + ":check-static-initializers_run", + ":jsfunfuzz_run", + ":run-gcmole_run", + ":run-num-fuzzer_run", + ] + } } group("v8_check_static_initializers") { @@ -45,3 +55,36 @@ group("v8_testrunner") { ] } } + +v8_isolate_run("check-static-initializers") { + deps = [ + "..:d8_run", + ] + + isolate = "check-static-initializers.isolate" +} + +v8_isolate_run("jsfunfuzz") { + deps = [ + "..:d8_run", + ] + + isolate = "jsfunfuzz/jsfunfuzz.isolate" +} + +v8_isolate_run("run-gcmole") { + deps = [ + "..:d8_run", + ] + + isolate = "gcmole/run-gcmole.isolate" +} + +# TODO(machenbach): Add tests as dependencies. +v8_isolate_run("run-num-fuzzer") { + deps = [ + "..:d8_run", + ] + + isolate = "run-num-fuzzer.isolate" +} diff --git a/tools/check-static-initializers.isolate b/tools/check-static-initializers.isolate new file mode 100644 index 0000000000..d1197d3d6c --- /dev/null +++ b/tools/check-static-initializers.isolate @@ -0,0 +1,16 @@ +# Copyright 2016 the V8 project authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +{ + 'variables': { + 'command': [ + 'check-static-initializers.sh', + ], + 'files': [ + 'check-static-initializers.sh', + ], + }, + 'includes': [ + '../src/d8.isolate', + ], +} diff --git a/tools/gcmole/run-gcmole.isolate b/tools/gcmole/run-gcmole.isolate new file mode 100644 index 0000000000..27ebe5b695 --- /dev/null +++ b/tools/gcmole/run-gcmole.isolate @@ -0,0 +1,36 @@ +# Copyright 2016 the V8 project authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +{ + 'variables': { + 'command': [ + 'run-gcmole.py', + ], + 'files': [ + 'gccause.lua', + 'gcmole.lua', + 'parallel.py', + 'run-gcmole.py', + # The following contains all relevant source and gyp files. + '../../BUILD.gn', + '../../base/', + '../../include/', + '../../src/', + '../../test/cctest/', + '../../testing/gtest/include/gtest/gtest_prod.h', + '../../third_party/googletest/src/googletest/include/gtest/gtest_prod.h', + '../../third_party/icu/source/', + ], + }, + 'conditions': [ + ['gcmole==1', { + 'variables': { + 'files': [ + # This assumes gcmole tools have been fetched by a hook + # into v8/tools/gcmole/gcmole_tools. + 'gcmole-tools/', + ], + }, + }], + ], +} diff --git a/tools/isolate_driver.py b/tools/isolate_driver.py new file mode 100644 index 0000000000..32077e236f --- /dev/null +++ b/tools/isolate_driver.py @@ -0,0 +1,340 @@ +#!/usr/bin/env python +# Copyright 2015 the V8 project authors. All rights reserved. +# Copyright 2014 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +"""Adaptor script called through gni/isolate.gni. + +Creates a wrapping .isolate which 'includes' the original one, that can be +consumed by tools/swarming_client/isolate.py. Path variables are determined +based on the current working directory. The relative_cwd in the .isolated file +is determined based on the .isolate file that declare the 'command' variable to +be used so the wrapping .isolate doesn't affect this value. + +This script loads build.ninja and processes it to determine all the executables +referenced by the isolated target. It adds them in the wrapping .isolate file. + +WARNING: The target to use for build.ninja analysis is the base name of the +.isolate file plus '_run'. For example, 'foo_test.isolate' would have the target +'foo_test_run' analysed. +""" + +import errno +import glob +import json +import logging +import os +import posixpath +import StringIO +import subprocess +import sys +import time + +TOOLS_DIR = os.path.dirname(os.path.abspath(__file__)) +SWARMING_CLIENT_DIR = os.path.join(TOOLS_DIR, 'swarming_client') +SRC_DIR = os.path.dirname(TOOLS_DIR) + +sys.path.insert(0, SWARMING_CLIENT_DIR) + +import isolate_format + + +def load_ninja_recursively(build_dir, ninja_path, build_steps): + """Crudely extracts all the subninja and build referenced in ninja_path. + + In particular, it ignores rule and variable declarations. The goal is to be + performant (well, as much as python can be performant) which is currently in + the <200ms range for a complete chromium tree. As such the code is laid out + for performance instead of readability. + """ + logging.debug('Loading %s', ninja_path) + try: + with open(os.path.join(build_dir, ninja_path), 'rb') as f: + line = None + merge_line = '' + subninja = [] + for line in f: + line = line.rstrip() + if not line: + continue + + if line[-1] == '$': + # The next line needs to be merged in. + merge_line += line[:-1] + continue + + if merge_line: + line = merge_line + line + merge_line = '' + + statement = line[:line.find(' ')] + if statement == 'build': + # Save the dependency list as a raw string. Only the lines needed will + # be processed with raw_build_to_deps(). This saves a good 70ms of + # processing time. + build_target, dependencies = line[6:].split(': ', 1) + # Interestingly, trying to be smart and only saving the build steps + # with the intended extensions ('', '.stamp', '.so') slows down + # parsing even if 90% of the build rules can be skipped. + # On Windows, a single step may generate two target, so split items + # accordingly. It has only been seen for .exe/.exe.pdb combos. + for i in build_target.strip().split(): + build_steps[i] = dependencies + elif statement == 'subninja': + subninja.append(line[9:]) + except IOError: + print >> sys.stderr, 'Failed to open %s' % ninja_path + raise + + total = 1 + for rel_path in subninja: + try: + # Load each of the files referenced. + # TODO(maruel): Skip the files known to not be needed. It saves an aweful + # lot of processing time. + total += load_ninja_recursively(build_dir, rel_path, build_steps) + except IOError: + print >> sys.stderr, '... as referenced by %s' % ninja_path + raise + return total + + +def load_ninja(build_dir): + """Loads the tree of .ninja files in build_dir.""" + build_steps = {} + total = load_ninja_recursively(build_dir, 'build.ninja', build_steps) + logging.info('Loaded %d ninja files, %d build steps', total, len(build_steps)) + return build_steps + + +def using_blacklist(item): + """Returns True if an item should be analyzed. + + Ignores many rules that are assumed to not depend on a dynamic library. If + the assumption doesn't hold true anymore for a file format, remove it from + this list. This is simply an optimization. + """ + # *.json is ignored below, *.isolated.gen.json is an exception, it is produced + # by isolate_driver.py in 'test_isolation_mode==prepare'. + if item.endswith('.isolated.gen.json'): + return True + IGNORED = ( + '.a', '.cc', '.css', '.dat', '.def', '.frag', '.h', '.html', '.isolate', + '.js', '.json', '.manifest', '.o', '.obj', '.pak', '.png', '.pdb', '.py', + '.strings', '.test', '.txt', '.vert', + ) + # ninja files use native path format. + ext = os.path.splitext(item)[1] + if ext in IGNORED: + return False + # Special case Windows, keep .dll.lib but discard .lib. + if item.endswith('.dll.lib'): + return True + if ext == '.lib': + return False + return item not in ('', '|', '||') + + +def raw_build_to_deps(item): + """Converts a raw ninja build statement into the list of interesting + dependencies. + """ + # TODO(maruel): Use a whitelist instead? .stamp, .so.TOC, .dylib.TOC, + # .dll.lib, .exe and empty. + # The first item is the build rule, e.g. 'link', 'cxx', 'phony', etc. + return filter(using_blacklist, item.split(' ')[1:]) + + +def collect_deps(target, build_steps, dependencies_added, rules_seen): + """Recursively adds all the interesting dependencies for |target| + into |dependencies_added|. + """ + if rules_seen is None: + rules_seen = set() + if target in rules_seen: + # TODO(maruel): Figure out how it happens. + logging.warning('Circular dependency for %s!', target) + return + rules_seen.add(target) + try: + dependencies = raw_build_to_deps(build_steps[target]) + except KeyError: + logging.info('Failed to find a build step to generate: %s', target) + return + logging.debug('collect_deps(%s) -> %s', target, dependencies) + for dependency in dependencies: + dependencies_added.add(dependency) + collect_deps(dependency, build_steps, dependencies_added, rules_seen) + + +def post_process_deps(build_dir, dependencies): + """Processes the dependency list with OS specific rules.""" + def filter_item(i): + if i.endswith('.so.TOC'): + # Remove only the suffix .TOC, not the .so! + return i[:-4] + if i.endswith('.dylib.TOC'): + # Remove only the suffix .TOC, not the .dylib! + return i[:-4] + if i.endswith('.dll.lib'): + # Remove only the suffix .lib, not the .dll! + return i[:-4] + return i + + def is_exe(i): + # This script is only for adding new binaries that are created as part of + # the component build. + ext = os.path.splitext(i)[1] + # On POSIX, executables have no extension. + if ext not in ('', '.dll', '.dylib', '.exe', '.nexe', '.so'): + return False + if os.path.isabs(i): + # In some rare case, there's dependency set explicitly on files outside + # the checkout. + return False + + # Check for execute access and strip directories. This gets rid of all the + # phony rules. + p = os.path.join(build_dir, i) + return os.access(p, os.X_OK) and not os.path.isdir(p) + + return filter(is_exe, map(filter_item, dependencies)) + + +def create_wrapper(args, isolate_index, isolated_index): + """Creates a wrapper .isolate that add dynamic libs. + + The original .isolate is not modified. + """ + cwd = os.getcwd() + isolate = args[isolate_index] + # The code assumes the .isolate file is always specified path-less in cwd. Fix + # if this assumption doesn't hold true. + assert os.path.basename(isolate) == isolate, isolate + + # This will look like ../out/Debug. This is based against cwd. Note that this + # must equal the value provided as PRODUCT_DIR. + build_dir = os.path.dirname(args[isolated_index]) + + # This will look like chrome/unit_tests.isolate. It is based against SRC_DIR. + # It's used to calculate temp_isolate. + src_isolate = os.path.relpath(os.path.join(cwd, isolate), SRC_DIR) + + # The wrapping .isolate. This will look like + # ../out/Debug/gen/chrome/unit_tests.isolate. + temp_isolate = os.path.join(build_dir, 'gen', src_isolate) + temp_isolate_dir = os.path.dirname(temp_isolate) + + # Relative path between the new and old .isolate file. + isolate_relpath = os.path.relpath( + '.', temp_isolate_dir).replace(os.path.sep, '/') + + # It's a big assumption here that the name of the isolate file matches the + # primary target '_run'. Fix accordingly if this doesn't hold true, e.g. + # complain to maruel@. + target = isolate[:-len('.isolate')] + '_run' + build_steps = load_ninja(build_dir) + binary_deps = set() + collect_deps(target, build_steps, binary_deps, None) + binary_deps = post_process_deps(build_dir, binary_deps) + logging.debug( + 'Binary dependencies:%s', ''.join('\n ' + i for i in binary_deps)) + + # Now do actual wrapping .isolate. + isolate_dict = { + 'includes': [ + posixpath.join(isolate_relpath, isolate), + ], + 'variables': { + # Will look like ['<(PRODUCT_DIR)/lib/flibuser_prefs.so']. + 'files': sorted( + '<(PRODUCT_DIR)/%s' % i.replace(os.path.sep, '/') + for i in binary_deps), + }, + } + # Some .isolate files have the same temp directory and the build system may + # run this script in parallel so make directories safely here. + try: + os.makedirs(temp_isolate_dir) + except OSError as e: + if e.errno != errno.EEXIST: + raise + comment = ( + '# Warning: this file was AUTOGENERATED.\n' + '# DO NO EDIT.\n') + out = StringIO.StringIO() + isolate_format.print_all(comment, isolate_dict, out) + isolate_content = out.getvalue() + with open(temp_isolate, 'wb') as f: + f.write(isolate_content) + logging.info('Added %d dynamic libs', len(binary_deps)) + logging.debug('%s', isolate_content) + args[isolate_index] = temp_isolate + + +def prepare_isolate_call(args, output): + """Gathers all information required to run isolate.py later. + + Dumps it as JSON to |output| file. + """ + with open(output, 'wb') as f: + json.dump({ + 'args': args, + 'dir': os.getcwd(), + 'version': 1, + }, f, indent=2, sort_keys=True) + + +def rebase_directories(args, abs_base): + """Rebases all paths to be relative to abs_base.""" + def replace(index): + args[index] = os.path.relpath(os.path.abspath(args[index]), abs_base) + for i, arg in enumerate(args): + if arg in ['--isolate', '--isolated']: + replace(i + 1) + if arg == '--path-variable': + # Path variables have a triple form: --path-variable NAME . + replace(i + 2) + + +def main(): + logging.basicConfig(level=logging.ERROR, format='%(levelname)7s %(message)s') + args = sys.argv[1:] + mode = args[0] if args else None + isolate = None + isolated = None + for i, arg in enumerate(args): + if arg == '--isolate': + isolate = i + 1 + if arg == '--isolated': + isolated = i + 1 + if isolate is None or isolated is None or not mode: + print >> sys.stderr, 'Internal failure' + return 1 + + # Make sure all paths are relative to the isolate file. This is an + # expectation of the go binaries. In gn, this script is not called + # relative to the isolate file, but relative to the product dir. + new_base = os.path.abspath(os.path.dirname(args[isolate])) + rebase_directories(args, new_base) + assert args[isolate] == os.path.basename(args[isolate]) + os.chdir(new_base) + + create_wrapper(args, isolate, isolated) + + # In 'prepare' mode just collect all required information for postponed + # isolated.py invocation later, store it in *.isolated.gen.json file. + if mode == 'prepare': + prepare_isolate_call(args[1:], args[isolated] + '.gen.json') + return 0 + + swarming_client = os.path.join(SRC_DIR, 'tools', 'swarming_client') + sys.stdout.flush() + result = subprocess.call( + [sys.executable, os.path.join(swarming_client, 'isolate.py')] + args) + return result + + +if __name__ == '__main__': + sys.exit(main()) diff --git a/tools/jsfunfuzz/jsfunfuzz.isolate b/tools/jsfunfuzz/jsfunfuzz.isolate new file mode 100644 index 0000000000..56cb4a733f --- /dev/null +++ b/tools/jsfunfuzz/jsfunfuzz.isolate @@ -0,0 +1,18 @@ +# Copyright 2016 the V8 project authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +{ + 'variables': { + 'command': [ + 'fuzz-harness.sh', + ], + 'files': [ + # Grab current directory. This avoids adding logic for checking the + # existence of the jsfunfuzz subdirectory. + './', + ], + }, + 'includes': [ + '../../src/d8.isolate', + ], +} diff --git a/tools/run-num-fuzzer.isolate b/tools/run-num-fuzzer.isolate new file mode 100644 index 0000000000..e9acbd4cb0 --- /dev/null +++ b/tools/run-num-fuzzer.isolate @@ -0,0 +1,20 @@ +# Copyright 2017 the V8 project authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +{ + 'variables': { + 'command': [ + 'run-num-fuzzer.py', + ], + 'files': [ + 'run-num-fuzzer.py', + ], + }, + 'includes': [ + 'testrunner/testrunner.isolate', + '../src/d8.isolate', + '../test/benchmarks/benchmarks.isolate', + '../test/mjsunit/mjsunit.isolate', + '../test/webkit/webkit.isolate', + ], +} diff --git a/tools/testrunner/testrunner.isolate b/tools/testrunner/testrunner.isolate new file mode 100644 index 0000000000..56667c2021 --- /dev/null +++ b/tools/testrunner/testrunner.isolate @@ -0,0 +1,25 @@ +# Copyright 2015 the V8 project authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +{ + 'variables': { + 'command': [ + '../run-tests.py', + ], + 'files': [ + '<(PRODUCT_DIR)/v8_build_config.json', + '../run-tests.py', + './' + ], + }, + 'conditions': [ + ['coverage==1 and sanitizer_coverage=="bb,trace-pc-guard"', { + 'variables': { + 'files': [ + '../sanitizers/sancov_merger.py', + '../../third_party/llvm/projects/compiler-rt/lib/sanitizer_common/scripts/sancov.py', + ], + }, + }], + ], +}