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 1188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1553 def ShouldUseVerboseOptions(env, extra): | 1556 def ShouldUseVerboseOptions(env, extra): |
1554 """ Heuristic for setting up Verbose NACLLOG options. """ | 1557 """ Heuristic for setting up Verbose NACLLOG options. """ |
1555 return ('process_output_single' in extra or | 1558 return ('process_output_single' in extra or |
1556 'log_golden' in extra) | 1559 'log_golden' in extra) |
1557 | 1560 |
1558 pre_base_env.AddMethod(ShouldUseVerboseOptions) | 1561 pre_base_env.AddMethod(ShouldUseVerboseOptions) |
1559 | 1562 |
1560 | 1563 |
1561 DeclareBit('tests_use_irt', 'Non-browser tests also load the IRT image', False) | 1564 DeclareBit('tests_use_irt', 'Non-browser tests also load the IRT image', False) |
1562 | 1565 |
1563 # Translate the given pexe. | 1566 # Bit to be set by individual test/nacl.scons files that need to opt out. |
1564 def GetTranslatedNexe(env, pexe): | 1567 DeclareBit('nonstable_bitcode', 'Tests use non-stable bitcode features', False) |
1568 | |
1569 def GetFinalizedPexe(env, pexe): | |
Mark Seaborn
2013/03/28 18:44:17
Nit: 2 empty lines before this to separate top-lev
jvoung (off chromium)
2013/03/28 19:45:31
Done.
| |
1570 """ Prep and finalize the ABI for a given pexe if needed. | |
1571 """ | |
1572 if not env.Bit('pnacl_generate_pexe') or env.Bit('nonstable_bitcode'): | |
1573 return pexe | |
1574 | |
1575 # There is no bitcode for trusted code. | |
Mark Seaborn
2013/03/28 18:44:17
BTW, is this check necessary? Surely no pexes can
jvoung (off chromium)
2013/03/28 19:45:31
There are a couple of CommandSelLdrTestNaCl() comi
| |
1576 if env['NACL_BUILD_FAMILY'] == 'TRUSTED': | |
1577 return pexe | |
1578 | |
1579 # Otherwise, finalize during the build step, since there is no finalize tool | |
1580 # that can run on triggered bots such as the ARM HW bots. | |
1565 pexe_name = pexe.abspath | 1581 pexe_name = pexe.abspath |
1566 nexe_name = pexe_name[:pexe_name.index('.pexe')] + '.nexe' | 1582 final_name = pexe_name[:pexe_name.index('.nonfinal.pexe')] + '.final.pexe' |
Mark Seaborn
2013/03/28 18:44:17
I think you missed this before:
On 2013/03/28 01:
jvoung (off chromium)
2013/03/28 19:45:31
Ah yes, the StripSuffix helper is safer -- using t
| |
1567 # Make sure the pexe doesn't get removed by the fake builders when | 1583 # Make sure the pexe doesn't get removed by the fake builders when |
1568 # built_elsewhere=1 | 1584 # built_elsewhere=1 |
1569 env.Precious(pexe) | 1585 env.Precious(pexe) |
1570 node = env.Command(target=nexe_name, source=[pexe_name], | 1586 node = env.Command(target=final_name, source=[pexe_name], |
1571 action=[Action('${TRANSLATECOM}', '${TRANSLATECOMSTR}')]) | 1587 action=[Action('${PNACLFINALIZECOM}', |
1588 '${PNACLFINALIZECOMSTR}')]) | |
1572 assert len(node) == 1, node | 1589 assert len(node) == 1, node |
1573 return node[0] | 1590 return node[0] |
1574 | 1591 |
1575 pre_base_env.AddMethod(GetTranslatedNexe) | |
1576 | 1592 |
1593 # Translate the given pexe. | |
1594 def GetTranslatedNexe(env, pexe): | |
1595 # First finalize the pexe. | |
1596 pexe = GetFinalizedPexe(env, pexe) | |
1577 | 1597 |
1578 def ShouldTranslateToNexe(env, pexe): | 1598 # 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. | 1599 # Check if we started with a pexe, so there is actually a translation step. |
1582 if not env.Bit('pnacl_generate_pexe'): | 1600 if not env.Bit('pnacl_generate_pexe'): |
1583 return False | 1601 return pexe |
1584 | 1602 |
1585 # There is no bitcode for trusted code. | 1603 # There is no bitcode for trusted code. |
1586 if env['NACL_BUILD_FAMILY'] == 'TRUSTED': | 1604 if env['NACL_BUILD_FAMILY'] == 'TRUSTED': |
1587 return False | 1605 return pexe |
1588 | 1606 |
1589 # Often there is a build step (do_not_run_tests=1) and a test step | 1607 # 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 | 1608 # (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 | 1609 # 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 | 1610 # 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, | 1611 # 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 | 1612 # we check the bit 'translate_in_build_step' / check if we are |
1595 # in the test step. | 1613 # in the test step. |
1596 return ( | 1614 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')) | 1615 return pexe |
1598 | 1616 |
1599 pre_base_env.AddMethod(ShouldTranslateToNexe) | 1617 pexe_name = pexe.abspath |
1618 nexe_name = pexe_name[:pexe_name.index('.pexe')] + '.nexe' | |
Mark Seaborn
2013/03/28 18:44:17
Can you add an assertion here too, please?
i.e.
as
jvoung (off chromium)
2013/03/28 19:45:31
Done (using the asserting version), and simplified
| |
1619 # Make sure the pexe doesn't get removed by the fake builders when | |
1620 # built_elsewhere=1 | |
1621 env.Precious(pexe) | |
1622 node = env.Command(target=nexe_name, source=[pexe_name], | |
1623 action=[Action('${TRANSLATECOM}', '${TRANSLATECOMSTR}')]) | |
1624 assert len(node) == 1, node | |
1625 return node[0] | |
1626 | |
1627 pre_base_env.AddMethod(GetTranslatedNexe) | |
1600 | 1628 |
1601 | 1629 |
1602 def CommandTestFileDumpCheck(env, | 1630 def CommandTestFileDumpCheck(env, |
1603 name, | 1631 name, |
1604 target, | 1632 target, |
1605 check_file, | 1633 check_file, |
1606 objdump_flags): | 1634 objdump_flags): |
1607 """Create a test that disassembles a binary (|target|) and checks for | 1635 """Create a test that disassembles a binary (|target|) and checks for |
1608 patterns in the |check_file|. Disassembly is done using |objdump_flags|. | 1636 patterns in the |check_file|. Disassembly is done using |objdump_flags|. |
1609 """ | 1637 """ |
1610 | 1638 |
1611 # Do not try to run OBJDUMP if 'built_elsewhere', since that *might* mean | 1639 # 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 | 1640 # 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 | 1641 # 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. | 1642 # ARM objdump though... a TODO(jvoung) for when there is time. |
1615 if env.Bit('built_elsewhere'): | 1643 if env.Bit('built_elsewhere'): |
1616 return [] | 1644 return [] |
1617 if env.ShouldTranslateToNexe(target): | 1645 target = env.GetTranslatedNexe(target) |
1618 target_obj = env.GetTranslatedNexe(target) | |
1619 else: | |
1620 target_obj = target | |
1621 return env.CommandTestFileCheck(name, | 1646 return env.CommandTestFileCheck(name, |
1622 ['${OBJDUMP}', objdump_flags, target_obj], | 1647 ['${OBJDUMP}', objdump_flags, target], |
1623 check_file) | 1648 check_file) |
1624 | 1649 |
1625 pre_base_env.AddMethod(CommandTestFileDumpCheck) | 1650 pre_base_env.AddMethod(CommandTestFileDumpCheck) |
1626 | 1651 |
1627 | 1652 |
1628 def CommandTestFileCheck(env, name, cmd, check_file): | 1653 def CommandTestFileCheck(env, name, cmd, check_file): |
1629 """Create a test that runs a |cmd| (array of strings), | 1654 """Create a test that runs a |cmd| (array of strings), |
1630 which is expected to print to stdout. The results | 1655 which is expected to print to stdout. The results |
1631 of stdout will then be piped to the file_check.py tool which | 1656 of stdout will then be piped to the file_check.py tool which |
1632 will search for the regexes specified in |check_file|. """ | 1657 will search for the regexes specified in |check_file|. """ |
(...skipping 20 matching lines...) Expand all Loading... | |
1653 # e.g., [ 'python', 'time_check.py', '--' ] | 1678 # e.g., [ 'python', 'time_check.py', '--' ] |
1654 **extra): | 1679 **extra): |
1655 # Disable all sel_ldr tests for windows under coverage. | 1680 # Disable all sel_ldr tests for windows under coverage. |
1656 # Currently several .S files block sel_ldr from being instrumented. | 1681 # Currently several .S files block sel_ldr from being instrumented. |
1657 # See http://code.google.com/p/nativeclient/issues/detail?id=831 | 1682 # See http://code.google.com/p/nativeclient/issues/detail?id=831 |
1658 if ('TRUSTED_ENV' in env and | 1683 if ('TRUSTED_ENV' in env and |
1659 env['TRUSTED_ENV'].Bit('coverage_enabled') and | 1684 env['TRUSTED_ENV'].Bit('coverage_enabled') and |
1660 env['TRUSTED_ENV'].Bit('windows')): | 1685 env['TRUSTED_ENV'].Bit('windows')): |
1661 return [] | 1686 return [] |
1662 | 1687 |
1663 if env.ShouldTranslateToNexe(nexe): | 1688 # The nexe might be a pexe that needs finalization, and translation. |
1664 # The nexe is actually a pexe. Translate it before we run it. | 1689 nexe = env.GetTranslatedNexe(nexe) |
1665 nexe = env.GetTranslatedNexe(nexe) | 1690 |
1666 command = [nexe] | 1691 command = [nexe] |
1667 if args is not None: | 1692 if args is not None: |
1668 command += args | 1693 command += args |
1669 | 1694 |
1670 if loader is None: | 1695 if loader is None: |
1671 loader = env.GetSelLdr() | 1696 loader = env.GetSelLdr() |
1672 if loader is None: | 1697 if loader is None: |
1673 print 'WARNING: no sel_ldr found. Skipping test %s' % name | 1698 print 'WARNING: no sel_ldr found. Skipping test %s' % name |
1674 return [] | 1699 return [] |
1675 | 1700 |
(...skipping 2108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3784 nacl_env.ValidateSdk() | 3809 nacl_env.ValidateSdk() |
3785 | 3810 |
3786 if BROKEN_TEST_COUNT > 0: | 3811 if BROKEN_TEST_COUNT > 0: |
3787 msg = "There are %d broken tests." % BROKEN_TEST_COUNT | 3812 msg = "There are %d broken tests." % BROKEN_TEST_COUNT |
3788 if GetOption('brief_comstr'): | 3813 if GetOption('brief_comstr'): |
3789 msg += " Add --verbose to the command line for more information." | 3814 msg += " Add --verbose to the command line for more information." |
3790 print msg | 3815 print msg |
3791 | 3816 |
3792 # separate warnings from actual build output | 3817 # separate warnings from actual build output |
3793 Banner('B U I L D - O U T P U T:') | 3818 Banner('B U I L D - O U T P U T:') |
OLD | NEW |