OLD | NEW |
(Empty) | |
| 1 # -*- python -*- |
| 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 |
| 4 # found in the LICENSE file. |
| 5 |
| 6 import os |
| 7 Import('env') |
| 8 |
| 9 if env.Bit('linux'): |
| 10 |
| 11 # Defines common arch-independent validator directory. |
| 12 COMMON_VAL_DIR = '${MAIN_DIR}/src/trusted/validator' |
| 13 |
| 14 # Defines this source directory. |
| 15 GEN_SRC_DIR = '${MAIN_DIR}/src/trusted/validator_mips/gen' |
| 16 |
| 17 # Defines the full file name for a generated file. |
| 18 def _gen_file(filename): |
| 19 return '%s/%s' % (GEN_SRC_DIR, filename) |
| 20 |
| 21 # Defines the full file name for a file inside common validator directory. |
| 22 def _val_dir(filename): |
| 23 return '%s/%s' % (COMMON_VAL_DIR, filename) |
| 24 |
| 25 env.Append( |
| 26 CXXFLAGS='-Weffc++ -Woverloaded-virtual -fno-rtti -fomit-frame-pointer', |
| 27 ) |
| 28 |
| 29 GEN_LIST = [_gen_file('decode.cc')] |
| 30 |
| 31 generate = False |
| 32 gen_env = env.Clone(); |
| 33 if 'mipsvalgen' in COMMAND_LINE_TARGETS: generate = True |
| 34 if 'mipsvalclean' in COMMAND_LINE_TARGETS: generate = True |
| 35 |
| 36 if generate: |
| 37 gen_env.AlwaysBuild(gen_env.Alias('mipsvalgen', GEN_LIST)) |
| 38 gen_env.AlwaysBuild( |
| 39 gen_env.Alias('mipsvalclean', action=[Delete(x) for x in GEN_LIST])) |
| 40 |
| 41 def _generate_source(filename): |
| 42 env.Command(target=filename, |
| 43 source=['mips-opt.table', |
| 44 'dgen/generate_decoder.py', |
| 45 'dgen/dgen_core.py', |
| 46 'dgen/dgen_input.py', |
| 47 'dgen/dgen_opt.py', |
| 48 'dgen/dgen_output.py'], |
| 49 action=['${SOURCES[1].abspath} ${SOURCES[0].abspath} ' |
| 50 '${TARGET.abspath}']) |
| 51 |
| 52 for f in GEN_LIST: |
| 53 _generate_source(f) |
| 54 |
| 55 env.ComponentLibrary('mips_validator_core', |
| 56 ['address_set.cc', |
| 57 'validator.cc', |
| 58 'gen/decode.cc']) |
| 59 |
| 60 ncval = env.ComponentProgram( |
| 61 'mips-ncval-core', |
| 62 ['ncval.cc'], |
| 63 LIBS=['mips_validator_core', |
| 64 env.NaClTargetArchSuffix('ncfileutils'), |
| 65 '${OPTIONAL_COVERAGE_LIBS}']) |
| 66 |
| 67 env.SDKInstallBin('ncval', ncval, target='mips32') |
| 68 |
| 69 gtest_env = env.MakeGTestEnv() |
| 70 |
| 71 address_exe = gtest_env.ComponentProgram('mips_address_set_test_binary', |
| 72 ['address_set_test.cc'], |
| 73 LIBS=['mips_validator_core', 'gtest', 'pthread', |
| 74 '${OPTIONAL_COVERAGE_LIBS}']) |
| 75 |
| 76 address_set_test = gtest_env.CommandTest('mips_address_set_test.out', |
| 77 command=[address_exe]) |
| 78 |
| 79 gtest_env.AddNodeToTestSuite(address_set_test, |
| 80 ['small_tests'], |
| 81 'mips_address_set_test') |
| 82 |
| 83 validator_tests = { |
| 84 'test_forbidden_instructions': 1, |
| 85 'test_sp_updates': 1, |
| 86 'test_stores': 1, |
| 87 'test_loads': 1, |
| 88 'test_jmp_reg': 1, |
| 89 'test_jmp_imm': 1, |
| 90 'test_read_only_regs': 1, |
| 91 'test_invalid_dest': 1, |
| 92 } |
| 93 |
| 94 for test, exit_status in validator_tests.iteritems(): |
| 95 node = env.CommandTest( |
| 96 test + '_actual_mips.out', |
| 97 [ncval, env.File('testdata/' + test + '.nexe')], |
| 98 exit_status = str(exit_status), |
| 99 filter_regex = "'^ncval'", |
| 100 stderr_golden = env.File('testdata/' + test + '.err')) |
| 101 |
| 102 # TODO(petarj): validator_tests need to be disabled until tools for MIPS |
| 103 # architecture are available in the repository. |
| 104 # env.AddNodeToTestSuite(node, ['small_tests', 'validator_tests'], |
| 105 # "run_mips_" + test) |
| 106 |
| 107 # Do NOT name this program 'validator_tests' because this is the same name as |
| 108 # a test suite, and scons will run that test suite if it ever builds |
| 109 # a program of the same name. |
| 110 validator_tests_exe = gtest_env.ComponentProgram('mips_validator_tests', |
| 111 ['validator_tests.cc'], |
| 112 EXTRA_LIBS=['mips_validator_core']) |
| 113 |
| 114 test_node = gtest_env.CommandTest( |
| 115 'mips_validator_tests.out', |
| 116 command=[validator_tests_exe]) |
| 117 gtest_env.AddNodeToTestSuite(test_node, ['small_tests'], |
| 118 'run_mips_validator_tests') |
OLD | NEW |