| OLD | NEW |
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 Import('env') | 5 Import('env') |
| 6 | 6 |
| 7 # Browser tests for the pnacl translator. This requires starting with a pexe. | 7 # Browser tests for the pnacl translator. This requires starting with a pexe. |
| 8 if not (env.Bit('bitcode') and env.Bit('pnacl_generate_pexe')): | 8 if not (env.Bit('bitcode') and env.Bit('pnacl_generate_pexe')): |
| 9 Return() | 9 Return() |
| 10 | 10 |
| 11 # The PNaCl coordinator cannot yet handle GLibC-based pexe. | 11 # The PNaCl coordinator cannot yet handle GLibC-based pexe. |
| 12 # The driver cannot build the pexe on x86-64 for now. | 12 # The driver cannot build the pexe on x86-64 for now. |
| 13 # The bitcode link arbitrarily picks x86-32 as the ARCH, but the | 13 # The bitcode link arbitrarily picks x86-32 as the ARCH, but the |
| 14 # glibc bitcode link line uses native x86-64 libs instead of bitcode | 14 # glibc bitcode link line uses native x86-64 libs instead of bitcode |
| 15 # stubs, so there is a mismatch: | 15 # stubs, so there is a mismatch: |
| 16 # http://code.google.com/p/nativeclient/issues/detail?id=2451 | 16 # http://code.google.com/p/nativeclient/issues/detail?id=2451 |
| 17 # Luckily, it can build the x86-32 pexe. That works, mostly because | 17 # Luckily, it can build the x86-32 pexe. That works, mostly because |
| 18 # the hello-world example doesn't depend on pso's, etc. | 18 # the hello-world example doesn't depend on pso's, etc. |
| 19 if env.Bit('nacl_glibc') and env.Bit('target_x86_64'): | 19 if env.Bit('nacl_glibc') and env.Bit('target_x86_64'): |
| 20 Return() | 20 Return() |
| 21 | 21 |
| 22 #---------------------------------------------------------------------- | |
| 23 # Test pexe translation. | |
| 24 | |
| 25 # Specify the object file to prevent junk from getting left over | |
| 26 # in source directory. SCons will default to point "-o" to the source | |
| 27 # directory if it is an absolute directory. | |
| 28 test_example_obj = env.ComponentObject( | |
| 29 'pnacl_test_example_obj', | |
| 30 '${SCONSTRUCT_DIR}/tests/ppapi_test_example/ppapi_test_example.cc') | |
| 31 | |
| 32 pexe_name = env.ProgramNameForNmf('pnacl_test_example') | |
| 33 | |
| 34 test_example_pexe = env.ComponentProgram( | |
| 35 pexe_name, | |
| 36 [test_example_obj], | |
| 37 EXTRA_LIBS=['ppapi', | |
| 38 'ppapi_test_lib', | |
| 39 'platform', # for CHECK | |
| 40 'pthread', | |
| 41 'gio', | |
| 42 ]) | |
| 43 | |
| 44 # Grab test routines. | |
| 45 borrowed_file = '${STAGING_DIR}/ppapi_test_example.js', | |
| 46 | |
| 47 env.Publish(pexe_name, | |
| 48 'run', | |
| 49 ['pnacl_test_example.html']) | |
| 50 | |
| 51 node = env.PPAPIBrowserTester( | |
| 52 'pnacl_test_example.out', | |
| 53 url='pnacl_test_example.html', | |
| 54 nmf_names=['pnacl_test_example'], | |
| 55 files=env.ExtractPublishedFiles(pexe_name) + [borrowed_file]) | |
| 56 | |
| 57 env.AddNodeToTestSuite(node, | |
| 58 ['chrome_browser_tests'], | |
| 59 'run_pnacl_example_browser_test', | |
| 60 is_broken=env.PPAPIBrowserTesterIsBroken()) | |
| 61 | |
| 62 #### Test error handling. | 22 #### Test error handling. |
| 63 | 23 |
| 64 # We should add more cases, e.g., try a bad library to crash ld, | 24 # We should add more cases, e.g., try a bad library to crash ld, |
| 65 # try a more malicious bitcode, try to exhaust resources, etc. | 25 # try a more malicious bitcode, try to exhaust resources, etc. |
| 66 # The current llc tests, don't actually crash LLC, they only | 26 # The current llc tests, don't actually crash LLC, they only |
| 67 # make llc exit w/ an abnormal status. | 27 # make llc exit w/ an abnormal status. |
| 68 | 28 |
| 29 program_fragment_obj = env.ComponentObject('program_fragment.cc') |
| 30 |
| 69 pnacl_bad_files = env.Replicate( | 31 pnacl_bad_files = env.Replicate( |
| 70 '${STAGING_DIR}', | 32 '${STAGING_DIR}', |
| 71 ['pnacl_bad_doesnotexist.nmf', | 33 ['pnacl_bad_doesnotexist.nmf', |
| 72 'pnacl_bad_doesnotexist_pexe_only.nmf', | 34 'pnacl_bad_doesnotexist_pexe_only.nmf', |
| 73 # This one is just a text file that begins with "BC". | 35 # This one is just a text file that begins with "BC". |
| 74 'bad.pexe', | 36 'bad.pexe', |
| 75 'pnacl_bad_pexe.nmf', | 37 'pnacl_bad_pexe.nmf', |
| 76 # This one is the hello world bitcode .ll w/ a missing instruction. | 38 # This one is the hello world bitcode .ll w/ a missing instruction. |
| 77 'bad2.pexe', | 39 'bad2.pexe', |
| 78 'pnacl_bad2_pexe.nmf', | 40 'pnacl_bad2_pexe.nmf', |
| 79 # Borrow the bitcode file from the test above and treat it as a | 41 program_fragment_obj, |
| 80 # pexe so that the compile succeeds but linking fails. | |
| 81 'pnacl_test_example_obj.bc', | |
| 82 'pnacl_bad_pexe_undefined_syms.nmf', | 42 'pnacl_bad_pexe_undefined_syms.nmf', |
| 83 'pnacl_bad_test.html', | 43 'pnacl_bad_test.html', |
| 84 ]) | 44 ]) |
| 85 | 45 |
| 86 env.Depends(pnacl_bad_files, test_example_obj) | |
| 87 | |
| 88 # Borrow bad load test harness. | 46 # Borrow bad load test harness. |
| 89 borrowed_file = '${STAGING_DIR}/ppapi_bad.js', | 47 borrowed_file = '${STAGING_DIR}/ppapi_bad.js', |
| 90 | 48 |
| 91 node = env.PPAPIBrowserTester( | 49 node = env.PPAPIBrowserTester( |
| 92 'pnacl_bad_test.out', | 50 'pnacl_bad_test.out', |
| 93 url='pnacl_bad_test.html', | 51 url='pnacl_bad_test.html', |
| 94 # TODO(jvoung): list "nmfs" without clashing with Replicate. | 52 # TODO(jvoung): list "nmfs" without clashing with Replicate. |
| 95 # Perhaps just use publish instead of Replicate. | 53 # Perhaps just use publish instead of Replicate. |
| 96 # There may also be an issue in that the scons manifest generator is picky | 54 # There may also be an issue in that the scons manifest generator is picky |
| 97 # about nexes that don't exist. | 55 # about nexes that don't exist. |
| 98 files=pnacl_bad_files + [borrowed_file], | 56 files=pnacl_bad_files + [borrowed_file], |
| 99 args=['--allow_404', '--prefer_portable_in_manifest']) | 57 args=['--allow_404', '--prefer_portable_in_manifest']) |
| 100 | 58 |
| 101 env.AddNodeToTestSuite(node, | 59 env.AddNodeToTestSuite(node, |
| 102 ['chrome_browser_tests'], | 60 ['chrome_browser_tests'], |
| 103 'run_pnacl_bad_browser_test', | 61 'run_pnacl_bad_browser_test', |
| 104 is_broken=env.PPAPIBrowserTesterIsBroken()) | 62 is_broken=env.PPAPIBrowserTesterIsBroken()) |
| OLD | NEW |