Skip to content

Commit d724820

Browse files
mi-acCommit Bot
authored andcommitted
Merged: Squashed multiple commits.
Merged: [test] Make finding build directory more flexible Revision: 4f015e8 Merged: [test] Use the correct precedence for choosing the build directory Revision: 7b24b13 Merged: [test] Add fallback to legacy output directory Revision: bf3adea Merged: [gcmole] Fix gcmole after property change Revision: c87bdbc Merged: [test] Overhaul mode processing in test runner Revision: 608b732 Merged: [test] Switch to flattened json output Revision: 373a9a8 BUG=chromium:1132088,v8:10893 NOTRY=true NOTREECHECKS=true R=liviurau@chromium.org Change-Id: I3c1de04ca4fe62e36da29e706a20daec0b3d4d98 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2461745 Reviewed-by: Liviu Rau <liviurau@chromium.org> Commit-Queue: Michael Achenbach <machenbach@chromium.org> Cr-Commit-Position: refs/branch-heads/8.6@{#20} Cr-Branched-From: a64aed2-refs/heads/8.6.395@{#1} Cr-Branched-From: a626bc0-refs/heads/master@{#69472}
1 parent 18b0abf commit d724820

11 files changed

Lines changed: 152 additions & 203 deletions

File tree

tools/gcmole/gcmole.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ local function MakeClangCommandLine(
115115
.. " -DV8_INTL_SUPPORT"
116116
.. " -I./"
117117
.. " -Iinclude/"
118-
.. " -Iout/Release/gen"
118+
.. " -Iout/build/gen"
119119
.. " -Ithird_party/icu/source/common"
120120
.. " -Ithird_party/icu/source/i18n"
121121
.. " " .. arch_options

tools/gcmole/run-gcmole.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121

2222
assert len(sys.argv) == 2
2323

24-
if not os.path.isfile("out/Release/gen/torque-generated/builtin-definitions-tq.h"):
25-
print("Expected generated headers in out/Release/gen.")
26-
print("Either build v8 in out/Release or change gcmole.lua:115")
24+
if not os.path.isfile("out/build/gen/torque-generated/builtin-definitions-tq.h"):
25+
print("Expected generated headers in out/build/gen.")
26+
print("Either build v8 in out/build or change gcmole.lua:115")
2727
sys.exit(-1)
2828

2929
proc = subprocess.Popen(

tools/run_perf.py

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,32 @@ def FlattenRunnables(node, node_cb):
575575
raise Exception('Invalid suite configuration.')
576576

577577

578+
def find_build_directory(base_path, arch):
579+
"""Returns the location of d8 or node in the build output directory.
580+
581+
This supports a seamless transition between legacy build location
582+
(out/Release) and new build location (out/build).
583+
"""
584+
def is_build(path):
585+
# We support d8 or node as executables. We don't support testing on
586+
# Windows.
587+
return (os.path.isfile(os.path.join(path, 'd8')) or
588+
os.path.isfile(os.path.join(path, 'node')))
589+
possible_paths = [
590+
# Location developer wrapper scripts is using.
591+
'%s.release' % arch,
592+
# Current build location on bots.
593+
'build',
594+
# Legacy build location on bots.
595+
'Release',
596+
]
597+
possible_paths = [os.path.join(base_path, p) for p in possible_paths]
598+
actual_paths = filter(is_build, possible_paths)
599+
assert actual_paths, 'No build directory found.'
600+
assert len(actual_paths) == 1, 'Found ambiguous build directories.'
601+
return actual_paths[0]
602+
603+
578604
class Platform(object):
579605
def __init__(self, args):
580606
self.shell_dir = args.shell_dir
@@ -881,8 +907,7 @@ def Main(argv):
881907
'to auto-detect.', default='x64',
882908
choices=SUPPORTED_ARCHS + ['auto'])
883909
parser.add_argument('--buildbot',
884-
help='Adapt to path structure used on buildbots and adds '
885-
'timestamps/level to all logged status messages',
910+
help='Deprecated',
886911
default=False, action='store_true')
887912
parser.add_argument('-d', '--device',
888913
help='The device ID to run Android tests on. If not '
@@ -978,13 +1003,9 @@ def Main(argv):
9781003

9791004
workspace = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
9801005

981-
if args.buildbot:
982-
build_config = 'Release'
983-
else:
984-
build_config = '%s.release' % args.arch
985-
9861006
if args.binary_override_path == None:
987-
args.shell_dir = os.path.join(workspace, args.outdir, build_config)
1007+
args.shell_dir = find_build_directory(
1008+
os.path.join(workspace, args.outdir), args.arch)
9881009
default_binary_name = 'd8'
9891010
else:
9901011
if not os.path.isfile(args.binary_override_path):
@@ -998,8 +1019,8 @@ def Main(argv):
9981019
default_binary_name = os.path.basename(args.binary_override_path)
9991020

10001021
if args.outdir_secondary:
1001-
args.shell_dir_secondary = os.path.join(
1002-
workspace, args.outdir_secondary, build_config)
1022+
args.shell_dir_secondary = find_build_directory(
1023+
os.path.join(workspace, args.outdir_secondary), args.arch)
10031024
else:
10041025
args.shell_dir_secondary = None
10051026

tools/testrunner/base_runner.py

Lines changed: 57 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from __future__ import print_function
77
from functools import reduce
88

9-
from collections import OrderedDict
9+
from collections import OrderedDict, namedtuple
1010
import json
1111
import multiprocessing
1212
import optparse
@@ -116,52 +116,35 @@
116116
]
117117

118118

119-
class ModeConfig(object):
120-
def __init__(self, flags, timeout_scalefactor, status_mode, execution_mode):
121-
self.flags = flags
122-
self.timeout_scalefactor = timeout_scalefactor
123-
self.status_mode = status_mode
124-
self.execution_mode = execution_mode
125-
119+
ModeConfig = namedtuple(
120+
'ModeConfig', 'label flags timeout_scalefactor status_mode')
126121

127122
DEBUG_FLAGS = ["--nohard-abort", "--enable-slow-asserts", "--verify-heap"]
128123
RELEASE_FLAGS = ["--nohard-abort"]
129-
MODES = {
130-
"debug": ModeConfig(
131-
flags=DEBUG_FLAGS,
132-
timeout_scalefactor=4,
133-
status_mode="debug",
134-
execution_mode="debug",
135-
),
136-
"optdebug": ModeConfig(
124+
125+
DEBUG_MODE = ModeConfig(
126+
label='debug',
137127
flags=DEBUG_FLAGS,
138128
timeout_scalefactor=4,
139129
status_mode="debug",
140-
execution_mode="debug",
141-
),
142-
"release": ModeConfig(
130+
)
131+
132+
RELEASE_MODE = ModeConfig(
133+
label='release',
143134
flags=RELEASE_FLAGS,
144135
timeout_scalefactor=1,
145136
status_mode="release",
146-
execution_mode="release",
147-
),
148-
# Normal trybot release configuration. There, dchecks are always on which
149-
# implies debug is set. Hence, the status file needs to assume debug-like
150-
# behavior/timeouts.
151-
"tryrelease": ModeConfig(
137+
)
138+
139+
# Normal trybot release configuration. There, dchecks are always on which
140+
# implies debug is set. Hence, the status file needs to assume debug-like
141+
# behavior/timeouts.
142+
TRY_RELEASE_MODE = ModeConfig(
143+
label='release+dchecks',
152144
flags=RELEASE_FLAGS,
153-
timeout_scalefactor=1,
154-
status_mode="debug",
155-
execution_mode="release",
156-
),
157-
# This mode requires v8 to be compiled with dchecks and slow dchecks.
158-
"slowrelease": ModeConfig(
159-
flags=RELEASE_FLAGS + ["--enable-slow-asserts"],
160-
timeout_scalefactor=2,
145+
timeout_scalefactor=4,
161146
status_mode="debug",
162-
execution_mode="release",
163-
),
164-
}
147+
)
165148

166149
PROGRESS_INDICATORS = {
167150
'verbose': progress.VerboseProgressIndicator,
@@ -242,12 +225,29 @@ def __str__(self):
242225
return '\n'.join(detected_options)
243226

244227

228+
def _do_load_build_config(outdir, verbose=False):
229+
build_config_path = os.path.join(outdir, "v8_build_config.json")
230+
if not os.path.exists(build_config_path):
231+
if verbose:
232+
print("Didn't find build config: %s" % build_config_path)
233+
raise TestRunnerError()
234+
235+
with open(build_config_path) as f:
236+
try:
237+
build_config_json = json.load(f)
238+
except Exception: # pragma: no cover
239+
print("%s exists but contains invalid json. Is your build up-to-date?"
240+
% build_config_path)
241+
raise TestRunnerError()
242+
243+
return BuildConfig(build_config_json)
244+
245+
245246
class BaseTestRunner(object):
246247
def __init__(self, basedir=None):
247248
self.basedir = basedir or BASE_DIR
248249
self.outdir = None
249250
self.build_config = None
250-
self.mode_name = None
251251
self.mode_options = None
252252
self.target_os = None
253253

@@ -284,7 +284,7 @@ def execute(self, sys_args=None):
284284
tests = self._load_testsuite_generators(args, options)
285285
self._setup_env()
286286
print(">>> Running tests for %s.%s" % (self.build_config.arch,
287-
self.mode_name))
287+
self.mode_options.label))
288288
exit_code = self._do_execute(tests, args, options)
289289
if exit_code == utils.EXIT_CODE_FAILURES and options.json_test_results:
290290
print("Force exit code 0 after failures. Json test results file "
@@ -318,9 +318,6 @@ def _add_parser_default_options(self, parser):
318318
default="out")
319319
parser.add_option("--arch",
320320
help="The architecture to run tests for")
321-
parser.add_option("-m", "--mode",
322-
help="The test mode in which to run (uppercase for builds"
323-
" in CI): %s" % MODES.keys())
324321
parser.add_option("--shell-dir", help="DEPRECATED! Executables from build "
325322
"directory will be used")
326323
parser.add_option("--test-root", help="Root directory of the test suites",
@@ -402,17 +399,21 @@ def _add_parser_options(self, parser):
402399
def _parse_args(self, parser, sys_args):
403400
options, args = parser.parse_args(sys_args)
404401

405-
if any(map(lambda v: v and ',' in v,
406-
[options.arch, options.mode])): # pragma: no cover
407-
print('Multiple arch/mode are deprecated')
402+
if options.arch and ',' in options.arch: # pragma: no cover
403+
print('Multiple architectures are deprecated')
408404
raise TestRunnerError()
409405

410406
return options, args
411407

412408
def _load_build_config(self, options):
413409
for outdir in self._possible_outdirs(options):
414410
try:
415-
self.build_config = self._do_load_build_config(outdir, options.verbose)
411+
self.build_config = _do_load_build_config(outdir, options.verbose)
412+
413+
# In auto-detect mode the outdir is always where we found the build config.
414+
# This ensures that we'll also take the build products from there.
415+
self.outdir = outdir
416+
break
416417
except TestRunnerError:
417418
pass
418419

@@ -435,26 +436,21 @@ def _load_build_config(self, options):
435436
# Returns possible build paths in order:
436437
# gn
437438
# outdir
438-
# outdir/arch.mode
439-
# Each path is provided in two versions: <path> and <path>/mode for bots.
439+
# outdir on bots
440440
def _possible_outdirs(self, options):
441441
def outdirs():
442442
if options.gn:
443443
yield self._get_gn_outdir()
444444
return
445445

446446
yield options.outdir
447-
if options.arch and options.mode:
448-
yield os.path.join(options.outdir,
449-
'%s.%s' % (options.arch, options.mode))
447+
448+
if os.path.basename(options.outdir) != 'build':
449+
yield os.path.join(options.outdir, 'build')
450450

451451
for outdir in outdirs():
452452
yield os.path.join(self.basedir, outdir)
453453

454-
# bot option
455-
if options.mode:
456-
yield os.path.join(self.basedir, outdir, options.mode)
457-
458454
def _get_gn_outdir(self):
459455
gn_out_dir = os.path.join(self.basedir, DEFAULT_OUT_GN)
460456
latest_timestamp = -1
@@ -470,51 +466,13 @@ def _get_gn_outdir(self):
470466
print(">>> Latest GN build found: %s" % latest_config)
471467
return os.path.join(DEFAULT_OUT_GN, latest_config)
472468

473-
def _do_load_build_config(self, outdir, verbose=False):
474-
build_config_path = os.path.join(outdir, "v8_build_config.json")
475-
if not os.path.exists(build_config_path):
476-
if verbose:
477-
print("Didn't find build config: %s" % build_config_path)
478-
raise TestRunnerError()
479-
480-
with open(build_config_path) as f:
481-
try:
482-
build_config_json = json.load(f)
483-
except Exception: # pragma: no cover
484-
print("%s exists but contains invalid json. Is your build up-to-date?"
485-
% build_config_path)
486-
raise TestRunnerError()
487-
488-
# In auto-detect mode the outdir is always where we found the build config.
489-
# This ensures that we'll also take the build products from there.
490-
self.outdir = os.path.dirname(build_config_path)
491-
492-
return BuildConfig(build_config_json)
493-
494469
def _process_default_options(self, options):
495-
# We don't use the mode for more path-magic.
496-
# Therefore transform the bot mode here to fix build_config value.
497-
if options.mode:
498-
options.mode = self._bot_to_v8_mode(options.mode)
499-
500-
build_config_mode = 'debug' if self.build_config.is_debug else 'release'
501-
if options.mode:
502-
if options.mode not in MODES: # pragma: no cover
503-
print('%s mode is invalid' % options.mode)
504-
raise TestRunnerError()
505-
if MODES[options.mode].execution_mode != build_config_mode:
506-
print ('execution mode (%s) for %s is inconsistent with build config '
507-
'(%s)' % (
508-
MODES[options.mode].execution_mode,
509-
options.mode,
510-
build_config_mode))
511-
raise TestRunnerError()
512-
513-
self.mode_name = options.mode
470+
if self.build_config.is_debug:
471+
self.mode_options = DEBUG_MODE
472+
elif self.build_config.dcheck_always_on:
473+
self.mode_options = TRY_RELEASE_MODE
514474
else:
515-
self.mode_name = build_config_mode
516-
517-
self.mode_options = MODES[self.mode_name]
475+
self.mode_options = RELEASE_MODE
518476

519477
if options.arch and options.arch != self.build_config.arch:
520478
print('--arch value (%s) inconsistent with build config (%s).' % (
@@ -535,15 +493,6 @@ def _process_default_options(self, options):
535493
options.command_prefix = shlex.split(options.command_prefix)
536494
options.extra_flags = sum(map(shlex.split, options.extra_flags), [])
537495

538-
def _bot_to_v8_mode(self, config):
539-
"""Convert build configs from bots to configs understood by the v8 runner.
540-
541-
V8 configs are always lower case and without the additional _x64 suffix
542-
for 64 bit builds on windows with ninja.
543-
"""
544-
mode = config[:-4] if config.endswith('_x64') else config
545-
return mode.lower()
546-
547496
def _process_options(self, options):
548497
pass
549498

@@ -692,9 +641,7 @@ def _get_statusfile_variables(self, options):
692641
"is_clang": self.build_config.is_clang,
693642
"is_full_debug": self.build_config.is_full_debug,
694643
"mips_arch_variant": mips_arch_variant,
695-
"mode": self.mode_options.status_mode
696-
if not self.build_config.dcheck_always_on
697-
else "debug",
644+
"mode": self.mode_options.status_mode,
698645
"msan": self.build_config.msan,
699646
"no_harness": options.no_harness,
700647
"no_i18n": self.build_config.no_i18n,
@@ -804,10 +751,7 @@ def _get_shard_info(self, options):
804751
def _create_progress_indicators(self, test_count, options):
805752
procs = [PROGRESS_INDICATORS[options.progress]()]
806753
if options.json_test_results:
807-
procs.append(progress.JsonTestProgressIndicator(
808-
self.framework_name,
809-
self.build_config.arch,
810-
self.mode_options.execution_mode))
754+
procs.append(progress.JsonTestProgressIndicator(self.framework_name))
811755

812756
for proc in procs:
813757
proc.configure(options)

tools/testrunner/standard_runner.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -380,10 +380,8 @@ def _duration_results_text(test):
380380
]
381381

382382
assert os.path.exists(options.json_test_results)
383-
complete_results = []
384383
with open(options.json_test_results, "r") as f:
385-
complete_results = json.loads(f.read())
386-
output = complete_results[0]
384+
output = json.load(f)
387385
lines = []
388386
for test in output['slowest_tests']:
389387
suffix = ''

0 commit comments

Comments
 (0)