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 1202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1567 # Make sure the pexe doesn't get removed by the fake builders when | 1570 # Make sure the pexe doesn't get removed by the fake builders when |
1568 # built_elsewhere=1 | 1571 # built_elsewhere=1 |
1569 env.Precious(pexe) | 1572 env.Precious(pexe) |
1570 node = env.Command(target=nexe_name, source=[pexe_name], | 1573 node = env.Command(target=nexe_name, source=[pexe_name], |
1571 action=[Action('${TRANSLATECOM}', '${TRANSLATECOMSTR}')]) | 1574 action=[Action('${TRANSLATECOM}', '${TRANSLATECOMSTR}')]) |
1572 assert len(node) == 1, node | 1575 assert len(node) == 1, node |
1573 return node[0] | 1576 return node[0] |
1574 | 1577 |
1575 pre_base_env.AddMethod(GetTranslatedNexe) | 1578 pre_base_env.AddMethod(GetTranslatedNexe) |
1576 | 1579 |
1577 | |
Mark Seaborn
2013/03/28 01:31:34
Nit: Can you leave 2 empty lines between top-level
jvoung - send to chromium...
2013/03/28 15:50:29
Done.
| |
1578 def ShouldTranslateToNexe(env, pexe): | 1580 def ShouldTranslateToNexe(env, pexe): |
1579 """ Determine when we need to translate a Pexe to a Nexe. | 1581 """ Determine when we need to translate a Pexe to a Nexe. |
1580 """ | 1582 """ |
1581 # Check if we started with a pexe, so there is actually a translation step. | 1583 # Check if we started with a pexe, so there is actually a translation step. |
1582 if not env.Bit('pnacl_generate_pexe'): | 1584 if not env.Bit('pnacl_generate_pexe'): |
1583 return False | 1585 return False |
1584 | 1586 |
1585 # There is no bitcode for trusted code. | 1587 # There is no bitcode for trusted code. |
1586 if env['NACL_BUILD_FAMILY'] == 'TRUSTED': | 1588 if env['NACL_BUILD_FAMILY'] == 'TRUSTED': |
1587 return False | 1589 return False |
1588 | 1590 |
1589 # Often there is a build step (do_not_run_tests=1) and a test step | 1591 # 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 | 1592 # (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 | 1593 # 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 | 1594 # 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, | 1595 # 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 | 1596 # we check the bit 'translate_in_build_step' / check if we are |
1595 # in the test step. | 1597 # in the test step. |
1596 return ( | 1598 return ( |
1597 env.Bit('translate_in_build_step') or not env.Bit('do_not_run_tests')) | 1599 env.Bit('translate_in_build_step') or not env.Bit('do_not_run_tests')) |
1598 | 1600 |
1599 pre_base_env.AddMethod(ShouldTranslateToNexe) | 1601 pre_base_env.AddMethod(ShouldTranslateToNexe) |
1600 | 1602 |
1603 def GetFinalizedPexe(env, pexe): | |
1604 """ Prep and finalize the ABI for a given pexe. | |
1605 """ | |
1606 pexe_name = pexe.abspath | |
1607 final_name = pexe_name[:pexe_name.index('.pexe')] + '.final.pexe' | |
Mark Seaborn
2013/03/28 01:31:34
You should assert that pexe_name ends with ".pexe"
| |
1608 # Make sure the pexe doesn't get removed by the fake builders when | |
1609 # built_elsewhere=1 | |
1610 env.Precious(pexe) | |
1611 node = env.Command(target=final_name, source=[pexe_name], | |
1612 action=[Action('${PNACLFINALIZECOM}', | |
1613 '${PNACLFINALIZECOMSTR}')]) | |
1614 assert len(node) == 1, node | |
1615 return node[0] | |
1616 | |
1617 pre_base_env.AddMethod(GetFinalizedPexe) | |
1618 | |
1619 # Bit to be set by individual test/nacl.scons files that need to opt-out. | |
Mark Seaborn
2013/03/28 01:31:34
Nit: "opt out", no hyphen :-)
jvoung - send to chromium...
2013/03/28 15:50:29
Done.
| |
1620 DeclareBit('nonstable_bitcode', 'Tests use non-stable bitcode features', False) | |
1621 | |
1622 def ShouldFinalizePexe(env, pexe): | |
1623 """ Determine when we need to prep a pexe to finalize it for ABI stability. | |
1624 """ | |
1625 if not env.Bit('pnacl_generate_pexe') or env.Bit('nonstable_bitcode'): | |
1626 return False | |
1627 | |
1628 # There is no bitcode for trusted code. | |
1629 if env['NACL_BUILD_FAMILY'] == 'TRUSTED': | |
1630 return False | |
1631 | |
1632 # Unlike ShouldTranslateToNexe, we always prep during the build step, | |
1633 # since there is no prep tool that can run on triggered bots such as the | |
1634 # ARM HW bots. | |
1635 return True | |
1636 | |
1637 pre_base_env.AddMethod(ShouldFinalizePexe) | |
1638 | |
1601 | 1639 |
1602 def CommandTestFileDumpCheck(env, | 1640 def CommandTestFileDumpCheck(env, |
1603 name, | 1641 name, |
1604 target, | 1642 target, |
1605 check_file, | 1643 check_file, |
1606 objdump_flags): | 1644 objdump_flags): |
1607 """Create a test that disassembles a binary (|target|) and checks for | 1645 """Create a test that disassembles a binary (|target|) and checks for |
1608 patterns in the |check_file|. Disassembly is done using |objdump_flags|. | 1646 patterns in the |check_file|. Disassembly is done using |objdump_flags|. |
1609 """ | 1647 """ |
1610 | 1648 |
1611 # Do not try to run OBJDUMP if 'built_elsewhere', since that *might* mean | 1649 # 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 | 1650 # 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 | 1651 # 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. | 1652 # ARM objdump though... a TODO(jvoung) for when there is time. |
1615 if env.Bit('built_elsewhere'): | 1653 if env.Bit('built_elsewhere'): |
1616 return [] | 1654 return [] |
1655 if env.ShouldFinalizePexe(target): | |
1656 target = env.GetFinalizedPexe(target) | |
Mark Seaborn
2013/03/28 01:31:34
GetFinalizedPexe() is always called after ShouldFi
jvoung - send to chromium...
2013/03/28 15:50:29
Yes, I think we can merge these.
| |
1617 if env.ShouldTranslateToNexe(target): | 1657 if env.ShouldTranslateToNexe(target): |
1618 target_obj = env.GetTranslatedNexe(target) | 1658 target = 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 |
1701 if env.ShouldFinalizePexe(nexe): | |
1702 # The nexe is actually a pexe and we need to prep it for | |
1703 # ABI stability first. | |
1704 nexe = env.GetFinalizedPexe(nexe) | |
1705 | |
1663 if env.ShouldTranslateToNexe(nexe): | 1706 if env.ShouldTranslateToNexe(nexe): |
1664 # The nexe is actually a pexe. Translate it before we run it. | 1707 # The nexe is actually a pexe. Translate it before we run it. |
1665 nexe = env.GetTranslatedNexe(nexe) | 1708 nexe = env.GetTranslatedNexe(nexe) |
1666 command = [nexe] | 1709 command = [nexe] |
1667 if args is not None: | 1710 if args is not None: |
1668 command += args | 1711 command += args |
1669 | 1712 |
1670 if loader is None: | 1713 if loader is None: |
1671 loader = env.GetSelLdr() | 1714 loader = env.GetSelLdr() |
1672 if loader is None: | 1715 if loader is None: |
(...skipping 2111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3784 nacl_env.ValidateSdk() | 3827 nacl_env.ValidateSdk() |
3785 | 3828 |
3786 if BROKEN_TEST_COUNT > 0: | 3829 if BROKEN_TEST_COUNT > 0: |
3787 msg = "There are %d broken tests." % BROKEN_TEST_COUNT | 3830 msg = "There are %d broken tests." % BROKEN_TEST_COUNT |
3788 if GetOption('brief_comstr'): | 3831 if GetOption('brief_comstr'): |
3789 msg += " Add --verbose to the command line for more information." | 3832 msg += " Add --verbose to the command line for more information." |
3790 print msg | 3833 print msg |
3791 | 3834 |
3792 # separate warnings from actual build output | 3835 # separate warnings from actual build output |
3793 Banner('B U I L D - O U T P U T:') | 3836 Banner('B U I L D - O U T P U T:') |
OLD | NEW |