Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Side by Side Diff: ppapi/native_client/chrome_main.scons

Issue 10914053: Relocating files in the nacl repo that belong in chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 json
7 import os
8 import shutil
9 import sys
10
11 sys.path.append(Dir('#/tools').abspath)
12 import command_tester
13 import test_lib
14
15 Import(['pre_base_env'])
16
17 # Underlay things migrating to ppapi repo.
18 Dir('#/..').addRepository(Dir('#/../ppapi'))
19
20 # Load a config file from the Chrome repo. This allows scons files to be added
21 # and removed in Chrome without requiring a DEPS roll.
22 ppapi_scons_files = {}
23 execfile(
24 File('#/../ppapi/native_client/ppapi_scons_files.py').abspath,
25 {}, # Globals
26 ppapi_scons_files)
27
28 # Append a list of files to another, filtering out the files that already exist.
29 # Filtering helps migrate declarations between repos by preventing redundant
30 # declarations from causing an error.
31 def ExtendFileList(existing, additional):
32 # Avoid quadratic behavior by using a set.
33 combined = set()
34 for file_name in existing + additional:
35 if file_name in combined:
36 print 'WARNING: two references to file %s in the build.' % file_name
37 combined.add(file_name)
38 return sorted(combined)
39
40 ppapi_scons_files['nonvariant_test_scons_files'] = ExtendFileList(
41 ppapi_scons_files.get('nonvariant_test_scons_files', []), [
42 'tests/nacl_browser/browser_dynamic_library/nacl.scons',
43 'tests/nacl_browser/browser_startup_time/nacl.scons',
44 'tests/nacl_browser/exit_status/nacl.scons',
45 'tests/nacl_browser/inbrowser_test_runner/nacl.scons',
46 'tests/nacl_browser/manifest_file/nacl.scons',
47 'tests/nacl_browser/nameservice/nacl.scons',
48 'tests/nacl_browser/postmessage_redir/nacl.scons',
49 ])
50
51 ppapi_scons_files['irt_variant_test_scons_files'] = ExtendFileList(
52 ppapi_scons_files.get('irt_variant_test_scons_files', []), [
53 # Disabled by Brad Chen 4 Sep to try to green Chromium
54 # nacl_integration tests
55 #'tests/nacl_browser/fault_injection/nacl.scons',
56 'tests/nacl.scons',
57 'tests/nacl_browser/pnacl_client_translator/nacl.scons',
58 ])
59
60 ppapi_scons_files['untrusted_scons_files'] = ExtendFileList(
61 ppapi_scons_files.get('untrusted_scons_files', []), [
62 'src/untrusted/irt_stub/nacl.scons',
63 'src/untrusted/nacl_ppapi_util/nacl.scons',
64 'src/untrusted/pnacl_irt_shim/nacl.scons',
65 'src/untrusted/pnacl_support_extension/nacl.scons',
66 ])
67
68 EXTRA_ENV = ['XAUTHORITY', 'HOME', 'DISPLAY', 'SSH_TTY', 'KRB5CCNAME']
69
70 def SetupBrowserEnv(env):
71 for var_name in EXTRA_ENV:
72 if var_name in os.environ:
73 env['ENV'][var_name] = os.environ[var_name]
74
75 pre_base_env.AddMethod(SetupBrowserEnv)
76
77
78 def GetHeadlessPrefix(env):
79 if env.Bit('browser_headless') and env.Bit('host_linux'):
80 return ['xvfb-run', '--auto-servernum']
81 else:
82 # Mac and Windows do not seem to have an equivalent.
83 return []
84
85 pre_base_env.AddMethod(GetHeadlessPrefix)
86
87
88 pre_base_env['CHROME_DOWNLOAD_DIR'] = \
89 pre_base_env.Dir(ARGUMENTS.get('chrome_binaries_dir', '#chromebinaries'))
90
91 def ChromeBinaryArch(env):
92 arch = env['BUILD_FULLARCH']
93 # Currently there are no 64-bit Chrome binaries for Windows or Mac OS X.
94 if (env.Bit('host_windows') or env.Bit('host_mac')) and arch == 'x86-64':
95 arch = 'x86-32'
96 return arch
97
98 pre_base_env.AddMethod(ChromeBinaryArch)
99
100
101 def DownloadedChromeBinary(env):
102 if env.Bit('host_linux'):
103 os_name = 'linux'
104 binary = 'chrome'
105 elif env.Bit('host_windows'):
106 os_name = 'windows'
107 binary = 'chrome.exe'
108 elif env.Bit('host_mac'):
109 os_name = 'mac'
110 binary = 'Chromium.app/Contents/MacOS/Chromium'
111 else:
112 raise Exception('Unsupported OS')
113
114 arch = env.ChromeBinaryArch()
115 return env.File(os.path.join('${CHROME_DOWNLOAD_DIR}',
116 '%s_%s' % (os_name, arch), binary))
117
118 pre_base_env.AddMethod(DownloadedChromeBinary)
119
120
121 def ChromeBinary(env):
122 if 'chrome_browser_path' in ARGUMENTS:
123 return env.File(env.SConstructAbsPath(ARGUMENTS['chrome_browser_path']))
124 else:
125 return env.DownloadedChromeBinary()
126
127 pre_base_env.AddMethod(ChromeBinary)
128
129
130 def GetPPAPIPluginPath(env, allow_64bit_redirect=True):
131 if 'force_ppapi_plugin' in ARGUMENTS:
132 return env.SConstructAbsPath(ARGUMENTS['force_ppapi_plugin'])
133 if env.Bit('mac'):
134 fn = env.File('${STAGING_DIR}/ppNaClPlugin')
135 else:
136 fn = env.File('${STAGING_DIR}/${SHLIBPREFIX}ppNaClPlugin${SHLIBSUFFIX}')
137 if allow_64bit_redirect and env.Bit('target_x86_64'):
138 # On 64-bit Windows and on Mac, we need the 32-bit plugin because
139 # the browser is 32-bit.
140 # Unfortunately it is tricky to build the 32-bit plugin (and all the
141 # libraries it needs) in a 64-bit build... so we'll assume it has already
142 # been built in a previous invocation.
143 # TODO(ncbray) better 32/64 builds.
144 if env.Bit('windows'):
145 fn = env.subst(fn).abspath.replace('-win-x86-64', '-win-x86-32')
146 elif env.Bit('mac'):
147 fn = env.subst(fn).abspath.replace('-mac-x86-64', '-mac-x86-32')
148 return fn
149
150 pre_base_env.AddMethod(GetPPAPIPluginPath)
151
152
153 # runnable-ld.so log has following format:
154 # lib_name => path_to_lib (0x....address)
155 def ParseLibInfoInRunnableLdLog(line):
156 pos = line.find(' => ')
157 if pos < 0:
158 return None
159 lib_name = line[:pos].strip()
160 lib_path = line[pos+4:]
161 pos1 = lib_path.rfind(' (')
162 if pos1 < 0:
163 return None
164 lib_path = lib_path[:pos1]
165 return lib_name, lib_path
166
167
168 # Expected name of the temporary .libs file which stores glibc library
169 # dependencies in "lib_name => lib_info" format
170 # (see ParseLibInfoInRunnableLdLog)
171 def GlibcManifestLibsListFilename(manifest_base_name):
172 return '${STAGING_DIR}/%s.libs' % manifest_base_name
173
174
175 # Copy libs and manifest to the target directory.
176 # source[0] is a manifest file
177 # source[1] is a .libs file with a list of libs generated by runnable-ld.so
178 def CopyLibsForExtensionCommand(target, source, env):
179 source_manifest = str(source[0])
180 target_manifest = str(target[0])
181 shutil.copyfile(source_manifest, target_manifest)
182 target_dir = os.path.dirname(target_manifest)
183 libs_file = open(str(source[1]), 'r')
184 for line in libs_file.readlines():
185 lib_info = ParseLibInfoInRunnableLdLog(line)
186 if lib_info:
187 lib_name, lib_path = lib_info
188 # Note: This probably does NOT work with pnacl _pexes_ right now, because
189 # the NEEDED metadata in the bitcode doesn't have the original file paths.
190 # This should probably be done without such knowledge.
191 if lib_path == 'NaClMain':
192 # This is a fake file name, which we cannot copy.
193 continue
194 shutil.copyfile(lib_path, os.path.join(target_dir, lib_name))
195 shutil.copyfile(env.subst('${NACL_SDK_LIB}/runnable-ld.so'),
196 os.path.join(target_dir, 'runnable-ld.so'))
197 libs_file.close()
198
199
200 # Extensions are loaded from directory on disk and so all dynamic libraries
201 # they use must be copied to extension directory. The option --extra_serving_dir
202 # does not help us in this case.
203 def CopyLibsForExtension(env, target_dir, manifest):
204 if not env.Bit('nacl_glibc'):
205 return env.Install(target_dir, manifest)
206 manifest_base_name = os.path.basename(str(env.subst(manifest)))
207 lib_list_node = env.File(GlibcManifestLibsListFilename(manifest_base_name))
208 nmf_node = env.Command(
209 target_dir + '/' + manifest_base_name,
210 [manifest, lib_list_node],
211 CopyLibsForExtensionCommand)
212 return nmf_node
213
214 pre_base_env.AddMethod(CopyLibsForExtension)
215
216
217
218 def WhitelistLibsForExtensionCommand(target, source, env):
219 # Load existing extension manifest.
220 src_file = open(source[0].abspath, 'r')
221 src_json = json.load(src_file)
222 src_file.close()
223
224 # Load existing 'web_accessible_resources' key.
225 if 'web_accessible_resources' not in src_json:
226 src_json['web_accessible_resources'] = []
227 web_accessible = src_json['web_accessible_resources']
228
229 # Load list of libraries, and add libraries to web_accessible list.
230 libs_file = open(source[1].abspath, 'r')
231 for line in libs_file.readlines():
232 lib_info = ParseLibInfoInRunnableLdLog(line)
233 if lib_info:
234 web_accessible.append(lib_info[0])
235 # Also add the dynamic loader, which won't be in the libs_file.
236 web_accessible.append('runnable-ld.so')
237 libs_file.close()
238
239 # Write out the appended-to extension manifest.
240 target_file = open(target[0].abspath, 'w')
241 json.dump(src_json, target_file, sort_keys=True, indent=2)
242 target_file.close()
243
244
245 # Whitelist glibc shared libraries (if necessary), so that they are
246 # 'web_accessible_resources'. This allows the libraries hosted at the origin
247 # chrome-extension://[PACKAGE ID]/
248 # to be made available to webpages that use this NaCl extension,
249 # which are in a different origin.
250 # See: http://code.google.com/chrome/extensions/manifest.html
251 #
252 # Alternatively, we could try to use the chrome commandline switch
253 # '--disable-extensions-resource-whitelist', but that would not be what
254 # users will need to do.
255 def WhitelistLibsForExtension(env, target_dir, nmf, extension_manifest):
256 if env.Bit('nacl_static_link'):
257 # For static linking, assume the nexe and nmf files are already
258 # whitelisted, so there is no need to add entries to the extension_manifest.
259 return env.Install(target_dir, extension_manifest)
260 nmf_base_name = os.path.basename(env.File(nmf).abspath)
261 lib_list_node = env.File(GlibcManifestLibsListFilename(nmf_base_name))
262 manifest_base_name = os.path.basename(env.File(extension_manifest).abspath)
263 extension_manifest_node = env.Command(
264 target_dir + '/' + manifest_base_name,
265 [extension_manifest, lib_list_node],
266 WhitelistLibsForExtensionCommand)
267 return extension_manifest_node
268
269 pre_base_env.AddMethod(WhitelistLibsForExtension)
270
271
272 # Generate manifest from newlib manifest and the list of libs generated by
273 # runnable-ld.so.
274 def GenerateManifestFunc(target, source, env):
275 # Open the original manifest and parse it.
276 source_file = open(str(source[0]), 'r')
277 obj = json.load(source_file)
278 source_file.close()
279 # Open the file with ldd-format list of NEEDED libs and parse it.
280 libs_file = open(str(source[1]), 'r')
281 lib_names = []
282 arch = env.subst('${TARGET_FULLARCH}')
283 for line in libs_file.readlines():
284 lib_info = ParseLibInfoInRunnableLdLog(line)
285 if lib_info:
286 lib_name, _ = lib_info
287 lib_names.append(lib_name)
288 libs_file.close()
289 # Inject the NEEDED libs into the manifest.
290 if 'files' not in obj:
291 obj['files'] = {}
292 for lib_name in lib_names:
293 obj['files'][lib_name] = {}
294 obj['files'][lib_name][arch] = {}
295 obj['files'][lib_name][arch]['url'] = lib_name
296 # Put what used to be specified under 'program' into 'main.nexe'.
297 obj['files']['main.nexe'] = {}
298 for k, v in obj['program'].items():
299 obj['files']['main.nexe'][k] = v.copy()
300 v['url'] = 'runnable-ld.so'
301 # Write the new manifest!
302 target_file = open(str(target[0]), 'w')
303 json.dump(obj, target_file, sort_keys=True, indent=2)
304 target_file.close()
305 return 0
306
307 def GenerateManifestPnacl(env, dest_file, manifest, exe_file):
308 return env.Command(
309 dest_file,
310 ['${GENNMF}', exe_file, manifest],
311 # Generate a flat url scheme to simplify file-staging.
312 ('${SOURCES[0]} ${SOURCES[1]} -L${NACL_SDK_LIB} -L${LIB_DIR} '
313 ' --flat-url-scheme --base-nmf ${SOURCES[2]} -o ${TARGET}'))
314
315 def GenerateManifestDynamicLink(env, dest_file, lib_list_file,
316 manifest, exe_file):
317 # Run sel_ldr on the nexe to trace the NEEDED libraries.
318 lib_list_node = env.Command(
319 lib_list_file,
320 [env.GetSelLdr(),
321 '${NACL_SDK_LIB}/runnable-ld.so',
322 exe_file,
323 '${SCONSTRUCT_DIR}/DEPS'],
324 # We ignore the return code using '-' in order to build tests
325 # where binaries do not validate. This is a Scons feature.
326 '-${SOURCES[0]} -a -E LD_TRACE_LOADED_OBJECTS=1 ${SOURCES[1]} '
327 '--library-path ${NACL_SDK_LIB}:${LIB_DIR} ${SOURCES[2].posix} '
328 '> ${TARGET}')
329 return env.Command(dest_file,
330 [manifest, lib_list_node],
331 GenerateManifestFunc)[0]
332
333
334 def GenerateSimpleManifestStaticLink(env, dest_file, exe_name):
335 def Func(target, source, env):
336 archs = ('x86-32', 'x86-64', 'arm')
337 nmf_data = {'program': dict((arch, {'url': '%s_%s.nexe' % (exe_name, arch)})
338 for arch in archs)}
339 fh = open(target[0].abspath, 'w')
340 json.dump(nmf_data, fh, sort_keys=True, indent=2)
341 fh.close()
342 node = env.Command(dest_file, [], Func)[0]
343 # Scons does not track the dependency of dest_file on exe_name or on
344 # the Python code above, so we should always recreate dest_file when
345 # it is used.
346 env.AlwaysBuild(node)
347 return node
348
349
350 def GenerateSimpleManifest(env, dest_file, exe_name):
351 if env.Bit('pnacl_generate_pexe'):
352 static_manifest = GenerateSimpleManifestStaticLink(
353 env, '%s.static' % dest_file, exe_name)
354 return GenerateManifestPnacl(env, dest_file, static_manifest,
355 '${STAGING_DIR}/%s.pexe' %
356 env.ProgramNameForNmf(exe_name))
357 elif env.Bit('nacl_static_link'):
358 return GenerateSimpleManifestStaticLink(env, dest_file, exe_name)
359 else:
360 static_manifest = GenerateSimpleManifestStaticLink(
361 env, '%s.static' % dest_file, exe_name)
362 return GenerateManifestDynamicLink(
363 env, dest_file, '%s.tmp_lib_list' % dest_file, static_manifest,
364 '${STAGING_DIR}/%s.nexe' % env.ProgramNameForNmf(exe_name))
365
366 pre_base_env.AddMethod(GenerateSimpleManifest)
367
368
369 # Returns a pair (main program, is_portable), based on the program
370 # specified in manifest file.
371 def GetMainProgramFromManifest(env, manifest):
372 obj = json.loads(env.File(manifest).get_contents())
373 program_dict = obj['program']
374 if env.Bit('pnacl_generate_pexe') and 'portable' in program_dict:
375 return program_dict['portable']['pnacl-translate']['url']
376 else:
377 return program_dict[env.subst('${TARGET_FULLARCH}')]['url']
378
379
380 # Returns scons node for generated manifest.
381 def GeneratedManifestNode(env, manifest):
382 manifest = env.subst(manifest)
383 manifest_base_name = os.path.basename(manifest)
384 main_program = GetMainProgramFromManifest(env, manifest)
385 result = env.File('${STAGING_DIR}/' + manifest_base_name)
386 # Always generate the manifest for nacl_glibc and pnacl pexes.
387 # For nacl_glibc, generating the mapping of shared libraries is non-trivial.
388 # For pnacl, the manifest currently hosts a sha for the pexe.
389 if not env.Bit('nacl_glibc') and not env.Bit('pnacl_generate_pexe'):
390 env.Install('${STAGING_DIR}', manifest)
391 return result
392 if env.Bit('pnacl_generate_pexe'):
393 return GenerateManifestPnacl(
394 env,
395 '${STAGING_DIR}/' + manifest_base_name,
396 manifest,
397 env.File('${STAGING_DIR}/' + os.path.basename(main_program)))
398 else:
399 return GenerateManifestDynamicLink(
400 env, '${STAGING_DIR}/' + manifest_base_name,
401 # Note that CopyLibsForExtension() and WhitelistLibsForExtension()
402 # assume that it can find the library list file under this filename.
403 GlibcManifestLibsListFilename(manifest_base_name),
404 manifest,
405 env.File('${STAGING_DIR}/' + os.path.basename(main_program)))
406 return result
407
408
409 def GetPnaclExtensionRootNode(env):
410 """Get the scons node representing the root directory of pnacl support files.
411 """
412 # This is "built" by src/untrusted/pnacl_support_extension/nacl.scons.
413 return env.Dir('${DESTINATION_ROOT}/pnacl_support')
414
415 pre_base_env.AddMethod(GetPnaclExtensionRootNode)
416
417 def GetPnaclExtensionDummyVersion(env):
418 """ We supply a dummy version number when packaging the test-extension
419 that is probably newer than all other versions. """
420 return '9999.9.9.9'
421
422 pre_base_env.AddMethod(GetPnaclExtensionDummyVersion)
423
424 def GetPnaclExtensionNode(env):
425 """Get the scons node representing a specific version of pnacl support files.
426 """
427 # This is "built" by src/untrusted/pnacl_support_extension/nacl.scons.
428 return env.Dir('${DESTINATION_ROOT}/pnacl_support/' +
429 env.GetPnaclExtensionDummyVersion())
430
431 pre_base_env.AddMethod(GetPnaclExtensionNode)
432
433
434 # Compares output_file and golden_file.
435 # If they are different, prints the difference and returns 1.
436 # Otherwise, returns 0.
437 def CheckGoldenFile(golden_file, output_file,
438 filter_regex, filter_inverse, filter_group_only):
439 golden = open(golden_file).read()
440 actual = open(output_file).read()
441 if filter_regex is not None:
442 actual = test_lib.RegexpFilterLines(
443 filter_regex,
444 filter_inverse,
445 filter_group_only,
446 actual)
447 if command_tester.DifferentFromGolden(actual, golden, output_file):
448 return 1
449 return 0
450
451
452 # Returns action that compares output_file and golden_file.
453 # This action can be attached to the node with
454 # env.AddPostAction(target, action)
455 def GoldenFileCheckAction(env, output_file, golden_file,
456 filter_regex=None, filter_inverse=False,
457 filter_group_only=False):
458 def ActionFunc(target, source, env):
459 return CheckGoldenFile(env.subst(golden_file), env.subst(output_file),
460 filter_regex, filter_inverse, filter_group_only)
461
462 return env.Action(ActionFunc)
463
464
465 def PPAPIBrowserTester(env,
466 target,
467 url,
468 files,
469 nmfs=None,
470 # List of executable basenames to generate
471 # manifest files for.
472 nmf_names=(),
473 map_files=(),
474 extensions=(),
475 mime_types=(),
476 timeout=30,
477 log_verbosity=2,
478 args=[],
479 # list of key/value pairs that are passed to the test
480 test_args=(),
481 # list of "--flag=value" pairs (no spaces!)
482 browser_flags=None,
483 # redirect streams of NaCl program to files
484 nacl_exe_stdin=None,
485 nacl_exe_stdout=None,
486 nacl_exe_stderr=None,
487 python_tester_script=None,
488 **extra):
489 if 'TRUSTED_ENV' not in env:
490 return []
491
492 # No browser tests run on arm-thumb2
493 # Bug http://code.google.com/p/nativeclient/issues/detail?id=2224
494 if env.Bit('target_arm_thumb2'):
495 return []
496
497 # Handle issues with mutating any python default arg lists.
498 if browser_flags is None:
499 browser_flags = []
500
501 if env.Bit('pnacl_generate_pexe'):
502 # We likely prefer to choose the 'portable' field in nmfs in this mode.
503 args = args + ['--prefer_portable_in_manifest']
504 # Pass through env var controlling streaming translation
505 if 'NACL_STREAMING_TRANSLATION' in os.environ:
506 env['ENV']['NACL_STREAMING_TRANSLATION'] = 'true'
507
508 # Lint the extra arguments that are being passed to the tester.
509 special_args = ['--ppapi_plugin', '--sel_ldr', '--irt_library', '--file',
510 '--map_file', '--extension', '--mime_type', '--tool',
511 '--browser_flag', '--test_arg']
512 for arg_name in special_args:
513 if arg_name in args:
514 raise Exception('%s: %r is a test argument provided by the SCons test'
515 ' wrapper, do not specify it as an additional argument' %
516 (target, arg_name))
517
518 env = env.Clone()
519 env.SetupBrowserEnv()
520
521 if 'scale_timeout' in ARGUMENTS:
522 timeout = timeout * int(ARGUMENTS['scale_timeout'])
523
524 if python_tester_script is None:
525 python_tester_script = env.File('${SCONSTRUCT_DIR}/tools/browser_tester'
526 '/browser_tester.py')
527 command = env.GetHeadlessPrefix() + [
528 '${PYTHON}', python_tester_script,
529 '--browser_path', env.ChromeBinary(),
530 '--url', url,
531 # Fail if there is no response for X seconds.
532 '--timeout', str(timeout)]
533 if not env.Bit('disable_dynamic_plugin_loading'):
534 command.extend(['--ppapi_plugin', env['TRUSTED_ENV'].GetPPAPIPluginPath()])
535 command.extend(['--sel_ldr', env.GetSelLdr()])
536 bootstrap, _ = env.GetBootstrap()
537 if bootstrap is not None:
538 command.extend(['--sel_ldr_bootstrap', bootstrap])
539 if (not env.Bit('disable_dynamic_plugin_loading') or
540 env.Bit('override_chrome_irt')):
541 command.extend(['--irt_library', env.GetIrtNexe(chrome_irt=True)])
542 for dep_file in files:
543 command.extend(['--file', dep_file])
544 for extension in extensions:
545 command.extend(['--extension', extension])
546 if env.Bit('bitcode'):
547 # TODO(jvoung): remove this --extension once we have --pnacl-dir working.
548 command.extend(['--extension', env.GetPnaclExtensionNode().abspath])
549 # Enable the installed version of pnacl, and point to a custom install
550 # directory for testing purposes.
551 browser_flags.append('--enable-pnacl')
552 browser_flags.append('--pnacl-dir=%s' %
553 env.GetPnaclExtensionRootNode().abspath)
554 for dest_path, dep_file in map_files:
555 command.extend(['--map_file', dest_path, dep_file])
556 for file_ext, mime_type in mime_types:
557 command.extend(['--mime_type', file_ext, mime_type])
558 command.extend(['--serving_dir', '${NACL_SDK_LIB}'])
559 command.extend(['--serving_dir', '${LIB_DIR}'])
560 if 'browser_tester_bw' in ARGUMENTS:
561 command.extend(['-b', ARGUMENTS['browser_tester_bw']])
562 if not nmfs is None:
563 for nmf_file in nmfs:
564 generated_manifest = GeneratedManifestNode(env, nmf_file)
565 # We need to add generated manifests to the list of default targets.
566 # The manifests should be generated even if the tests are not run -
567 # the manifests may be needed for manual testing.
568 for group in env['COMPONENT_TEST_PROGRAM_GROUPS']:
569 env.Alias(group, generated_manifest)
570 # Generated manifests are served in the root of the HTTP server
571 command.extend(['--file', generated_manifest])
572 for nmf_name in nmf_names:
573 tmp_manifest = '%s.tmp/%s.nmf' % (target, nmf_name)
574 command.extend(['--map_file', '%s.nmf' % nmf_name,
575 env.GenerateSimpleManifest(tmp_manifest, nmf_name)])
576 if 'browser_test_tool' in ARGUMENTS:
577 command.extend(['--tool', ARGUMENTS['browser_test_tool']])
578
579 # Suppress debugging information on the Chrome waterfall.
580 if env.Bit('disable_flaky_tests') and '--debug' in args:
581 args.remove('--debug')
582
583 command.extend(args)
584 for flag in browser_flags:
585 if flag.find(' ') != -1:
586 raise Exception('Spaces not allowed in browser_flags: '
587 'use --flag=value instead')
588 command.extend(['--browser_flag', flag])
589 for key, value in test_args:
590 command.extend(['--test_arg', str(key), str(value)])
591
592 # Set a given file to be the nexe's stdin.
593 if nacl_exe_stdin is not None:
594 command.extend(['--nacl_exe_stdin', env.subst(nacl_exe_stdin['file'])])
595
596 post_actions = []
597 side_effects = []
598 # Set a given file to be the nexe's stdout or stderr. The tester also
599 # compares this output against a golden file.
600 for stream, params in (
601 ('stdout', nacl_exe_stdout),
602 ('stderr', nacl_exe_stderr)):
603 if params is None:
604 continue
605 stream_file = env.subst(params['file'])
606 side_effects.append(stream_file)
607 command.extend(['--nacl_exe_' + stream, stream_file])
608 if 'golden' in params:
609 golden_file = env.subst(params['golden'])
610 filter_regex = params.get('filter_regex', None)
611 filter_inverse = params.get('filter_inverse', False)
612 filter_group_only = params.get('filter_group_only', False)
613 post_actions.append(
614 GoldenFileCheckAction(
615 env, stream_file, golden_file,
616 filter_regex, filter_inverse, filter_group_only))
617
618 if env.ShouldUseVerboseOptions(extra):
619 env.MakeVerboseExtraOptions(target, log_verbosity, extra)
620 # Heuristic for when to capture output...
621 capture_output = (extra.pop('capture_output', False)
622 or 'process_output_single' in extra)
623 node = env.CommandTest(target,
624 command,
625 # Set to 'huge' so that the browser tester's timeout
626 # takes precedence over the default of the test_suite.
627 size='huge',
628 capture_output=capture_output,
629 **extra)
630 # Also indicate that we depend on the layed-out pnacl translator.
631 if env.Bit('bitcode'):
632 env.Depends(node, env.GetPnaclExtensionNode())
633 for side_effect in side_effects:
634 env.SideEffect(side_effect, node)
635 # We can't check output if the test is not run.
636 if not env.Bit('do_not_run_tests'):
637 for action in post_actions:
638 env.AddPostAction(node, action)
639 return node
640
641 pre_base_env.AddMethod(PPAPIBrowserTester)
642
643
644 # Disabled for ARM and MIPS because Chrome binaries for ARM and MIPS are not
645 # available.
646 def PPAPIBrowserTesterIsBroken(env):
647 return (env.Bit('target_arm') or env.Bit('target_arm_thumb2')
648 or env.Bit('target_mips32'))
649
650 pre_base_env.AddMethod(PPAPIBrowserTesterIsBroken)
651
652 # 3D is disabled everywhere
653 def PPAPIGraphics3DIsBroken(env):
654 return True
655
656 pre_base_env.AddMethod(PPAPIGraphics3DIsBroken)
657
658
659 def AddChromeFilesFromGroup(env, file_group):
660 env['BUILD_SCONSCRIPTS'] = ExtendFileList(
661 env.get('BUILD_SCONSCRIPTS', []),
662 ppapi_scons_files[file_group])
663
664 pre_base_env.AddMethod(AddChromeFilesFromGroup)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698