Index: src/trusted/validator_x86/build.scons |
diff --git a/src/trusted/validator_x86/build.scons b/src/trusted/validator_x86/build.scons |
index 4c928786c83f59dc1dff2d7997b28070fbd93325..ac9a7bcf2f1c593f38ac7ee35b8940182c3f5168 100644 |
--- a/src/trusted/validator_x86/build.scons |
+++ b/src/trusted/validator_x86/build.scons |
@@ -17,70 +17,6 @@ Import('env') |
# |
if not env.Bit('target_x86'): Return() |
-# ------------------------------------------------------ |
-# General adjustments to the environment for builds. |
- |
-# Defines which test sets tests should be added to. |
-STANDARD_TESTS = ['small_tests', 'validator_tests'] |
- |
-# TODO(bradchen): eliminate need for the following line |
-env.FilterOut(CCFLAGS=['-Wextra', '-Wswitch-enum', '-Wsign-compare']) |
- |
-# Defines the source directory where validator generated files should be added. |
-val_src_dir = '$MAIN_DIR/src/trusted/validator_x86' |
- |
-# Create environment for command-line tools and testing, rather than |
-# part of the TCB. Then define compile-time flag that communicates |
-# that we are compiling in the test environment (rather than for the TCB). |
-test_env = env.Clone() |
-test_env.Append(CCFLAGS=['-DNACL_TRUSTED_BUT_NOT_TCB']) |
- |
-# TODO(shcherbina): remove dead test running code (tests moved to |
-# testscripts/run_tests.py and *.test files) |
- |
-# ====================================================================== |
-# Helper functions for getting automated tests from the corresponding |
-# test directory. |
- |
-TESTDATA_DIR = 'testdata/' |
-TESTDATA_SUBARCH_DIR = TESTDATA_DIR + env['TARGET_SUBARCH'] + '/' |
- |
-# Generates the set of test files with the given extension. |
-def __GoldenFiles(ext): |
- return Glob(TESTDATA_SUBARCH_DIR + '*.' + ext) |
- |
-# Generates base names (i.e. minus path and extention (ext) suffix) of |
-# all test data input files. |
-def __FilterOutTestFileBaseGen(files, ext): |
- for f in files: |
- yield os.path.basename(f.path).replace('.' + ext, '') |
- |
-# Generates the set of golden bases for the given extension. |
-def __GoldenBases(ext): |
- return __FilterOutTestFileBaseGen(__GoldenFiles(ext), ext) |
- |
-# Generates the corresponding test file from the given base. |
-def __BaseTestFile(base, ext): |
- return test_env.File(TESTDATA_SUBARCH_DIR + base + '.' + ext) |
- |
-# Generates the corresponding output file from the given base. |
-def __OutTestFile(test, base, ext): |
- return test + '_' + base + '.' + ext + '.out' |
- |
-def __AddTest(test, test_env, base, ext, command, groups): |
- test_env.AddNodeToTestSuite( |
- command, |
- groups, |
- 'run_%s_%s_%s_test' % (test, base, ext)) |
- |
- |
-# The following are common library components that use elements |
-# of both x86-32 and x86-64 validators. |
-test_env.ComponentLibrary(test_env.NaClTargetArchSuffix('ncdis_util'), |
- ['ncdis_segments.c', |
- 'nc_read_segment.c', |
- test_env.NaClTargetArchSuffix('ncenuminsts') + '.c']) |
- |
# The following are copycode routines for x86-32 and x86-64. |
# TODO(karl): Break this up so that we don't need to load |
# non-shared code in library. |
@@ -89,204 +25,3 @@ env.ComponentLibrary(env.NaClTargetArchSuffix('nccopy'), [ |
'nccopycode_stores.S', |
]) |
-# ====================================================================== |
-# Decoder unittests |
-if test_env.Bit('target_x86_32'): |
- # TODO(kschimpf): remove this when the validator builds as 64-bits. |
- if test_env.Bit('build_x86_32'): |
- ncdecode_tests = test_env.ComponentProgram( |
- 'ncdecode_tests', |
- ['ncdecode_tests.c'], |
- EXTRA_LIBS=[test_env.NaClTargetArchSuffix('ncdis_seg_sfi_verbose'), |
- ]) |
- |
- node = test_env.CommandTest( |
- 'ncdecode_tests.out', |
- [ncdecode_tests], |
- ) |
- |
- test_env.AddNodeToTestSuite(node, STANDARD_TESTS, 'run_nc_decode_tests') |
- |
-# ====================================================================== |
-# Build command line decoder. |
-# |
-ncdis = test_env.ComponentProgram( |
- 'ncdis', [ |
- 'ncdis.c', |
- ], |
- EXTRA_LIBS=[test_env.NaClTargetArchSuffix('ncdis_util'), |
- test_env.NaClTargetArchSuffix('ncfileutils'), |
- test_env.NaClTargetArchSuffix('ncdis_decode_tables'), |
- test_env.NaClTargetArchSuffix('nc_opcode_modeling_verbose'), |
- 'utils', |
- ]) |
- |
-# ====================================================================== |
-# Valiator unittests |
-if test_env.Bit('target_x86_32'): |
- ncval_tests = test_env.ComponentProgram( |
- 'ncval_tests', |
- ['ncval_tests.c'], |
- EXTRA_LIBS=[test_env.NaClTargetArchSuffix('ncdis_util'), |
- test_env.NaClTargetArchSuffix('ncval_seg_sfi'), |
- ]) |
- |
- node = test_env.CommandTest( |
- 'ncval_tests.out', |
- [ncval_tests], |
- ) |
- |
- test_env.AddNodeToTestSuite(node, STANDARD_TESTS, 'run_ncval_tests') |
- |
-# ====================================================================== |
-# Define what decoder was historically being used for tests. This allows |
-# existing tests to continue to follow that historical assumption. |
- |
-if test_env.Bit('target_x86_32'): |
- _ncdis_historical_decoder = '--validator_decoder' |
-else: |
- _ncdis_historical_decoder = '--full_decoder' |
- |
- |
-# ====================================================================== |
-# Decoder vs objdump tests |
-# TODO: add tests using the toolchain binaries in the sdk |
-if test_env.Bit('linux') and test_env.Bit('target_x86_32'): |
- test = 'discmp' |
- ext = 'nexe' |
- for base in __GoldenBases(ext): |
- node = test_env.CommandTest( |
- __OutTestFile(test, base, ext), |
- ["${PYTHON}", test_env.File('discmp.py'), test_env.File('ncdis'), |
- __BaseTestFile(base, ext)], |
- size='large') |
- __AddTest(test, test_env, base, ext, node, ['large_tests']) |
- |
-# ====================================================================== |
-# Run tests on ncdis, where the input is self documenting (i.e. the input |
-# file matches the generated resulit. |
-def __AddNcdisSelfDocTests(validator_decoder, internals_also): |
- test = 'ncdis_test' |
- options = ['--commands=-'] |
- input_ext = 'input' |
- if internals_also: |
- output_ext = 'internal' |
- options.append('--internal') |
- else: |
- output_ext = input_ext |
- options.append('--self_document') |
- if validator_decoder: |
- output_ext = 'v' + output_ext |
- options.append('--validator_decoder') |
- else: |
- options.append('--full_decoder') |
- for base in __GoldenBases(output_ext): |
- command = [ncdis] + options |
- ncdis_test = test_env.CommandTest( |
- __OutTestFile(test, base, output_ext), |
- command, |
- stdin = __BaseTestFile(base, input_ext), |
- stdout_golden = __BaseTestFile(base, output_ext)) |
- __AddTest(test, test_env, base, output_ext, ncdis_test, |
- STANDARD_TESTS) |
- |
-for validator_decoder in [False, True]: |
- for internals_also in [False, True]: |
- __AddNcdisSelfDocTests(validator_decoder, internals_also) |
- |
-# ====================================================================== |
-# Build command line validator. |
-ncval = test_env.ComponentProgram( |
- 'ncval', [ |
- 'ncval.c', |
- ], |
- EXTRA_LIBS=[test_env.NaClTargetArchSuffix('ncdis_util'), |
- test_env.NaClTargetArchSuffix('ncval_seg_sfi'), |
- test_env.NaClTargetArchSuffix('ncfileutils'), |
- test_env.NaClTargetArchSuffix('ncdis_decode_tables'), |
- 'utils', |
- ]) |
- |
-test_env.SDKInstallBin('ncval', ncval) |
- |
- |
-# ====================================================================== |
-# Validator tests against real nacl images |
-# TODO: add death tests |
-# TODO: add tests using binaries produced by nacl.scons files |
-# TODO: consider comparing the actual output (not just exit codes) |
-# Validate tests |
-if env.Bit('target_x86_32'): |
- test = 'validate' |
- ext = 'nexe' |
- for base in __GoldenBases(ext): |
- node = test_env.CommandTest( |
- __OutTestFile(test, base, ext), |
- [ncval, '-t', __BaseTestFile(base, ext)]) |
- __AddTest(test, test_env, base, ext, node, ['small_tests']) |
- |
-if test_env.Bit('target_x86_64'): |
- node = test_env.CommandTest('ncval_hello_x32.out', |
- [ncval, |
- env.File(os.path.join('${MAIN_DIR}/src/trusted', |
- 'service_runtime', |
- 'testdata/x86_64', |
- 'hello_x32.nexe'))]) |
- env.AddNodeToTestSuite(node, STANDARD_TESTS, 'run_ncval_hello_x32_test') |
- |
-bits = env.get('TARGET_SUBARCH') |
-assert bits in ['32', '64'] |
- |
-tests_mask = '${MAIN_DIR}/src/trusted/validator_x86/testdata/%s/*.test' % bits |
- |
-if env.Bit('regenerate_golden'): |
- update_option = ['--update'] |
-else: |
- update_option = [] |
- |
-old_testdata_tests = env.AutoDepsCommand( |
- 'x86_old_validator_testdata_tests.out', |
- ['${PYTHON}', |
- env.File('testscripts/run_old_validator_tests.py'), |
- '--ncval', ncval, |
- '--ncdis', ncdis, |
- '--bits', bits, |
- tests_mask] + update_option) |
- |
-env.AddNodeToTestSuite( |
- old_testdata_tests, |
- STANDARD_TESTS, |
- node_name='run_x86_old_validator_testdata_tests') |
- |
-rdfaval = '$STAGING_DIR/ncval_new$PROGSUFFIX' |
- |
-rdfa_testdata_tests = env.AutoDepsCommand( |
- 'x86_rdfa_validator_testdata_tests.out', |
- ['${PYTHON}', |
- env.File('testscripts/run_rdfa_validator_tests.py'), |
- '--rdfaval', env.File(rdfaval), |
- '--bits', bits, |
- tests_mask] + update_option) |
- |
-env.AddNodeToTestSuite( |
- rdfa_testdata_tests, |
- STANDARD_TESTS, |
- node_name='run_x86_rdfa_validator_testdata_tests') |
- |
-compare_validators = env.AutoDepsCommand( |
- 'compare_x86_validators_tests.out', |
- ['${PYTHON}', |
- env.File('testscripts/compare_validators.py'), |
- '--bits', bits, |
- tests_mask] + update_option) |
- |
-env.AddNodeToTestSuite( |
- compare_validators, |
- STANDARD_TESTS, |
- node_name='run_compare_x86_validators_tests') |
- |
-if env.Bit('regenerate_golden'): |
- # Don't want these tests run in parallel because they write |
- # to .test files. |
- SideEffect(tests_mask, [old_testdata_tests, rdfa_testdata_tests]) |
- Depends(compare_validators, [old_testdata_tests, rdfa_testdata_tests]) |