| 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 json | 6 import json |
| 7 import hashlib | 7 import hashlib |
| 8 import os | 8 import os |
| 9 import platform | 9 import platform |
| 10 import sys | 10 import sys |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 env.AddNodeToTestSuite( | 143 env.AddNodeToTestSuite( |
| 144 validator_py_test, | 144 validator_py_test, |
| 145 ['small_tests', 'validator_tests'], | 145 ['small_tests', 'validator_tests'], |
| 146 'run_validator_py_test') | 146 'run_validator_py_test') |
| 147 | 147 |
| 148 # Source generation: | 148 # Source generation: |
| 149 # | 149 # |
| 150 # dfagen : Regenerate any autogenerated source files. | 150 # dfagen : Regenerate any autogenerated source files. |
| 151 | 151 |
| 152 ragel_targets = set([ | 152 ragel_targets = set([ |
| 153 'dfagen', 'dfacheckdecoder', 'dfacheckvalidator']) | 153 'dfagen', 'dfacheckdecoder', 'dfacheckvalidator', 'dfafullcheckvalidator']) |
| 154 ragel_involved = ragel_targets.intersection(COMMAND_LINE_TARGETS) | 154 ragel_involved = ragel_targets.intersection(COMMAND_LINE_TARGETS) |
| 155 | 155 |
| 156 gas = env.MakeUntrustedNativeEnv()['AS'] | 156 gas = env.MakeUntrustedNativeEnv()['AS'] |
| 157 objdump = env.MakeUntrustedNativeEnv()['OBJDUMP'] | 157 objdump = env.MakeUntrustedNativeEnv()['OBJDUMP'] |
| 158 | 158 |
| 159 if ragel_involved: | 159 if ragel_involved: |
| 160 if not env.Bit('host_linux'): | 160 if not env.Bit('host_linux'): |
| 161 raise UserError('Right now DFA generation is only supported on Linux') | 161 raise UserError('Right now DFA generation is only supported on Linux') |
| 162 | 162 |
| 163 # Source generation step 1: Build generator of ragel files. | 163 # Source generation step 1: Build generator of ragel files. |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 check_decoders.append(check_decoder) | 276 check_decoders.append(check_decoder) |
| 277 | 277 |
| 278 # Never run decoder tests in parallel because they can take all CPU. | 278 # Never run decoder tests in parallel because they can take all CPU. |
| 279 SideEffect('check_decoder', check_decoders) | 279 SideEffect('check_decoder', check_decoders) |
| 280 | 280 |
| 281 env.AlwaysBuild(env.Alias('dfagen', automata)) | 281 env.AlwaysBuild(env.Alias('dfagen', automata)) |
| 282 env.AlwaysBuild(env.Alias('dfacheckdecoder', check_decoders)) | 282 env.AlwaysBuild(env.Alias('dfacheckdecoder', check_decoders)) |
| 283 | 283 |
| 284 if python_can_load_dll: | 284 if python_can_load_dll: |
| 285 | 285 |
| 286 # Fullcheck includes both [relatively] slow "regular instructions test" |
| 287 # and [relatively] fast "regressions test". Check only includes |
| 288 # [relatively] fast "regressions test". |
| 289 dfafullcheckvalidator_tests = [] |
| 286 dfacheckvalidator_tests = [] | 290 dfacheckvalidator_tests = [] |
| 287 | 291 |
| 288 for bitness, xml in [('32', validator32_xml), ('64', validator64_xml)]: | 292 for bitness, xml in [('32', validator32_xml), ('64', validator64_xml)]: |
| 289 superinstruction = env.AutoDepsCommand( | 293 superinstruction = env.AutoDepsCommand( |
| 290 'superinstructions_x86_%s.txt' % bitness, | 294 'superinstructions_x86_%s.txt' % bitness, |
| 291 ['${PYTHON}', | 295 ['${PYTHON}', |
| 292 env.File('verify_validators_dfa.py'), | 296 env.File('verify_validators_dfa.py'), |
| 293 xml, | 297 xml, |
| 294 '-o', '${TARGET}']) | 298 '-o', '${TARGET}']) |
| 295 | 299 |
| 296 superinstruction_verified = env.AutoDepsCommand( | 300 superinstruction_verified = env.AutoDepsCommand( |
| 297 'superinstructions_verified_x86_%s.out' % bitness, | 301 'superinstructions_verified_x86_%s.out' % bitness, |
| 298 ['${PYTHON}', | 302 ['${PYTHON}', |
| 299 env.File('verify_superinstructions.py'), | 303 env.File('verify_superinstructions.py'), |
| 300 '--bitness', bitness, | 304 '--bitness', bitness, |
| 301 '--gas', gas, | 305 '--gas', gas, |
| 302 '--objdump', objdump, | 306 '--objdump', objdump, |
| 303 '--validator_dll', validator_dll, | 307 '--validator_dll', validator_dll, |
| 304 superinstruction]) | 308 superinstruction]) |
| 305 | 309 |
| 306 env.AlwaysBuild(superinstruction_verified) | 310 env.AlwaysBuild(superinstruction_verified) |
| 311 dfafullcheckvalidator_tests.append(superinstruction_verified) |
| 307 dfacheckvalidator_tests.append(superinstruction_verified) | 312 dfacheckvalidator_tests.append(superinstruction_verified) |
| 308 | 313 |
| 314 # Compare list of allowed instructions to python model |
| 309 regular_instructions_test = env.AutoDepsCommand( | 315 regular_instructions_test = env.AutoDepsCommand( |
| 310 'regular_instructions_test_x86_%s.out' % bitness, | 316 'regular_instructions_test_x86_%s.out' % bitness, |
| 311 ['${PYTHON}', | 317 ['${PYTHON}', |
| 312 env.File('verify_regular_instructions.py'), | 318 env.File('verify_regular_instructions.py'), |
| 313 xml, | 319 xml, |
| 314 '--bitness', bitness, | 320 '--bitness', bitness, |
| 315 '--validator_dll', validator_dll, | 321 '--validator_dll', validator_dll, |
| 316 '--decoder_dll', decoder_dll]) | 322 '--decoder_dll', decoder_dll]) |
| 317 | 323 |
| 318 # Never run exhaustive tests in parallel because they can take all CPU. | 324 # Never run exhaustive tests in parallel because they can take all CPU. |
| 319 env.AlwaysBuild(regular_instructions_test) | 325 env.AlwaysBuild(regular_instructions_test) |
| 320 SideEffect('check_validator', regular_instructions_test) | 326 SideEffect('check_validator_full', regular_instructions_test) |
| 321 dfacheckvalidator_tests.append(regular_instructions_test) | 327 dfafullcheckvalidator_tests.append(regular_instructions_test) |
| 328 |
| 329 # Compress list of instructions and compare it to golden file |
| 330 compress_regular_instructions_test = env.CommandTest( |
| 331 '%sbit_regular.out' % bitness, |
| 332 ['${PYTHON}', |
| 333 env.File('compress_regular_instructions.py'), |
| 334 xml, |
| 335 '--bitness', bitness, |
| 336 '--validator_dll', validator_dll, |
| 337 '--decoder_dll', decoder_dll], |
| 338 size = 'huge', scale_timeout = 16, capture_stderr = False, |
| 339 stdout_golden = env.File('testdata/%sbit_regular.golden' % bitness)) |
| 340 SideEffect('check_validator', compress_regular_instructions_test) |
| 341 dfacheckvalidator_tests.append(compress_regular_instructions_test) |
| 322 | 342 |
| 323 env32 = env.Clone(BUILD_TARGET_NAME='x86-32') | 343 env32 = env.Clone(BUILD_TARGET_NAME='x86-32') |
| 324 env64 = env.Clone(BUILD_TARGET_NAME='x86-64') | 344 env64 = env.Clone(BUILD_TARGET_NAME='x86-64') |
| 325 old_ncval32 = env32.File('$STAGING_DIR/ncval$PROGSUFFIX') | 345 old_ncval32 = env32.File('$STAGING_DIR/ncval$PROGSUFFIX') |
| 326 old_ncval64 = env64.File('$STAGING_DIR/ncval$PROGSUFFIX') | 346 old_ncval64 = env64.File('$STAGING_DIR/ncval$PROGSUFFIX') |
| 327 | 347 |
| 328 regular_instructions_old_test = env.AutoDepsCommand( | 348 regular_instructions_old_test = env.AutoDepsCommand( |
| 329 'regular_instructions_old_test_x86_%s.out' % bitness, | 349 'regular_instructions_old_test_x86_%s.out' % bitness, |
| 330 ['${PYTHON}', | 350 ['${PYTHON}', |
| 331 env.File('verify_regular_instructions_old.py'), | 351 env.File('verify_regular_instructions_old.py'), |
| 332 xml, | 352 xml, |
| 333 '--bitness', bitness, | 353 '--bitness', bitness, |
| 334 '--gas', gas, | 354 '--gas', gas, |
| 335 '--objdump', objdump, | 355 '--objdump', objdump, |
| 336 '--validator_dll', validator_dll, | 356 '--validator_dll', validator_dll, |
| 337 '--ncval32', old_ncval32, | 357 '--ncval32', old_ncval32, |
| 338 '--ncval64', old_ncval64, | 358 '--ncval64', old_ncval64, |
| 339 '--errors', '${TARGET}']) | 359 '--errors', '${TARGET}']) |
| 340 | 360 |
| 341 # Never run exhaustive tests in parallel because they can take all CPU. | 361 # Never run exhaustive tests in parallel because they can take all CPU. |
| 342 env.AlwaysBuild(regular_instructions_old_test) | 362 env.AlwaysBuild(regular_instructions_old_test) |
| 343 SideEffect('check_validator', regular_instructions_old_test) | 363 SideEffect('check_validator_full', regular_instructions_old_test) |
| 344 dfacheckvalidator_tests.append(regular_instructions_old_test) | 364 dfafullcheckvalidator_tests.append(regular_instructions_old_test) |
| 345 | 365 |
| 346 # There are three categories of protected files: validator files, generated | 366 # There are three categories of protected files: validator files, generated |
| 347 # files (those of validator files that lie withing 'gen' directory) and | 367 # files (those of validator files that lie withing 'gen' directory) and |
| 348 # generating files (programs and input data used to produce generated | 368 # generating files (programs and input data used to produce generated |
| 349 # files). | 369 # files). |
| 350 # | 370 # |
| 351 # When validator files are changed, exhaustive validator tests have to be | 371 # When validator files are changed, exhaustive validator tests have to be |
| 352 # rerun. When generating files are changed, dfagen must be run to ensure | 372 # rerun. When generating files are changed, dfagen must be run to ensure |
| 353 # that generated files are up to date. Presubmit script uses | 373 # that generated files are up to date. Presubmit script uses |
| 354 # protected_files.json to perform these checks. | 374 # protected_files.json to perform these checks. |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 canonical_filename = CanonicalizeFilename(filename) | 416 canonical_filename = CanonicalizeFilename(filename) |
| 397 protected_files['generating'].append(canonical_filename) | 417 protected_files['generating'].append(canonical_filename) |
| 398 with open(target_filename, 'w') as target_file: | 418 with open(target_filename, 'w') as target_file: |
| 399 json.dump(protected_files, target_file, sort_keys=True, indent=2) | 419 json.dump(protected_files, target_file, sort_keys=True, indent=2) |
| 400 | 420 |
| 401 calculate_hash_sums = env.Command( | 421 calculate_hash_sums = env.Command( |
| 402 target='%s/protected_files.json' % gen_dir, | 422 target='%s/protected_files.json' % gen_dir, |
| 403 source=protected_files, | 423 source=protected_files, |
| 404 action=CalculateHashSums) | 424 action=CalculateHashSums) |
| 405 env.Depends(calculate_hash_sums, dfacheckvalidator_tests) | 425 env.Depends(calculate_hash_sums, dfacheckvalidator_tests) |
| 426 dfafullcheckvalidator_tests.append(calculate_hash_sums) |
| 427 dfacheckvalidator_tests.append(calculate_hash_sums) |
| 406 | 428 |
| 407 env.Alias('dfacheckvalidator', calculate_hash_sums) | 429 env.Alias('dfafullcheckvalidator', dfafullcheckvalidator_tests) |
| 430 |
| 431 env.Alias('dfacheckvalidator', dfacheckvalidator_tests) |
| 408 | 432 |
| 409 # Targeted tests: RDFA validator test, dis section checker and spec_val test. | 433 # Targeted tests: RDFA validator test, dis section checker and spec_val test. |
| 410 | 434 |
| 411 for bits in ['32', '64']: | 435 for bits in ['32', '64']: |
| 412 tests_mask = ( | 436 tests_mask = ( |
| 413 '${MAIN_DIR}/src/trusted/validator_ragel/testdata/%s/*.test' % bits) | 437 '${MAIN_DIR}/src/trusted/validator_ragel/testdata/%s/*.test' % bits) |
| 414 | 438 |
| 415 if env.Bit('regenerate_golden'): | 439 if env.Bit('regenerate_golden'): |
| 416 update_option = ['--update'] | 440 update_option = ['--update'] |
| 417 else: | 441 else: |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 | 497 |
| 474 if env.Bit('regenerate_golden'): | 498 if env.Bit('regenerate_golden'): |
| 475 # Don't want these tests run in parallel because they write | 499 # Don't want these tests run in parallel because they write |
| 476 # to .test files. | 500 # to .test files. |
| 477 SideEffect(tests_mask, spec_test) | 501 SideEffect(tests_mask, spec_test) |
| 478 | 502 |
| 479 # Spec test uses @dis section in test files, which in turn is updated | 503 # Spec test uses @dis section in test files, which in turn is updated |
| 480 # by dis_section_test. | 504 # by dis_section_test. |
| 481 if env.Bit('target_x86'): | 505 if env.Bit('target_x86'): |
| 482 env.Depends(spec_test, dis_section_test) | 506 env.Depends(spec_test, dis_section_test) |
| OLD | NEW |