Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Side by Side Diff: tools/mb/mb_unittest.py

Issue 2510033004: Add rtc_use_memcheck flag, update MB and GN to handle it, and add gni files listing the runtime deps (Closed)
Patch Set: Fixed android and added unittest. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/mb/mb.py ('k') | tools/valgrind-webrtc/python-google.gni » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 2 # Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 # 3 #
4 # Use of this source code is governed by a BSD-style license 4 # Use of this source code is governed by a BSD-style license
5 # that can be found in the LICENSE file in the root of the source 5 # that can be found in the LICENSE file in the root of the source
6 # tree. An additional intellectual property rights grant can be found 6 # tree. An additional intellectual property rights grant can be found
7 # in the file PATENTS. All contributing project authors may 7 # in the file PATENTS. All contributing project authors may
8 # be found in the AUTHORS file in the root of the source tree. 8 # be found in the AUTHORS file in the root of the source tree.
9 9
10 """Tests for mb.py.""" 10 """Tests for mb.py."""
11 11
12 import ast
12 import json 13 import json
13 import StringIO 14 import StringIO
14 import os 15 import os
15 import sys 16 import sys
16 import unittest 17 import unittest
17 18
18 import mb 19 import mb
19 20
20 21
21 class FakeMBW(mb.MetaBuildWrapper): 22 class FakeMBW(mb.MetaBuildWrapper):
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 { 115 {
115 'masters': { 116 'masters': {
116 'chromium': {}, 117 'chromium': {},
117 'fake_master': { 118 'fake_master': {
118 'fake_builder': 'gyp_rel_bot', 119 'fake_builder': 'gyp_rel_bot',
119 'fake_gn_builder': 'gn_rel_bot', 120 'fake_gn_builder': 'gn_rel_bot',
120 'fake_gyp_crosscompile_builder': 'gyp_crosscompile', 121 'fake_gyp_crosscompile_builder': 'gyp_crosscompile',
121 'fake_gn_debug_builder': 'gn_debug_goma', 122 'fake_gn_debug_builder': 'gn_debug_goma',
122 'fake_gyp_builder': 'gyp_debug', 123 'fake_gyp_builder': 'gyp_debug',
123 'fake_gn_args_bot': '//build/args/bots/fake_master/fake_gn_args_bot.gn', 124 'fake_gn_args_bot': '//build/args/bots/fake_master/fake_gn_args_bot.gn',
125 'fake_memcheck_bot': 'gn_memcheck_bot',
124 'fake_multi_phase': { 'phase_1': 'gn_phase_1', 'phase_2': 'gn_phase_2'}, 126 'fake_multi_phase': { 'phase_1': 'gn_phase_1', 'phase_2': 'gn_phase_2'},
127 'fake_android_bot': 'gn_android_bot',
125 }, 128 },
126 }, 129 },
127 'configs': { 130 'configs': {
128 'gyp_rel_bot': ['gyp', 'rel', 'goma'], 131 'gyp_rel_bot': ['gyp', 'rel', 'goma'],
129 'gn_debug_goma': ['gn', 'debug', 'goma'], 132 'gn_debug_goma': ['gn', 'debug', 'goma'],
130 'gyp_debug': ['gyp', 'debug', 'fake_feature1'], 133 'gyp_debug': ['gyp', 'debug', 'fake_feature1'],
131 'gn_rel_bot': ['gn', 'rel', 'goma'], 134 'gn_rel_bot': ['gn', 'rel', 'goma'],
132 'gyp_crosscompile': ['gyp', 'crosscompile'], 135 'gyp_crosscompile': ['gyp', 'crosscompile'],
133 'gn_phase_1': ['gn', 'phase_1'], 136 'gn_phase_1': ['gn', 'phase_1'],
134 'gn_phase_2': ['gn', 'phase_2'], 137 'gn_phase_2': ['gn', 'phase_2'],
138 'gn_memcheck_bot': ['gn', 'memcheck'],
139 'gn_android_bot': ['gn', 'android'],
135 }, 140 },
136 'mixins': { 141 'mixins': {
137 'crosscompile': { 142 'crosscompile': {
138 'gyp_crosscompile': True, 143 'gyp_crosscompile': True,
139 }, 144 },
140 'fake_feature1': { 145 'fake_feature1': {
141 'gn_args': 'enable_doom_melon=true', 146 'gn_args': 'enable_doom_melon=true',
142 'gyp_defines': 'doom_melon=1', 147 'gyp_defines': 'doom_melon=1',
143 }, 148 },
144 'gyp': {'type': 'gyp'}, 149 'gyp': {'type': 'gyp'},
145 'gn': {'type': 'gn'}, 150 'gn': {'type': 'gn'},
146 'goma': { 151 'goma': {
147 'gn_args': 'use_goma=true', 152 'gn_args': 'use_goma=true',
148 'gyp_defines': 'goma=1', 153 'gyp_defines': 'goma=1',
149 }, 154 },
150 'phase_1': { 155 'phase_1': {
151 'gn_args': 'phase=1', 156 'gn_args': 'phase=1',
152 'gyp_args': 'phase=1', 157 'gyp_args': 'phase=1',
153 }, 158 },
154 'phase_2': { 159 'phase_2': {
155 'gn_args': 'phase=2', 160 'gn_args': 'phase=2',
156 'gyp_args': 'phase=2', 161 'gyp_args': 'phase=2',
157 }, 162 },
158 'rel': { 163 'rel': {
159 'gn_args': 'is_debug=false', 164 'gn_args': 'is_debug=false',
160 }, 165 },
161 'debug': { 166 'debug': {
162 'gn_args': 'is_debug=true', 167 'gn_args': 'is_debug=true',
163 }, 168 },
169 'memcheck': {
170 'gn_args': 'rtc_use_memcheck=true',
171 },
172 'android': {
173 'gn_args': 'target_os="android"',
174 }
164 }, 175 },
165 } 176 }
166 """ 177 """
167 178
168 179
169 TEST_BAD_CONFIG = """\ 180 TEST_BAD_CONFIG = """\
170 { 181 {
171 'configs': { 182 'configs': {
172 'gn_rel_bot_1': ['gn', 'rel', 'chrome_with_codecs'], 183 'gn_rel_bot_1': ['gn', 'rel', 'chrome_with_codecs'],
173 'gn_rel_bot_2': ['gn', 'rel', 'bad_nested_config'], 184 'gn_rel_bot_2': ['gn', 'rel', 'bad_nested_config'],
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 '-c', 'gn_debug_goma', 374 '-c', 'gn_debug_goma',
364 '--swarming-targets-file', '/tmp/swarming_targets', 375 '--swarming-targets-file', '/tmp/swarming_targets',
365 '--isolate-map-file', 376 '--isolate-map-file',
366 '/fake_src/testing/buildbot/gn_isolate_map.pyl', 377 '/fake_src/testing/buildbot/gn_isolate_map.pyl',
367 '//out/Default'], mbw=mbw, ret=0) 378 '//out/Default'], mbw=mbw, ret=0)
368 self.assertIn('c:\\fake_src\\out\\Default\\cc_perftests.isolate', 379 self.assertIn('c:\\fake_src\\out\\Default\\cc_perftests.isolate',
369 mbw.files) 380 mbw.files)
370 self.assertIn('c:\\fake_src\\out\\Default\\cc_perftests.isolated.gen.json', 381 self.assertIn('c:\\fake_src\\out\\Default\\cc_perftests.isolated.gen.json',
371 mbw.files) 382 mbw.files)
372 383
384 def test_gn_gen_swarming_android(self):
385 test_files = {
386 '/tmp/swarming_targets': 'base_unittests\n',
387 '/fake_src/testing/buildbot/gn_isolate_map.pyl': (
388 "{'base_unittests': {"
389 " 'label': '//base:base_unittests',"
390 " 'type': 'additional_compile_target',"
391 "}}\n"
392 ),
393 '/fake_src/out/Default/base_unittests.runtime_deps': (
394 "base_unittests\n"
395 ),
396 }
397 mbw = self.check(['gen', '-c', 'gn_android_bot', '//out/Default',
398 '--swarming-targets-file', '/tmp/swarming_targets',
399 '--isolate-map-file',
400 '/fake_src/testing/buildbot/gn_isolate_map.pyl'],
401 files=test_files, ret=0)
402
403 isolate_file = mbw.files['/fake_src/out/Default/base_unittests.isolate']
404 isolate_file_contents = ast.literal_eval(isolate_file)
405 files = isolate_file_contents['variables']['files']
406 command = isolate_file_contents['variables']['command']
407
408 self.assertEqual(files, ['base_unittests'])
409 self.assertEqual(command, [
410 './../../build/android/test_wrapper/logdog_wrapper.py',
411 '--logdog-bin-cmd', './../../bin/logdog_butler',
412 '--project', 'chromium',
413 '--service-account-json',
414 '/creds/service_accounts/service-account-luci-logdog-publisher.json',
415 '--prefix', 'android/swarming/logcats/${SWARMING_TASK_ID}',
416 '--source', '${ISOLATED_OUTDIR}/logcats',
417 '--name', 'unified_logcats',
418 'bin/run_base_unittests',
419 '--logcat-output-file', '${ISOLATED_OUTDIR}/logcats',
420 '--target-devices-file', '${SWARMING_BOT_FILE}',
421 '-v',
422 ])
423
424 def test_gn_gen_swarming_android_junit_test(self):
425 test_files = {
426 '/tmp/swarming_targets': 'base_unittests\n',
427 '/fake_src/testing/buildbot/gn_isolate_map.pyl': (
428 "{'base_unittests': {"
429 " 'label': '//base:base_unittests',"
430 " 'type': 'junit_test',"
431 "}}\n"
432 ),
433 '/fake_src/out/Default/base_unittests.runtime_deps': (
434 "base_unittests\n"
435 ),
436 }
437 mbw = self.check(['gen', '-c', 'gn_android_bot', '//out/Default',
438 '--swarming-targets-file', '/tmp/swarming_targets',
439 '--isolate-map-file',
440 '/fake_src/testing/buildbot/gn_isolate_map.pyl'],
441 files=test_files, ret=0)
442
443 isolate_file = mbw.files['/fake_src/out/Default/base_unittests.isolate']
444 isolate_file_contents = ast.literal_eval(isolate_file)
445 files = isolate_file_contents['variables']['files']
446 command = isolate_file_contents['variables']['command']
447
448 self.assertEqual(files, ['base_unittests'])
449 self.assertEqual(command, [
450 './../../build/android/test_wrapper/logdog_wrapper.py',
451 '--logdog-bin-cmd', './../../bin/logdog_butler',
452 '--project', 'chromium',
453 '--service-account-json',
454 '/creds/service_accounts/service-account-luci-logdog-publisher.json',
455 '--prefix', 'android/swarming/logcats/${SWARMING_TASK_ID}',
456 '--source', '${ISOLATED_OUTDIR}/logcats',
457 '--name', 'unified_logcats',
458 'bin/run_base_unittests',
459 '--logcat-output-file', '${ISOLATED_OUTDIR}/logcats',
460 '--target-devices-file', '${SWARMING_BOT_FILE}',
461 '-v',
462 ])
463
464 def test_gn_gen_non_parallel_console_test_launcher(self):
465 test_files = {
466 '/tmp/swarming_targets': 'base_unittests\n',
467 '/fake_src/testing/buildbot/gn_isolate_map.pyl': (
468 "{'base_unittests': {"
469 " 'label': '//base:base_unittests',"
470 " 'type': 'non_parallel_console_test_launcher',"
471 "}}\n"
472 ),
473 '/fake_src/out/Default/base_unittests.runtime_deps': (
474 "base_unittests\n"
475 ),
476 }
477 mbw = self.check(['gen', '-c', 'gn_debug_goma', '//out/Default',
478 '--swarming-targets-file', '/tmp/swarming_targets',
479 '--isolate-map-file',
480 '/fake_src/testing/buildbot/gn_isolate_map.pyl'],
481 files=test_files, ret=0)
482
483 isolate_file = mbw.files['/fake_src/out/Default/base_unittests.isolate']
484 isolate_file_contents = ast.literal_eval(isolate_file)
485 files = isolate_file_contents['variables']['files']
486 command = isolate_file_contents['variables']['command']
487
488 self.assertEqual(files, [
489 '../../testing/test_env.py',
490 'base_unittests',
491 ])
492 self.assertEqual(command, [
493 '../../testing/test_env.py',
494 './base_unittests',
495 '--',
496 '--asan=0',
497 '--msan=0',
498 '--tsan=0',
499 ])
500
501 def test_gn_isolate_windowed_test_launcher_linux(self):
502 test_files = {
503 '/tmp/swarming_targets': 'base_unittests\n',
504 '/fake_src/testing/buildbot/gn_isolate_map.pyl': (
505 "{'base_unittests': {"
506 " 'label': '//base:base_unittests',"
507 " 'type': 'windowed_test_launcher',"
508 "}}\n"
509 ),
510 '/fake_src/out/Default/base_unittests.runtime_deps': (
511 "base_unittests\n"
512 "some_resource_file\n"
513 ),
514 }
515 mbw = self.check(['gen', '-c', 'gn_debug_goma', '//out/Default',
516 '--swarming-targets-file', '/tmp/swarming_targets',
517 '--isolate-map-file',
518 '/fake_src/testing/buildbot/gn_isolate_map.pyl'],
519 files=test_files, ret=0)
520
521 isolate_file = mbw.files['/fake_src/out/Default/base_unittests.isolate']
522 isolate_file_contents = ast.literal_eval(isolate_file)
523 files = isolate_file_contents['variables']['files']
524 command = isolate_file_contents['variables']['command']
525
526 self.assertEqual(files, [
527 '../../testing/test_env.py',
528 '../../testing/xvfb.py',
529 '../../third_party/gtest-parallel/gtest-parallel',
530 '../../third_party/gtest-parallel/gtest-parallel-wrapper.py',
531 'base_unittests',
532 'some_resource_file',
533 'xdisplaycheck',
534 ])
535 self.assertEqual(command, [
536 '../../testing/xvfb.py',
537 '.',
538 '../../third_party/gtest-parallel/gtest-parallel-wrapper.py',
539 './base_unittests',
540 '--',
541 '--asan=0',
542 '--msan=0',
543 '--tsan=0',
544 ])
545
546 def test_gn_gen_windowed_test_launcher_win(self):
547 files = {
548 '/tmp/swarming_targets': 'unittests\n',
549 '/fake_src/testing/buildbot/gn_isolate_map.pyl': (
550 "{'unittests': {"
551 " 'label': '//somewhere:unittests',"
552 " 'type': 'windowed_test_launcher',"
553 "}}\n"
554 ),
555 r'c:\fake_src\out\Default\unittests.exe.runtime_deps': (
556 "unittests.exe\n"
557 "some_dependency\n"
558 ),
559 }
560 mbw = self.fake_mbw(files=files, win32=True)
561 self.check(['gen',
562 '-c', 'gn_debug_goma',
563 '--swarming-targets-file', '/tmp/swarming_targets',
564 '--isolate-map-file',
565 '/fake_src/testing/buildbot/gn_isolate_map.pyl',
566 '//out/Default'], mbw=mbw, ret=0)
567
568 isolate_file = mbw.files['c:\\fake_src\\out\\Default\\unittests.isolate']
569 isolate_file_contents = ast.literal_eval(isolate_file)
570 files = isolate_file_contents['variables']['files']
571 command = isolate_file_contents['variables']['command']
572
573 self.assertEqual(files, [
574 '../../testing/test_env.py',
575 '../../third_party/gtest-parallel/gtest-parallel',
576 '../../third_party/gtest-parallel/gtest-parallel-wrapper.py',
577 'some_dependency',
578 'unittests.exe',
579 ])
580 self.assertEqual(command, [
581 '../../testing/test_env.py',
582 '../../third_party/gtest-parallel/gtest-parallel-wrapper.py',
583 r'.\unittests.exe',
584 '--',
585 '--asan=0',
586 '--msan=0',
587 '--tsan=0',
588 ])
589
590 def test_gn_gen_console_test_launcher(self):
591 test_files = {
592 '/tmp/swarming_targets': 'base_unittests\n',
593 '/fake_src/testing/buildbot/gn_isolate_map.pyl': (
594 "{'base_unittests': {"
595 " 'label': '//base:base_unittests',"
596 " 'type': 'console_test_launcher',"
597 "}}\n"
598 ),
599 '/fake_src/out/Default/base_unittests.runtime_deps': (
600 "base_unittests\n"
601 ),
602 }
603 mbw = self.check(['gen', '-c', 'gn_debug_goma', '//out/Default',
604 '--swarming-targets-file', '/tmp/swarming_targets',
605 '--isolate-map-file',
606 '/fake_src/testing/buildbot/gn_isolate_map.pyl'],
607 files=test_files, ret=0)
608
609 isolate_file = mbw.files['/fake_src/out/Default/base_unittests.isolate']
610 isolate_file_contents = ast.literal_eval(isolate_file)
611 files = isolate_file_contents['variables']['files']
612 command = isolate_file_contents['variables']['command']
613
614 self.assertEqual(files, [
615 '../../testing/test_env.py',
616 '../../third_party/gtest-parallel/gtest-parallel',
617 '../../third_party/gtest-parallel/gtest-parallel-wrapper.py',
618 'base_unittests',
619 ])
620 self.assertEqual(command, [
621 '../../testing/test_env.py',
622 '../../third_party/gtest-parallel/gtest-parallel-wrapper.py',
623 './base_unittests',
624 '--',
625 '--asan=0',
626 '--msan=0',
627 '--tsan=0',
628 ])
629
630 def test_gn_isolate_console_test_launcher_memcheck(self):
631 test_files = {
632 '/tmp/swarming_targets': 'base_unittests\n',
633 '/fake_src/testing/buildbot/gn_isolate_map.pyl': (
634 "{'base_unittests': {"
635 " 'label': '//base:base_unittests',"
636 " 'type': 'console_test_launcher',"
637 "}}\n"
638 ),
639 '/fake_src/out/Release/base_unittests.runtime_deps': (
640 "base_unittests\n"
641 "lots_of_memcheck_dependencies\n"
642 "../../tools/valgrind-webrtc/webrtc_tests.sh\n"
643 ),
644 }
645 mbw = self.check(['gen', '-c', 'gn_memcheck_bot', '//out/Release',
646 '--swarming-targets-file', '/tmp/swarming_targets',
647 '--isolate-map-file',
648 '/fake_src/testing/buildbot/gn_isolate_map.pyl'],
649 files=test_files, ret=0)
650
651 isolate_file = mbw.files['/fake_src/out/Release/base_unittests.isolate']
652 isolate_file_contents = ast.literal_eval(isolate_file)
653 files = isolate_file_contents['variables']['files']
654 command = isolate_file_contents['variables']['command']
655
656 self.assertEqual(files, [
657 '../../testing/test_env.py',
658 '../../tools/valgrind-webrtc/webrtc_tests.sh',
659 'base_unittests',
660 'lots_of_memcheck_dependencies',
661 ])
662 self.assertEqual(command, [
663 '../../testing/test_env.py',
664 'bash',
665 '../../tools/valgrind-webrtc/webrtc_tests.sh',
666 '--tool',
667 'memcheck',
668 '--target',
669 'Release',
670 '--build-dir',
671 '..',
672 '--test',
673 './base_unittests',
674 '--',
675 '--asan=0',
676 '--msan=0',
677 '--tsan=0',
678 ])
373 679
374 def test_gn_isolate(self): 680 def test_gn_isolate(self):
375 files = { 681 files = {
376 '/fake_src/out/Default/toolchain.ninja': "", 682 '/fake_src/out/Default/toolchain.ninja': "",
377 '/fake_src/testing/buildbot/gn_isolate_map.pyl': ( 683 '/fake_src/testing/buildbot/gn_isolate_map.pyl': (
378 "{'base_unittests': {" 684 "{'base_unittests': {"
379 " 'label': '//base:base_unittests'," 685 " 'label': '//base:base_unittests',"
380 " 'type': 'non_parallel_console_test_launcher'," 686 " 'type': 'non_parallel_console_test_launcher',"
381 " 'args': [],"
382 "}}\n" 687 "}}\n"
383 ), 688 ),
384 '/fake_src/out/Default/base_unittests.runtime_deps': ( 689 '/fake_src/out/Default/base_unittests.runtime_deps': (
385 "base_unittests\n" 690 "base_unittests\n"
386 ), 691 ),
387 } 692 }
388 self.check(['isolate', '-c', 'gn_debug_goma', '//out/Default', 693 self.check(['isolate', '-c', 'gn_debug_goma', '//out/Default',
389 'base_unittests'], files=files, ret=0) 694 'base_unittests'], files=files, ret=0)
390 695
391 # test running isolate on an existing build_dir 696 # test running isolate on an existing build_dir
392 files['/fake_src/out/Default/args.gn'] = 'is_debug = True\n' 697 files['/fake_src/out/Default/args.gn'] = 'is_debug = True\n'
393 self.check(['isolate', '//out/Default', 'base_unittests'], 698 self.check(['isolate', '//out/Default', 'base_unittests'],
394 files=files, ret=0) 699 files=files, ret=0)
395
396 files['/fake_src/out/Default/mb_type'] = 'gn\n' 700 files['/fake_src/out/Default/mb_type'] = 'gn\n'
397 self.check(['isolate', '//out/Default', 'base_unittests'], 701 self.check(['isolate', '//out/Default', 'base_unittests'],
398 files=files, ret=0) 702 files=files, ret=0)
399 703
400 def test_gn_run(self): 704 def test_gn_run(self):
401 files = { 705 files = {
402 '/fake_src/testing/buildbot/gn_isolate_map.pyl': ( 706 '/fake_src/testing/buildbot/gn_isolate_map.pyl': (
403 "{'base_unittests': {" 707 "{'base_unittests': {"
404 " 'label': '//base:base_unittests'," 708 " 'label': '//base:base_unittests',"
405 " 'type': 'windowed_test_launcher'," 709 " 'type': 'windowed_test_launcher',"
406 " 'args': [],"
407 "}}\n" 710 "}}\n"
408 ), 711 ),
409 '/fake_src/out/Default/base_unittests.runtime_deps': ( 712 '/fake_src/out/Default/base_unittests.runtime_deps': (
410 "base_unittests\n" 713 "base_unittests\n"
411 ), 714 ),
412 } 715 }
413 self.check(['run', '-c', 'gn_debug_goma', '//out/Default', 716 self.check(['run', '-c', 'gn_debug_goma', '//out/Default',
414 'base_unittests'], files=files, ret=0) 717 'base_unittests'], files=files, ret=0)
415 718
416 def test_gn_lookup(self): 719 def test_gn_lookup(self):
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 self.check(['lookup', '-c', 'fake_config'], mbw=mbw, 835 self.check(['lookup', '-c', 'fake_config'], mbw=mbw,
533 ret=0, 836 ret=0,
534 out=("GYP_DEFINES='foo=bar baz=1'\n" 837 out=("GYP_DEFINES='foo=bar baz=1'\n"
535 "GYP_LINK_CONCURRENCY=1\n" 838 "GYP_LINK_CONCURRENCY=1\n"
536 "LLVM_FORCE_HEAD_REVISION=1\n" 839 "LLVM_FORCE_HEAD_REVISION=1\n"
537 "python build/gyp_chromium -G output_dir=_path_\n")) 840 "python build/gyp_chromium -G output_dir=_path_\n"))
538 841
539 842
540 if __name__ == '__main__': 843 if __name__ == '__main__':
541 unittest.main() 844 unittest.main()
OLDNEW
« no previous file with comments | « tools/mb/mb.py ('k') | tools/valgrind-webrtc/python-google.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698