OLD | NEW |
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 Loading... |
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'}, |
125 }, | 127 }, |
126 }, | 128 }, |
127 'configs': { | 129 'configs': { |
128 'gyp_rel_bot': ['gyp', 'rel', 'goma'], | 130 'gyp_rel_bot': ['gyp', 'rel', 'goma'], |
129 'gn_debug_goma': ['gn', 'debug', 'goma'], | 131 'gn_debug_goma': ['gn', 'debug', 'goma'], |
130 'gyp_debug': ['gyp', 'debug', 'fake_feature1'], | 132 'gyp_debug': ['gyp', 'debug', 'fake_feature1'], |
131 'gn_rel_bot': ['gn', 'rel', 'goma'], | 133 'gn_rel_bot': ['gn', 'rel', 'goma'], |
132 'gyp_crosscompile': ['gyp', 'crosscompile'], | 134 'gyp_crosscompile': ['gyp', 'crosscompile'], |
133 'gn_phase_1': ['gn', 'phase_1'], | 135 'gn_phase_1': ['gn', 'phase_1'], |
134 'gn_phase_2': ['gn', 'phase_2'], | 136 'gn_phase_2': ['gn', 'phase_2'], |
| 137 'gn_memcheck_bot': ['gn', 'memcheck'], |
135 }, | 138 }, |
136 'mixins': { | 139 'mixins': { |
137 'crosscompile': { | 140 'crosscompile': { |
138 'gyp_crosscompile': True, | 141 'gyp_crosscompile': True, |
139 }, | 142 }, |
140 'fake_feature1': { | 143 'fake_feature1': { |
141 'gn_args': 'enable_doom_melon=true', | 144 'gn_args': 'enable_doom_melon=true', |
142 'gyp_defines': 'doom_melon=1', | 145 'gyp_defines': 'doom_melon=1', |
143 }, | 146 }, |
144 'gyp': {'type': 'gyp'}, | 147 'gyp': {'type': 'gyp'}, |
145 'gn': {'type': 'gn'}, | 148 'gn': {'type': 'gn'}, |
146 'goma': { | 149 'goma': { |
147 'gn_args': 'use_goma=true', | 150 'gn_args': 'use_goma=true', |
148 'gyp_defines': 'goma=1', | 151 'gyp_defines': 'goma=1', |
149 }, | 152 }, |
150 'phase_1': { | 153 'phase_1': { |
151 'gn_args': 'phase=1', | 154 'gn_args': 'phase=1', |
152 'gyp_args': 'phase=1', | 155 'gyp_args': 'phase=1', |
153 }, | 156 }, |
154 'phase_2': { | 157 'phase_2': { |
155 'gn_args': 'phase=2', | 158 'gn_args': 'phase=2', |
156 'gyp_args': 'phase=2', | 159 'gyp_args': 'phase=2', |
157 }, | 160 }, |
158 'rel': { | 161 'rel': { |
159 'gn_args': 'is_debug=false', | 162 'gn_args': 'is_debug=false', |
160 }, | 163 }, |
161 'debug': { | 164 'debug': { |
162 'gn_args': 'is_debug=true', | 165 'gn_args': 'is_debug=true', |
163 }, | 166 }, |
| 167 'memcheck': { |
| 168 'gn_args': 'rtc_use_memcheck=true', |
| 169 }, |
164 }, | 170 }, |
165 } | 171 } |
166 """ | 172 """ |
167 | 173 |
168 | 174 |
169 TEST_BAD_CONFIG = """\ | 175 TEST_BAD_CONFIG = """\ |
170 { | 176 { |
171 'configs': { | 177 'configs': { |
172 'gn_rel_bot_1': ['gn', 'rel', 'chrome_with_codecs'], | 178 'gn_rel_bot_1': ['gn', 'rel', 'chrome_with_codecs'], |
173 'gn_rel_bot_2': ['gn', 'rel', 'bad_nested_config'], | 179 'gn_rel_bot_2': ['gn', 'rel', 'bad_nested_config'], |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 '-c', 'gn_debug_goma', | 369 '-c', 'gn_debug_goma', |
364 '--swarming-targets-file', '/tmp/swarming_targets', | 370 '--swarming-targets-file', '/tmp/swarming_targets', |
365 '--isolate-map-file', | 371 '--isolate-map-file', |
366 '/fake_src/testing/buildbot/gn_isolate_map.pyl', | 372 '/fake_src/testing/buildbot/gn_isolate_map.pyl', |
367 '//out/Default'], mbw=mbw, ret=0) | 373 '//out/Default'], mbw=mbw, ret=0) |
368 self.assertIn('c:\\fake_src\\out\\Default\\cc_perftests.isolate', | 374 self.assertIn('c:\\fake_src\\out\\Default\\cc_perftests.isolate', |
369 mbw.files) | 375 mbw.files) |
370 self.assertIn('c:\\fake_src\\out\\Default\\cc_perftests.isolated.gen.json', | 376 self.assertIn('c:\\fake_src\\out\\Default\\cc_perftests.isolated.gen.json', |
371 mbw.files) | 377 mbw.files) |
372 | 378 |
| 379 def test_gn_gen_non_parallel_console_test_launcher(self): |
| 380 test_files = { |
| 381 '/tmp/swarming_targets': 'base_unittests\n', |
| 382 '/fake_src/testing/buildbot/gn_isolate_map.pyl': ( |
| 383 "{'base_unittests': {" |
| 384 " 'label': '//base:base_unittests'," |
| 385 " 'type': 'non_parallel_console_test_launcher'," |
| 386 "}}\n" |
| 387 ), |
| 388 '/fake_src/out/Default/base_unittests.runtime_deps': ( |
| 389 "base_unittests\n" |
| 390 ), |
| 391 } |
| 392 mbw = self.check(['gen', '-c', 'gn_debug_goma', '//out/Default', |
| 393 '--swarming-targets-file', '/tmp/swarming_targets', |
| 394 '--isolate-map-file', |
| 395 '/fake_src/testing/buildbot/gn_isolate_map.pyl'], |
| 396 files=test_files, ret=0) |
| 397 |
| 398 isolate_file = mbw.files['/fake_src/out/Default/base_unittests.isolate'] |
| 399 isolate_file_contents = ast.literal_eval(isolate_file) |
| 400 files = isolate_file_contents['variables']['files'] |
| 401 command = isolate_file_contents['variables']['command'] |
| 402 |
| 403 self.assertEqual(files, [ |
| 404 '../../testing/test_env.py', |
| 405 'base_unittests', |
| 406 ]) |
| 407 self.assertEqual(command, [ |
| 408 '../../testing/test_env.py', |
| 409 './base_unittests', |
| 410 '--', |
| 411 '--asan=0', |
| 412 '--msan=0', |
| 413 '--tsan=0', |
| 414 ]) |
| 415 |
| 416 def test_gn_isolate_windowed_test_launcher_linux(self): |
| 417 test_files = { |
| 418 '/tmp/swarming_targets': 'base_unittests\n', |
| 419 '/fake_src/testing/buildbot/gn_isolate_map.pyl': ( |
| 420 "{'base_unittests': {" |
| 421 " 'label': '//base:base_unittests'," |
| 422 " 'type': 'windowed_test_launcher'," |
| 423 "}}\n" |
| 424 ), |
| 425 '/fake_src/out/Default/base_unittests.runtime_deps': ( |
| 426 "base_unittests\n" |
| 427 "some_resource_file\n" |
| 428 ), |
| 429 } |
| 430 mbw = self.check(['gen', '-c', 'gn_debug_goma', '//out/Default', |
| 431 '--swarming-targets-file', '/tmp/swarming_targets', |
| 432 '--isolate-map-file', |
| 433 '/fake_src/testing/buildbot/gn_isolate_map.pyl'], |
| 434 files=test_files, ret=0) |
| 435 |
| 436 isolate_file = mbw.files['/fake_src/out/Default/base_unittests.isolate'] |
| 437 isolate_file_contents = ast.literal_eval(isolate_file) |
| 438 files = isolate_file_contents['variables']['files'] |
| 439 command = isolate_file_contents['variables']['command'] |
| 440 |
| 441 self.assertEqual(files, [ |
| 442 '../../testing/test_env.py', |
| 443 '../../testing/xvfb.py', |
| 444 '../../third_party/gtest-parallel/gtest-parallel', |
| 445 '../../third_party/gtest-parallel/gtest-parallel-wrapper.py', |
| 446 'base_unittests', |
| 447 'some_resource_file', |
| 448 'xdisplaycheck', |
| 449 ]) |
| 450 self.assertEqual(command, [ |
| 451 '../../testing/xvfb.py', |
| 452 '.', |
| 453 '../../third_party/gtest-parallel/gtest-parallel-wrapper.py', |
| 454 './base_unittests', |
| 455 '--', |
| 456 '--asan=0', |
| 457 '--msan=0', |
| 458 '--tsan=0', |
| 459 ]) |
| 460 |
| 461 def test_gn_gen_windowed_test_launcher_win(self): |
| 462 files = { |
| 463 '/tmp/swarming_targets': 'unittests\n', |
| 464 '/fake_src/testing/buildbot/gn_isolate_map.pyl': ( |
| 465 "{'unittests': {" |
| 466 " 'label': '//somewhere:unittests'," |
| 467 " 'type': 'windowed_test_launcher'," |
| 468 "}}\n" |
| 469 ), |
| 470 r'c:\fake_src\out\Default\unittests.exe.runtime_deps': ( |
| 471 "unittests.exe\n" |
| 472 "some_dependency\n" |
| 473 ), |
| 474 } |
| 475 mbw = self.fake_mbw(files=files, win32=True) |
| 476 self.check(['gen', |
| 477 '-c', 'gn_debug_goma', |
| 478 '--swarming-targets-file', '/tmp/swarming_targets', |
| 479 '--isolate-map-file', |
| 480 '/fake_src/testing/buildbot/gn_isolate_map.pyl', |
| 481 '//out/Default'], mbw=mbw, ret=0) |
| 482 |
| 483 isolate_file = mbw.files['c:\\fake_src\\out\\Default\\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 '../../third_party/gtest-parallel/gtest-parallel', |
| 491 '../../third_party/gtest-parallel/gtest-parallel-wrapper.py', |
| 492 'some_dependency', |
| 493 'unittests.exe', |
| 494 ]) |
| 495 self.assertEqual(command, [ |
| 496 '../../testing/test_env.py', |
| 497 '../../third_party/gtest-parallel/gtest-parallel-wrapper.py', |
| 498 r'.\unittests.exe', |
| 499 '--', |
| 500 '--asan=0', |
| 501 '--msan=0', |
| 502 '--tsan=0', |
| 503 ]) |
| 504 |
| 505 def test_gn_gen_console_test_launcher(self): |
| 506 test_files = { |
| 507 '/tmp/swarming_targets': 'base_unittests\n', |
| 508 '/fake_src/testing/buildbot/gn_isolate_map.pyl': ( |
| 509 "{'base_unittests': {" |
| 510 " 'label': '//base:base_unittests'," |
| 511 " 'type': 'console_test_launcher'," |
| 512 "}}\n" |
| 513 ), |
| 514 '/fake_src/out/Default/base_unittests.runtime_deps': ( |
| 515 "base_unittests\n" |
| 516 ), |
| 517 } |
| 518 mbw = self.check(['gen', '-c', 'gn_debug_goma', '//out/Default', |
| 519 '--swarming-targets-file', '/tmp/swarming_targets', |
| 520 '--isolate-map-file', |
| 521 '/fake_src/testing/buildbot/gn_isolate_map.pyl'], |
| 522 files=test_files, ret=0) |
| 523 |
| 524 isolate_file = mbw.files['/fake_src/out/Default/base_unittests.isolate'] |
| 525 isolate_file_contents = ast.literal_eval(isolate_file) |
| 526 files = isolate_file_contents['variables']['files'] |
| 527 command = isolate_file_contents['variables']['command'] |
| 528 |
| 529 self.assertEqual(files, [ |
| 530 '../../testing/test_env.py', |
| 531 '../../third_party/gtest-parallel/gtest-parallel', |
| 532 '../../third_party/gtest-parallel/gtest-parallel-wrapper.py', |
| 533 'base_unittests', |
| 534 ]) |
| 535 self.assertEqual(command, [ |
| 536 '../../testing/test_env.py', |
| 537 '../../third_party/gtest-parallel/gtest-parallel-wrapper.py', |
| 538 './base_unittests', |
| 539 '--', |
| 540 '--asan=0', |
| 541 '--msan=0', |
| 542 '--tsan=0', |
| 543 ]) |
| 544 |
| 545 def test_gn_isolate_console_test_launcher_memcheck(self): |
| 546 test_files = { |
| 547 '/tmp/swarming_targets': 'base_unittests\n', |
| 548 '/fake_src/testing/buildbot/gn_isolate_map.pyl': ( |
| 549 "{'base_unittests': {" |
| 550 " 'label': '//base:base_unittests'," |
| 551 " 'type': 'console_test_launcher'," |
| 552 "}}\n" |
| 553 ), |
| 554 '/fake_src/out/Release/base_unittests.runtime_deps': ( |
| 555 "base_unittests\n" |
| 556 "lots_of_memcheck_dependencies\n" |
| 557 "../../tools/valgrind-webrtc/webrtc_tests.sh\n" |
| 558 ), |
| 559 } |
| 560 mbw = self.check(['gen', '-c', 'gn_memcheck_bot', '//out/Release', |
| 561 '--swarming-targets-file', '/tmp/swarming_targets', |
| 562 '--isolate-map-file', |
| 563 '/fake_src/testing/buildbot/gn_isolate_map.pyl'], |
| 564 files=test_files, ret=0) |
| 565 |
| 566 isolate_file = mbw.files['/fake_src/out/Release/base_unittests.isolate'] |
| 567 isolate_file_contents = ast.literal_eval(isolate_file) |
| 568 files = isolate_file_contents['variables']['files'] |
| 569 command = isolate_file_contents['variables']['command'] |
| 570 |
| 571 self.assertEqual(files, [ |
| 572 '../../testing/test_env.py', |
| 573 '../../tools/valgrind-webrtc/webrtc_tests.sh', |
| 574 'base_unittests', |
| 575 'lots_of_memcheck_dependencies', |
| 576 ]) |
| 577 self.assertEqual(command, [ |
| 578 '../../testing/test_env.py', |
| 579 'bash', |
| 580 '../../tools/valgrind-webrtc/webrtc_tests.sh', |
| 581 '--tool', |
| 582 'memcheck', |
| 583 '--target', |
| 584 'Release', |
| 585 '--build-dir', |
| 586 '..', |
| 587 '--test', |
| 588 './base_unittests', |
| 589 '--', |
| 590 '--asan=0', |
| 591 '--msan=0', |
| 592 '--tsan=0', |
| 593 ]) |
373 | 594 |
374 def test_gn_isolate(self): | 595 def test_gn_isolate(self): |
375 files = { | 596 files = { |
376 '/fake_src/out/Default/toolchain.ninja': "", | 597 '/fake_src/out/Default/toolchain.ninja': "", |
377 '/fake_src/testing/buildbot/gn_isolate_map.pyl': ( | 598 '/fake_src/testing/buildbot/gn_isolate_map.pyl': ( |
378 "{'base_unittests': {" | 599 "{'base_unittests': {" |
379 " 'label': '//base:base_unittests'," | 600 " 'label': '//base:base_unittests'," |
380 " 'type': 'non_parallel_console_test_launcher'," | 601 " 'type': 'non_parallel_console_test_launcher'," |
381 " 'args': []," | |
382 "}}\n" | 602 "}}\n" |
383 ), | 603 ), |
384 '/fake_src/out/Default/base_unittests.runtime_deps': ( | 604 '/fake_src/out/Default/base_unittests.runtime_deps': ( |
385 "base_unittests\n" | 605 "base_unittests\n" |
386 ), | 606 ), |
387 } | 607 } |
388 self.check(['isolate', '-c', 'gn_debug_goma', '//out/Default', | 608 self.check(['isolate', '-c', 'gn_debug_goma', '//out/Default', |
389 'base_unittests'], files=files, ret=0) | 609 'base_unittests'], files=files, ret=0) |
390 | 610 |
391 # test running isolate on an existing build_dir | 611 # test running isolate on an existing build_dir |
392 files['/fake_src/out/Default/args.gn'] = 'is_debug = True\n' | 612 files['/fake_src/out/Default/args.gn'] = 'is_debug = True\n' |
393 self.check(['isolate', '//out/Default', 'base_unittests'], | 613 self.check(['isolate', '//out/Default', 'base_unittests'], |
394 files=files, ret=0) | 614 files=files, ret=0) |
395 | |
396 files['/fake_src/out/Default/mb_type'] = 'gn\n' | 615 files['/fake_src/out/Default/mb_type'] = 'gn\n' |
397 self.check(['isolate', '//out/Default', 'base_unittests'], | 616 self.check(['isolate', '//out/Default', 'base_unittests'], |
398 files=files, ret=0) | 617 files=files, ret=0) |
399 | 618 |
400 def test_gn_run(self): | 619 def test_gn_run(self): |
401 files = { | 620 files = { |
402 '/fake_src/testing/buildbot/gn_isolate_map.pyl': ( | 621 '/fake_src/testing/buildbot/gn_isolate_map.pyl': ( |
403 "{'base_unittests': {" | 622 "{'base_unittests': {" |
404 " 'label': '//base:base_unittests'," | 623 " 'label': '//base:base_unittests'," |
405 " 'type': 'windowed_test_launcher'," | 624 " 'type': 'windowed_test_launcher'," |
406 " 'args': []," | |
407 "}}\n" | 625 "}}\n" |
408 ), | 626 ), |
409 '/fake_src/out/Default/base_unittests.runtime_deps': ( | 627 '/fake_src/out/Default/base_unittests.runtime_deps': ( |
410 "base_unittests\n" | 628 "base_unittests\n" |
411 ), | 629 ), |
412 } | 630 } |
413 self.check(['run', '-c', 'gn_debug_goma', '//out/Default', | 631 self.check(['run', '-c', 'gn_debug_goma', '//out/Default', |
414 'base_unittests'], files=files, ret=0) | 632 'base_unittests'], files=files, ret=0) |
415 | 633 |
416 def test_gn_lookup(self): | 634 def test_gn_lookup(self): |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 self.check(['lookup', '-c', 'fake_config'], mbw=mbw, | 750 self.check(['lookup', '-c', 'fake_config'], mbw=mbw, |
533 ret=0, | 751 ret=0, |
534 out=("GYP_DEFINES='foo=bar baz=1'\n" | 752 out=("GYP_DEFINES='foo=bar baz=1'\n" |
535 "GYP_LINK_CONCURRENCY=1\n" | 753 "GYP_LINK_CONCURRENCY=1\n" |
536 "LLVM_FORCE_HEAD_REVISION=1\n" | 754 "LLVM_FORCE_HEAD_REVISION=1\n" |
537 "python build/gyp_chromium -G output_dir=_path_\n")) | 755 "python build/gyp_chromium -G output_dir=_path_\n")) |
538 | 756 |
539 | 757 |
540 if __name__ == '__main__': | 758 if __name__ == '__main__': |
541 unittest.main() | 759 unittest.main() |
OLD | NEW |