OLD | NEW |
1 #! -*- python -*- | 1 #! -*- python -*- |
2 # Copyright (c) 2012 The Native Client Authors. All rights reserved. | 2 # Copyright (c) 2012 The Native Client Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 import atexit | 6 import atexit |
7 import os | 7 import os |
8 import platform | 8 import platform |
9 import re | 9 import re |
10 import subprocess | 10 import subprocess |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 BitFromArgument(env, 'x86_64_zero_based_sandbox', default=False, | 345 BitFromArgument(env, 'x86_64_zero_based_sandbox', default=False, |
346 desc='Use the zero-address-based x86-64 sandbox model instead of ' | 346 desc='Use the zero-address-based x86-64 sandbox model instead of ' |
347 'the r15-based model.') | 347 'the r15-based model.') |
348 | 348 |
349 BitFromArgument(env, 'android', default=False, | 349 BitFromArgument(env, 'android', default=False, |
350 desc='Build for Android target') | 350 desc='Build for Android target') |
351 | 351 |
352 BitFromArgument(env, 'arm_hard_float', default=False, | 352 BitFromArgument(env, 'arm_hard_float', default=False, |
353 desc='Build for hard float ARM ABI') | 353 desc='Build for hard float ARM ABI') |
354 | 354 |
| 355 BitFromArgument(env, 'skip_nonstable_bitcode', default=False, |
| 356 desc='Skip tests involving non-stable bitcode') |
| 357 |
355 ######################################################################### | 358 ######################################################################### |
356 # EXPERIMENTAL | 359 # EXPERIMENTAL |
357 # This is for generating a testing library for use within private test | 360 # This is for generating a testing library for use within private test |
358 # enuminsts, where we want to compare and test different validators. | 361 # enuminsts, where we want to compare and test different validators. |
359 # | 362 # |
360 BitFromArgument(env, 'ncval_testing', default=False, | 363 BitFromArgument(env, 'ncval_testing', default=False, |
361 desc='EXPERIMENTAL: Compile validator code for testing within enuminsts') | 364 desc='EXPERIMENTAL: Compile validator code for testing within enuminsts') |
362 | 365 |
363 # PNaCl sanity checks | 366 # PNaCl sanity checks |
364 if ((env.Bit('pnacl_generate_pexe') or env.Bit('use_sandboxed_translator')) | 367 if ((env.Bit('pnacl_generate_pexe') or env.Bit('use_sandboxed_translator')) |
(...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1224 | 1227 |
1225 def HasSuffix(item, suffix): | 1228 def HasSuffix(item, suffix): |
1226 if isinstance(item, str): | 1229 if isinstance(item, str): |
1227 return item.endswith(suffix) | 1230 return item.endswith(suffix) |
1228 elif hasattr(item, '__getitem__'): | 1231 elif hasattr(item, '__getitem__'): |
1229 return HasSuffix(item[0], suffix) | 1232 return HasSuffix(item[0], suffix) |
1230 else: | 1233 else: |
1231 return item.path.endswith(suffix) | 1234 return item.path.endswith(suffix) |
1232 | 1235 |
1233 | 1236 |
| 1237 def StripSuffix(string, suffix): |
| 1238 assert string.endswith(suffix) |
| 1239 return string[:-len(suffix)] |
| 1240 |
| 1241 |
1234 def DualLibrary(env, lib_name, *args, **kwargs): | 1242 def DualLibrary(env, lib_name, *args, **kwargs): |
1235 """Builder to build both .a and _shared.a library in one step. | 1243 """Builder to build both .a and _shared.a library in one step. |
1236 | 1244 |
1237 Args: | 1245 Args: |
1238 env: Environment in which we were called. | 1246 env: Environment in which we were called. |
1239 lib_name: Library name. | 1247 lib_name: Library name. |
1240 args: Positional arguments. | 1248 args: Positional arguments. |
1241 kwargs: Keyword arguments. | 1249 kwargs: Keyword arguments. |
1242 """ | 1250 """ |
1243 static_objs = [i for i in Flatten(args[0]) if not HasSuffix(i, '.os')] | 1251 static_objs = [i for i in Flatten(args[0]) if not HasSuffix(i, '.os')] |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1553 def ShouldUseVerboseOptions(env, extra): | 1561 def ShouldUseVerboseOptions(env, extra): |
1554 """ Heuristic for setting up Verbose NACLLOG options. """ | 1562 """ Heuristic for setting up Verbose NACLLOG options. """ |
1555 return ('process_output_single' in extra or | 1563 return ('process_output_single' in extra or |
1556 'log_golden' in extra) | 1564 'log_golden' in extra) |
1557 | 1565 |
1558 pre_base_env.AddMethod(ShouldUseVerboseOptions) | 1566 pre_base_env.AddMethod(ShouldUseVerboseOptions) |
1559 | 1567 |
1560 | 1568 |
1561 DeclareBit('tests_use_irt', 'Non-browser tests also load the IRT image', False) | 1569 DeclareBit('tests_use_irt', 'Non-browser tests also load the IRT image', False) |
1562 | 1570 |
1563 # Translate the given pexe. | 1571 # Bit to be set by individual test/nacl.scons files that need to opt out. |
1564 def GetTranslatedNexe(env, pexe): | 1572 DeclareBit('nonstable_bitcode', 'Tests use non-stable bitcode features', False) |
| 1573 |
| 1574 |
| 1575 def GetFinalizedPexe(env, pexe): |
| 1576 """ Prep and finalize the ABI for a given pexe if needed. |
| 1577 """ |
| 1578 if not env.Bit('pnacl_generate_pexe') or env.Bit('nonstable_bitcode'): |
| 1579 return pexe |
| 1580 |
| 1581 # We can remove this once we move all CommandSelLdrTestNacl to a nacl.scons |
| 1582 # file instead. There are currently some canned nexe tests in build.scons. |
| 1583 if env['NACL_BUILD_FAMILY'] == 'TRUSTED': |
| 1584 return pexe |
| 1585 |
| 1586 # Otherwise, finalize during the build step, since there is no finalize tool |
| 1587 # that can run on triggered bots such as the ARM HW bots. |
1565 pexe_name = pexe.abspath | 1588 pexe_name = pexe.abspath |
1566 nexe_name = pexe_name[:pexe_name.index('.pexe')] + '.nexe' | 1589 final_name = StripSuffix(pexe_name, '.nonfinal.pexe') + '.final.pexe' |
1567 # Make sure the pexe doesn't get removed by the fake builders when | 1590 # Make sure the pexe doesn't get removed by the fake builders when |
1568 # built_elsewhere=1 | 1591 # built_elsewhere=1 |
1569 env.Precious(pexe) | 1592 env.Precious(pexe) |
1570 node = env.Command(target=nexe_name, source=[pexe_name], | 1593 node = env.Command(target=final_name, source=[pexe_name], |
1571 action=[Action('${TRANSLATECOM}', '${TRANSLATECOMSTR}')]) | 1594 action=[Action('${PNACLFINALIZECOM}', |
| 1595 '${PNACLFINALIZECOMSTR}')]) |
1572 assert len(node) == 1, node | 1596 assert len(node) == 1, node |
1573 return node[0] | 1597 return node[0] |
1574 | 1598 |
1575 pre_base_env.AddMethod(GetTranslatedNexe) | |
1576 | 1599 |
| 1600 # Translate the given pexe. |
| 1601 def GetTranslatedNexe(env, pexe): |
| 1602 # First finalize the pexe. |
| 1603 pexe = GetFinalizedPexe(env, pexe) |
1577 | 1604 |
1578 def ShouldTranslateToNexe(env, pexe): | 1605 # Then check if we need to translate. |
1579 """ Determine when we need to translate a Pexe to a Nexe. | |
1580 """ | |
1581 # Check if we started with a pexe, so there is actually a translation step. | 1606 # Check if we started with a pexe, so there is actually a translation step. |
1582 if not env.Bit('pnacl_generate_pexe'): | 1607 if not env.Bit('pnacl_generate_pexe'): |
1583 return False | 1608 return pexe |
1584 | 1609 |
1585 # There is no bitcode for trusted code. | 1610 # We can remove this once we move all CommandSelLdrTestNacl to a nacl.scons |
| 1611 # file instead. There are currently some canned nexe tests in build.scons. |
1586 if env['NACL_BUILD_FAMILY'] == 'TRUSTED': | 1612 if env['NACL_BUILD_FAMILY'] == 'TRUSTED': |
1587 return False | 1613 return pexe |
1588 | 1614 |
1589 # Often there is a build step (do_not_run_tests=1) and a test step | 1615 # Often there is a build step (do_not_run_tests=1) and a test step |
1590 # (which is run with -j1). Normally we want to translate in the build step | 1616 # (which is run with -j1). Normally we want to translate in the build step |
1591 # so we can translate in parallel. However when we do sandboxed translation | 1617 # so we can translate in parallel. However when we do sandboxed translation |
1592 # on arm hw, we do the build step on x86 and translation on arm, so we have | 1618 # on arm hw, we do the build step on x86 and translation on arm, so we have |
1593 # to force the translation to be done in the test step. Hence, | 1619 # to force the translation to be done in the test step. Hence, |
1594 # we check the bit 'translate_in_build_step' / check if we are | 1620 # we check the bit 'translate_in_build_step' / check if we are |
1595 # in the test step. | 1621 # in the test step. |
1596 return ( | 1622 if not env.Bit('translate_in_build_step') and env.Bit('do_not_run_tests'): |
1597 env.Bit('translate_in_build_step') or not env.Bit('do_not_run_tests')) | 1623 return pexe |
1598 | 1624 |
1599 pre_base_env.AddMethod(ShouldTranslateToNexe) | 1625 pexe_name = pexe.abspath |
| 1626 # Tidy up the suffix (remove the .final.pexe or .nonfinal.pexe), |
| 1627 # depending on whether or not the pexe was finalized. |
| 1628 suffix_to_strip = '.final.pexe' |
| 1629 if not pexe_name.endswith(suffix_to_strip): |
| 1630 suffix_to_strip = '.nonfinal.pexe' |
| 1631 nexe_name = StripSuffix(pexe_name, suffix_to_strip) + '.nexe' |
| 1632 # Make sure the pexe doesn't get removed by the fake builders when |
| 1633 # built_elsewhere=1 |
| 1634 env.Precious(pexe) |
| 1635 node = env.Command(target=nexe_name, source=[pexe_name], |
| 1636 action=[Action('${TRANSLATECOM}', '${TRANSLATECOMSTR}')]) |
| 1637 assert len(node) == 1, node |
| 1638 return node[0] |
| 1639 |
| 1640 pre_base_env.AddMethod(GetTranslatedNexe) |
1600 | 1641 |
1601 | 1642 |
1602 def CommandTestFileDumpCheck(env, | 1643 def CommandTestFileDumpCheck(env, |
1603 name, | 1644 name, |
1604 target, | 1645 target, |
1605 check_file, | 1646 check_file, |
1606 objdump_flags): | 1647 objdump_flags): |
1607 """Create a test that disassembles a binary (|target|) and checks for | 1648 """Create a test that disassembles a binary (|target|) and checks for |
1608 patterns in the |check_file|. Disassembly is done using |objdump_flags|. | 1649 patterns in the |check_file|. Disassembly is done using |objdump_flags|. |
1609 """ | 1650 """ |
1610 | 1651 |
1611 # Do not try to run OBJDUMP if 'built_elsewhere', since that *might* mean | 1652 # Do not try to run OBJDUMP if 'built_elsewhere', since that *might* mean |
1612 # that a toolchain is not even present. E.g., the arm hw buildbots do | 1653 # that a toolchain is not even present. E.g., the arm hw buildbots do |
1613 # not have the pnacl toolchain. We should be able to look for the host | 1654 # not have the pnacl toolchain. We should be able to look for the host |
1614 # ARM objdump though... a TODO(jvoung) for when there is time. | 1655 # ARM objdump though... a TODO(jvoung) for when there is time. |
1615 if env.Bit('built_elsewhere'): | 1656 if env.Bit('built_elsewhere'): |
1616 return [] | 1657 return [] |
1617 if env.ShouldTranslateToNexe(target): | 1658 target = env.GetTranslatedNexe(target) |
1618 target_obj = env.GetTranslatedNexe(target) | |
1619 else: | |
1620 target_obj = target | |
1621 return env.CommandTestFileCheck(name, | 1659 return env.CommandTestFileCheck(name, |
1622 ['${OBJDUMP}', objdump_flags, target_obj], | 1660 ['${OBJDUMP}', objdump_flags, target], |
1623 check_file) | 1661 check_file) |
1624 | 1662 |
1625 pre_base_env.AddMethod(CommandTestFileDumpCheck) | 1663 pre_base_env.AddMethod(CommandTestFileDumpCheck) |
1626 | 1664 |
1627 | 1665 |
1628 def CommandTestFileCheck(env, name, cmd, check_file): | 1666 def CommandTestFileCheck(env, name, cmd, check_file): |
1629 """Create a test that runs a |cmd| (array of strings), | 1667 """Create a test that runs a |cmd| (array of strings), |
1630 which is expected to print to stdout. The results | 1668 which is expected to print to stdout. The results |
1631 of stdout will then be piped to the file_check.py tool which | 1669 of stdout will then be piped to the file_check.py tool which |
1632 will search for the regexes specified in |check_file|. """ | 1670 will search for the regexes specified in |check_file|. """ |
(...skipping 20 matching lines...) Expand all Loading... |
1653 # e.g., [ 'python', 'time_check.py', '--' ] | 1691 # e.g., [ 'python', 'time_check.py', '--' ] |
1654 **extra): | 1692 **extra): |
1655 # Disable all sel_ldr tests for windows under coverage. | 1693 # Disable all sel_ldr tests for windows under coverage. |
1656 # Currently several .S files block sel_ldr from being instrumented. | 1694 # Currently several .S files block sel_ldr from being instrumented. |
1657 # See http://code.google.com/p/nativeclient/issues/detail?id=831 | 1695 # See http://code.google.com/p/nativeclient/issues/detail?id=831 |
1658 if ('TRUSTED_ENV' in env and | 1696 if ('TRUSTED_ENV' in env and |
1659 env['TRUSTED_ENV'].Bit('coverage_enabled') and | 1697 env['TRUSTED_ENV'].Bit('coverage_enabled') and |
1660 env['TRUSTED_ENV'].Bit('windows')): | 1698 env['TRUSTED_ENV'].Bit('windows')): |
1661 return [] | 1699 return [] |
1662 | 1700 |
1663 if env.ShouldTranslateToNexe(nexe): | 1701 # The nexe might be a pexe that needs finalization, and translation. |
1664 # The nexe is actually a pexe. Translate it before we run it. | 1702 nexe = env.GetTranslatedNexe(nexe) |
1665 nexe = env.GetTranslatedNexe(nexe) | 1703 |
1666 command = [nexe] | 1704 command = [nexe] |
1667 if args is not None: | 1705 if args is not None: |
1668 command += args | 1706 command += args |
1669 | 1707 |
1670 if loader is None: | 1708 if loader is None: |
1671 loader = env.GetSelLdr() | 1709 loader = env.GetSelLdr() |
1672 if loader is None: | 1710 if loader is None: |
1673 print 'WARNING: no sel_ldr found. Skipping test %s' % name | 1711 print 'WARNING: no sel_ldr found. Skipping test %s' % name |
1674 return [] | 1712 return [] |
1675 | 1713 |
(...skipping 2108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3784 nacl_env.ValidateSdk() | 3822 nacl_env.ValidateSdk() |
3785 | 3823 |
3786 if BROKEN_TEST_COUNT > 0: | 3824 if BROKEN_TEST_COUNT > 0: |
3787 msg = "There are %d broken tests." % BROKEN_TEST_COUNT | 3825 msg = "There are %d broken tests." % BROKEN_TEST_COUNT |
3788 if GetOption('brief_comstr'): | 3826 if GetOption('brief_comstr'): |
3789 msg += " Add --verbose to the command line for more information." | 3827 msg += " Add --verbose to the command line for more information." |
3790 print msg | 3828 print msg |
3791 | 3829 |
3792 # separate warnings from actual build output | 3830 # separate warnings from actual build output |
3793 Banner('B U I L D - O U T P U T:') | 3831 Banner('B U I L D - O U T P U T:') |
OLD | NEW |