Skip to content

Commit 4f015e8

Browse files
mi-acCommit Bot
authored andcommitted
[test] Make finding build directory more flexible
This prepares moving the build directory on bots to out/build. For a smooth transition, the performance runner will dynamically check for the build in several locations. This prepares: https://crrev.com/c/2426643 NOTREECHECKS=true Bug: chromium:1132088 Change-Id: Ia12fcdedec0f4ac2bfe087e8154c0acb8771a43f Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2431364 Commit-Queue: Michael Achenbach <[email protected]> Reviewed-by: Liviu Rau <[email protected]> Cr-Commit-Position: refs/heads/master@{#70158}
1 parent c55c00d commit 4f015e8

3 files changed

Lines changed: 68 additions & 16 deletions

File tree

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/unittests/run_perf_test.py

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,21 @@
9090
'units': 'ms',
9191
}
9292

93+
94+
class UnitTest(unittest.TestCase):
95+
@classmethod
96+
def setUpClass(cls):
97+
sys.path.insert(0, BASE_DIR)
98+
import run_perf
99+
global run_perf
100+
101+
def testBuildDirectory(self):
102+
base_path = os.path.join(TEST_DATA, 'builddirs', 'dir1', 'out')
103+
expected_path = os.path.join(base_path, 'build')
104+
self.assertEquals(
105+
expected_path, run_perf.find_build_directory(base_path, 'x64'))
106+
107+
93108
class PerfTest(unittest.TestCase):
94109
@classmethod
95110
def setUpClass(cls):
@@ -125,6 +140,7 @@ def _WriteTestInput(self, json_content):
125140
f.write(json.dumps(json_content))
126141

127142
def _MockCommand(self, *args, **kwargs):
143+
on_bots = kwargs.pop('on_bots', False)
128144
# Fake output for each test run.
129145
test_outputs = [Output(stdout=arg,
130146
timed_out=kwargs.get('timed_out', False),
@@ -142,6 +158,16 @@ def execute(*args, **kwargs):
142158
run_perf.command, 'PosixCommand',
143159
mock.MagicMock(side_effect=create_cmd)).start()
144160

161+
build_dir = 'Release' if on_bots else 'x64.release'
162+
out_dirs = ['out', 'out-secondary']
163+
return_values = [
164+
os.path.join(os.path.dirname(BASE_DIR), out, build_dir)
165+
for out in out_dirs
166+
]
167+
mock.patch.object(
168+
run_perf, 'find_build_directory',
169+
mock.MagicMock(side_effect=return_values)).start()
170+
145171
# Check that d8 is called from the correct cwd for each test run.
146172
dirs = [os.path.join(TEST_WORKSPACE, arg) for arg in args[0]]
147173
def chdir(*args, **kwargs):
@@ -394,11 +420,12 @@ def testTwoRunsStdDevRegExp(self):
394420

395421
def testBuildbot(self):
396422
self._WriteTestInput(V8_JSON)
397-
self._MockCommand(['.'], ['Richards: 1.234\nDeltaBlue: 10657567\n'])
423+
self._MockCommand(['.'], ['Richards: 1.234\nDeltaBlue: 10657567\n'],
424+
on_bots=True)
398425
mock.patch.object(
399426
run_perf.Platform, 'ReadBuildConfig',
400427
mock.MagicMock(return_value={'is_android': False})).start()
401-
self.assertEqual(0, self._CallMain('--buildbot'))
428+
self.assertEqual(0, self._CallMain())
402429
self._VerifyResults('test', 'score', [
403430
{'name': 'Richards', 'results': [1.234], 'stddev': ''},
404431
{'name': 'DeltaBlue', 'results': [10657567.0], 'stddev': ''},
@@ -410,11 +437,12 @@ def testBuildbotWithTotal(self):
410437
test_input = dict(V8_JSON)
411438
test_input['total'] = True
412439
self._WriteTestInput(test_input)
413-
self._MockCommand(['.'], ['Richards: 1.234\nDeltaBlue: 10657567\n'])
440+
self._MockCommand(['.'], ['Richards: 1.234\nDeltaBlue: 10657567\n'],
441+
on_bots=True)
414442
mock.patch.object(
415443
run_perf.Platform, 'ReadBuildConfig',
416444
mock.MagicMock(return_value={'is_android': False})).start()
417-
self.assertEqual(0, self._CallMain('--buildbot'))
445+
self.assertEqual(0, self._CallMain())
418446
self._VerifyResults('test', 'score', [
419447
{'name': 'Richards', 'results': [1.234], 'stddev': ''},
420448
{'name': 'DeltaBlue', 'results': [10657567.0], 'stddev': ''},
@@ -427,11 +455,12 @@ def testBuildbotWithTotalAndErrors(self):
427455
test_input = dict(V8_JSON)
428456
test_input['total'] = True
429457
self._WriteTestInput(test_input)
430-
self._MockCommand(['.'], ['x\nRichards: bla\nDeltaBlue: 10657567\ny\n'])
458+
self._MockCommand(['.'], ['x\nRichards: bla\nDeltaBlue: 10657567\ny\n'],
459+
on_bots=True)
431460
mock.patch.object(
432461
run_perf.Platform, 'ReadBuildConfig',
433462
mock.MagicMock(return_value={'is_android': False})).start()
434-
self.assertEqual(1, self._CallMain('--buildbot'))
463+
self.assertEqual(1, self._CallMain())
435464
self._VerifyResults('test', 'score', [
436465
{'name': 'DeltaBlue', 'results': [10657567.0], 'stddev': ''},
437466
])
@@ -484,6 +513,7 @@ def testAndroid(self):
484513
mock.patch('run_perf.AndroidPlatform.PreExecution').start()
485514
mock.patch('run_perf.AndroidPlatform.PostExecution').start()
486515
mock.patch('run_perf.AndroidPlatform.PreTests').start()
516+
mock.patch('run_perf.find_build_directory').start()
487517
mock.patch(
488518
'run_perf.AndroidPlatform.Run',
489519
return_value=(Output(stdout='Richards: 1.234\nDeltaBlue: 10657567\n'),
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
test

0 commit comments

Comments
 (0)