| 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 ast |
| 13 import json | 13 import json |
| 14 import StringIO | 14 import StringIO |
| 15 import os | 15 import os |
| 16 import sys | 16 import sys |
| 17 import unittest | 17 import unittest |
| 18 | 18 |
| 19 import mb | 19 import mb |
| 20 | 20 |
| 21 | 21 |
| 22 class FakeMBW(mb.MetaBuildWrapper): | 22 class FakeMBW(mb.MetaBuildWrapper): |
| 23 def __init__(self, win32=False): | 23 def __init__(self, win32=False): |
| 24 super(FakeMBW, self).__init__() | 24 super(FakeMBW, self).__init__() |
| 25 | 25 |
| 26 # Override vars for test portability. | 26 # Override vars for test portability. |
| 27 if win32: | 27 if win32: |
| 28 self.src_dir = 'c:\\fake_src' | 28 self.src_dir = 'c:\\fake_src' |
| 29 self.default_config = 'c:\\fake_src\\tools-webrtc\\mb\\mb_config.pyl' | 29 self.default_config = 'c:\\fake_src\\tools_webrtc\\mb\\mb_config.pyl' |
| 30 self.default_isolate_map = ('c:\\fake_src\\testing\\buildbot\\' | 30 self.default_isolate_map = ('c:\\fake_src\\testing\\buildbot\\' |
| 31 'gn_isolate_map.pyl') | 31 'gn_isolate_map.pyl') |
| 32 self.platform = 'win32' | 32 self.platform = 'win32' |
| 33 self.executable = 'c:\\python\\python.exe' | 33 self.executable = 'c:\\python\\python.exe' |
| 34 self.sep = '\\' | 34 self.sep = '\\' |
| 35 else: | 35 else: |
| 36 self.src_dir = '/fake_src' | 36 self.src_dir = '/fake_src' |
| 37 self.default_config = '/fake_src/tools-webrtc/mb/mb_config.pyl' | 37 self.default_config = '/fake_src/tools_webrtc/mb/mb_config.pyl' |
| 38 self.default_isolate_map = '/fake_src/testing/buildbot/gn_isolate_map.pyl' | 38 self.default_isolate_map = '/fake_src/testing/buildbot/gn_isolate_map.pyl' |
| 39 self.executable = '/usr/bin/python' | 39 self.executable = '/usr/bin/python' |
| 40 self.platform = 'linux2' | 40 self.platform = 'linux2' |
| 41 self.sep = '/' | 41 self.sep = '/' |
| 42 | 42 |
| 43 self.files = {} | 43 self.files = {} |
| 44 self.calls = [] | 44 self.calls = [] |
| 45 self.cmds = [] | 45 self.cmds = [] |
| 46 self.cross_compile = None | 46 self.cross_compile = None |
| 47 self.out = '' | 47 self.out = '' |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 files=test_files, ret=0) | 435 files=test_files, ret=0) |
| 436 | 436 |
| 437 isolate_file = mbw.files['/fake_src/out/Default/base_unittests.isolate'] | 437 isolate_file = mbw.files['/fake_src/out/Default/base_unittests.isolate'] |
| 438 isolate_file_contents = ast.literal_eval(isolate_file) | 438 isolate_file_contents = ast.literal_eval(isolate_file) |
| 439 files = isolate_file_contents['variables']['files'] | 439 files = isolate_file_contents['variables']['files'] |
| 440 command = isolate_file_contents['variables']['command'] | 440 command = isolate_file_contents['variables']['command'] |
| 441 | 441 |
| 442 self.assertEqual(files, [ | 442 self.assertEqual(files, [ |
| 443 '../../testing/test_env.py', | 443 '../../testing/test_env.py', |
| 444 '../../third_party/gtest-parallel/gtest-parallel', | 444 '../../third_party/gtest-parallel/gtest-parallel', |
| 445 '../../tools-webrtc/gtest-parallel-wrapper.py', | 445 '../../tools_webrtc/gtest-parallel-wrapper.py', |
| 446 'base_unittests', | 446 'base_unittests', |
| 447 ]) | 447 ]) |
| 448 self.assertEqual(command, [ | 448 self.assertEqual(command, [ |
| 449 '../../testing/test_env.py', | 449 '../../testing/test_env.py', |
| 450 '../../tools-webrtc/gtest-parallel-wrapper.py', | 450 '../../tools_webrtc/gtest-parallel-wrapper.py', |
| 451 '--output_dir=${ISOLATED_OUTDIR}/test_logs', | 451 '--output_dir=${ISOLATED_OUTDIR}/test_logs', |
| 452 '--gtest_color=no', | 452 '--gtest_color=no', |
| 453 '--timeout=900', | 453 '--timeout=900', |
| 454 '--retry_failed=3', | 454 '--retry_failed=3', |
| 455 './base_unittests', | 455 './base_unittests', |
| 456 '--workers=1', | 456 '--workers=1', |
| 457 '--', | 457 '--', |
| 458 '--asan=0', | 458 '--asan=0', |
| 459 '--lsan=0', | 459 '--lsan=0', |
| 460 '--msan=0', | 460 '--msan=0', |
| (...skipping 22 matching lines...) Expand all Loading... |
| 483 | 483 |
| 484 isolate_file = mbw.files['/fake_src/out/Default/base_unittests.isolate'] | 484 isolate_file = mbw.files['/fake_src/out/Default/base_unittests.isolate'] |
| 485 isolate_file_contents = ast.literal_eval(isolate_file) | 485 isolate_file_contents = ast.literal_eval(isolate_file) |
| 486 files = isolate_file_contents['variables']['files'] | 486 files = isolate_file_contents['variables']['files'] |
| 487 command = isolate_file_contents['variables']['command'] | 487 command = isolate_file_contents['variables']['command'] |
| 488 | 488 |
| 489 self.assertEqual(files, [ | 489 self.assertEqual(files, [ |
| 490 '../../testing/test_env.py', | 490 '../../testing/test_env.py', |
| 491 '../../testing/xvfb.py', | 491 '../../testing/xvfb.py', |
| 492 '../../third_party/gtest-parallel/gtest-parallel', | 492 '../../third_party/gtest-parallel/gtest-parallel', |
| 493 '../../tools-webrtc/gtest-parallel-wrapper.py', | 493 '../../tools_webrtc/gtest-parallel-wrapper.py', |
| 494 'base_unittests', | 494 'base_unittests', |
| 495 'some_resource_file', | 495 'some_resource_file', |
| 496 ]) | 496 ]) |
| 497 self.assertEqual(command, [ | 497 self.assertEqual(command, [ |
| 498 '../../testing/xvfb.py', | 498 '../../testing/xvfb.py', |
| 499 '../../tools-webrtc/gtest-parallel-wrapper.py', | 499 '../../tools_webrtc/gtest-parallel-wrapper.py', |
| 500 '--output_dir=${ISOLATED_OUTDIR}/test_logs', | 500 '--output_dir=${ISOLATED_OUTDIR}/test_logs', |
| 501 '--gtest_color=no', | 501 '--gtest_color=no', |
| 502 '--timeout=900', | 502 '--timeout=900', |
| 503 '--retry_failed=3', | 503 '--retry_failed=3', |
| 504 './base_unittests', | 504 './base_unittests', |
| 505 '--', | 505 '--', |
| 506 '--asan=0', | 506 '--asan=0', |
| 507 '--lsan=0', | 507 '--lsan=0', |
| 508 '--msan=0', | 508 '--msan=0', |
| 509 '--tsan=0', | 509 '--tsan=0', |
| (...skipping 22 matching lines...) Expand all Loading... |
| 532 '//out/Default'], mbw=mbw, ret=0) | 532 '//out/Default'], mbw=mbw, ret=0) |
| 533 | 533 |
| 534 isolate_file = mbw.files['c:\\fake_src\\out\\Default\\unittests.isolate'] | 534 isolate_file = mbw.files['c:\\fake_src\\out\\Default\\unittests.isolate'] |
| 535 isolate_file_contents = ast.literal_eval(isolate_file) | 535 isolate_file_contents = ast.literal_eval(isolate_file) |
| 536 files = isolate_file_contents['variables']['files'] | 536 files = isolate_file_contents['variables']['files'] |
| 537 command = isolate_file_contents['variables']['command'] | 537 command = isolate_file_contents['variables']['command'] |
| 538 | 538 |
| 539 self.assertEqual(files, [ | 539 self.assertEqual(files, [ |
| 540 '../../testing/test_env.py', | 540 '../../testing/test_env.py', |
| 541 '../../third_party/gtest-parallel/gtest-parallel', | 541 '../../third_party/gtest-parallel/gtest-parallel', |
| 542 '../../tools-webrtc/gtest-parallel-wrapper.py', | 542 '../../tools_webrtc/gtest-parallel-wrapper.py', |
| 543 'some_dependency', | 543 'some_dependency', |
| 544 'unittests.exe', | 544 'unittests.exe', |
| 545 ]) | 545 ]) |
| 546 self.assertEqual(command, [ | 546 self.assertEqual(command, [ |
| 547 '../../testing/test_env.py', | 547 '../../testing/test_env.py', |
| 548 '../../tools-webrtc/gtest-parallel-wrapper.py', | 548 '../../tools_webrtc/gtest-parallel-wrapper.py', |
| 549 '--output_dir=${ISOLATED_OUTDIR}\\test_logs', | 549 '--output_dir=${ISOLATED_OUTDIR}\\test_logs', |
| 550 '--gtest_color=no', | 550 '--gtest_color=no', |
| 551 '--timeout=900', | 551 '--timeout=900', |
| 552 '--retry_failed=3', | 552 '--retry_failed=3', |
| 553 r'.\unittests.exe', | 553 r'.\unittests.exe', |
| 554 '--', | 554 '--', |
| 555 '--asan=0', | 555 '--asan=0', |
| 556 '--lsan=0', | 556 '--lsan=0', |
| 557 '--msan=0', | 557 '--msan=0', |
| 558 '--tsan=0', | 558 '--tsan=0', |
| (...skipping 19 matching lines...) Expand all Loading... |
| 578 files=test_files, ret=0) | 578 files=test_files, ret=0) |
| 579 | 579 |
| 580 isolate_file = mbw.files['/fake_src/out/Default/base_unittests.isolate'] | 580 isolate_file = mbw.files['/fake_src/out/Default/base_unittests.isolate'] |
| 581 isolate_file_contents = ast.literal_eval(isolate_file) | 581 isolate_file_contents = ast.literal_eval(isolate_file) |
| 582 files = isolate_file_contents['variables']['files'] | 582 files = isolate_file_contents['variables']['files'] |
| 583 command = isolate_file_contents['variables']['command'] | 583 command = isolate_file_contents['variables']['command'] |
| 584 | 584 |
| 585 self.assertEqual(files, [ | 585 self.assertEqual(files, [ |
| 586 '../../testing/test_env.py', | 586 '../../testing/test_env.py', |
| 587 '../../third_party/gtest-parallel/gtest-parallel', | 587 '../../third_party/gtest-parallel/gtest-parallel', |
| 588 '../../tools-webrtc/gtest-parallel-wrapper.py', | 588 '../../tools_webrtc/gtest-parallel-wrapper.py', |
| 589 'base_unittests', | 589 'base_unittests', |
| 590 ]) | 590 ]) |
| 591 self.assertEqual(command, [ | 591 self.assertEqual(command, [ |
| 592 '../../testing/test_env.py', | 592 '../../testing/test_env.py', |
| 593 '../../tools-webrtc/gtest-parallel-wrapper.py', | 593 '../../tools_webrtc/gtest-parallel-wrapper.py', |
| 594 '--output_dir=${ISOLATED_OUTDIR}/test_logs', | 594 '--output_dir=${ISOLATED_OUTDIR}/test_logs', |
| 595 '--gtest_color=no', | 595 '--gtest_color=no', |
| 596 '--timeout=900', | 596 '--timeout=900', |
| 597 '--retry_failed=3', | 597 '--retry_failed=3', |
| 598 './base_unittests', | 598 './base_unittests', |
| 599 '--', | 599 '--', |
| 600 '--asan=0', | 600 '--asan=0', |
| 601 '--lsan=0', | 601 '--lsan=0', |
| 602 '--msan=0', | 602 '--msan=0', |
| 603 '--tsan=0', | 603 '--tsan=0', |
| 604 ]) | 604 ]) |
| 605 | 605 |
| 606 def test_gn_isolate_console_test_launcher_memcheck(self): | 606 def test_gn_isolate_console_test_launcher_memcheck(self): |
| 607 test_files = { | 607 test_files = { |
| 608 '/tmp/swarming_targets': 'base_unittests\n', | 608 '/tmp/swarming_targets': 'base_unittests\n', |
| 609 '/fake_src/testing/buildbot/gn_isolate_map.pyl': ( | 609 '/fake_src/testing/buildbot/gn_isolate_map.pyl': ( |
| 610 "{'base_unittests': {" | 610 "{'base_unittests': {" |
| 611 " 'label': '//base:base_unittests'," | 611 " 'label': '//base:base_unittests'," |
| 612 " 'type': 'console_test_launcher'," | 612 " 'type': 'console_test_launcher'," |
| 613 "}}\n" | 613 "}}\n" |
| 614 ), | 614 ), |
| 615 '/fake_src/out/Release/base_unittests.runtime_deps': ( | 615 '/fake_src/out/Release/base_unittests.runtime_deps': ( |
| 616 "base_unittests\n" | 616 "base_unittests\n" |
| 617 "lots_of_memcheck_dependencies\n" | 617 "lots_of_memcheck_dependencies\n" |
| 618 "../../tools-webrtc/valgrind/webrtc_tests.sh\n" | 618 "../../tools_webrtc/valgrind/webrtc_tests.sh\n" |
| 619 ), | 619 ), |
| 620 } | 620 } |
| 621 mbw = self.check(['gen', '-c', 'gn_memcheck_bot', '//out/Release', | 621 mbw = self.check(['gen', '-c', 'gn_memcheck_bot', '//out/Release', |
| 622 '--swarming-targets-file', '/tmp/swarming_targets', | 622 '--swarming-targets-file', '/tmp/swarming_targets', |
| 623 '--isolate-map-file', | 623 '--isolate-map-file', |
| 624 '/fake_src/testing/buildbot/gn_isolate_map.pyl'], | 624 '/fake_src/testing/buildbot/gn_isolate_map.pyl'], |
| 625 files=test_files, ret=0) | 625 files=test_files, ret=0) |
| 626 | 626 |
| 627 isolate_file = mbw.files['/fake_src/out/Release/base_unittests.isolate'] | 627 isolate_file = mbw.files['/fake_src/out/Release/base_unittests.isolate'] |
| 628 isolate_file_contents = ast.literal_eval(isolate_file) | 628 isolate_file_contents = ast.literal_eval(isolate_file) |
| 629 files = isolate_file_contents['variables']['files'] | 629 files = isolate_file_contents['variables']['files'] |
| 630 command = isolate_file_contents['variables']['command'] | 630 command = isolate_file_contents['variables']['command'] |
| 631 | 631 |
| 632 self.assertEqual(files, [ | 632 self.assertEqual(files, [ |
| 633 '../../testing/test_env.py', | 633 '../../testing/test_env.py', |
| 634 '../../tools-webrtc/valgrind/webrtc_tests.sh', | 634 '../../tools_webrtc/valgrind/webrtc_tests.sh', |
| 635 'base_unittests', | 635 'base_unittests', |
| 636 'lots_of_memcheck_dependencies', | 636 'lots_of_memcheck_dependencies', |
| 637 ]) | 637 ]) |
| 638 self.assertEqual(command, [ | 638 self.assertEqual(command, [ |
| 639 '../../testing/test_env.py', | 639 '../../testing/test_env.py', |
| 640 'bash', | 640 'bash', |
| 641 '../../tools-webrtc/valgrind/webrtc_tests.sh', | 641 '../../tools_webrtc/valgrind/webrtc_tests.sh', |
| 642 '--tool', | 642 '--tool', |
| 643 'memcheck', | 643 'memcheck', |
| 644 '--target', | 644 '--target', |
| 645 'Release', | 645 'Release', |
| 646 '--build-dir', | 646 '--build-dir', |
| 647 '..', | 647 '..', |
| 648 '--test', | 648 '--test', |
| 649 './base_unittests', | 649 './base_unittests', |
| 650 '--', | 650 '--', |
| 651 '--asan=0', | 651 '--asan=0', |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 784 self.check(['lookup', '-c', 'fake_config'], mbw=mbw, | 784 self.check(['lookup', '-c', 'fake_config'], mbw=mbw, |
| 785 ret=0, | 785 ret=0, |
| 786 out=("GYP_DEFINES='foo=bar baz=1'\n" | 786 out=("GYP_DEFINES='foo=bar baz=1'\n" |
| 787 "GYP_LINK_CONCURRENCY=1\n" | 787 "GYP_LINK_CONCURRENCY=1\n" |
| 788 "LLVM_FORCE_HEAD_REVISION=1\n" | 788 "LLVM_FORCE_HEAD_REVISION=1\n" |
| 789 "python build/gyp_chromium -G output_dir=_path_\n")) | 789 "python build/gyp_chromium -G output_dir=_path_\n")) |
| 790 | 790 |
| 791 | 791 |
| 792 if __name__ == '__main__': | 792 if __name__ == '__main__': |
| 793 unittest.main() | 793 unittest.main() |
| OLD | NEW |