- add sources.
[platform/framework/web/crosswalk.git] / src / ppapi / native_client / tests / ppapi_browser / bad / nacl.scons
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 # Tests fatal errors that occur during loading.
7 # (See ppapi_browser/crash for fatal errors that occur after loading).
8 # TODO(polina): rename the directory and browser test to bad_load
9 #
10 # Manual testing with localhost:5103/scons-out/.../staging/ppapi_bad.html:
11 #   scons --mode=nacl ppapi_bad
12 # Automatic testing:
13 #   scons run_ppapi_bad_browser_test
14 #
15
16 Import('env')
17
18 # TODO(robertm): those should not be necessary once we go -std=c99
19 env.FilterOut(CFLAGS=['-pedantic'])
20 env.FilterOut(CCFLAGS=['-pedantic'])
21 env.Replace(TEST_DIR='${SOURCE_ROOT}/ppapi/native_client/tests/ppapi_browser/' +
22                      'bad')
23
24 ppapi_bad_files = [
25   'ppapi_bad.html',
26   'ppapi_bad.js',
27   'ppapi_bad_crossorigin.nmf',
28   'ppapi_bad_doesnotexist.nmf',
29   'ppapi_bad_magic.nmf',
30   'ppapi_bad_manifest_uses_nexes.nmf',
31   'ppapi_bad_manifest_bad_files.nmf',
32   'ppapi_bad_manifest_nexe_arch.nmf',
33   env.File('${SCONSTRUCT_DIR}/tools/browser_tester/browserdata/nacltest.js')
34   ]
35 ppapi_bad = env.Replicate('${STAGING_DIR}', ppapi_bad_files)
36
37 nmf_names = []
38 # Compile all nexes embedded into the above html
39 # TODO(bbudge) Re-enable tests as the IPC proxy gets equivalent error reporting
40 # or delete them after the proxy switch if they're specific to SRPC.
41 # http://crbug.com/160076
42 for kind in [ 'ppp_initialize', 'ppp_initialize_crash',
43               'no_ppp_instance', 'get_ppp_instance_crash',
44               #'get_ppp_messaging_crash', 'get_ppp_printing_crash',
45               'ppp_instance_didcreate', 'ppp_instance_didcreate_crash',
46               #'event_replay_crash'
47             ]:
48   bad_nmf = 'ppapi_bad_%s' % kind
49   bad_nexe = env.ProgramNameForNmf('ppapi_bad_%s' % kind)
50   env.ComponentProgram(bad_nexe,
51                        ['ppapi_bad_%s.cc' % kind],
52                        EXTRA_LIBS=['ppapi',
53                                    'platform',
54                                    'pthread',
55                                    'gio'])
56   nmf_names.append(bad_nmf)
57   ppapi_bad_files.extend(env.ExtractPublishedFiles(bad_nexe))
58   env.Depends(ppapi_bad, env.Alias(bad_nexe))
59
60 # "scons --mode=nacl ppapi_bad" will publish the html and all of its
61 # dependencies to scons-out.
62 env.Alias('ppapi_bad', ppapi_bad)
63
64 node = env.PPAPIBrowserTester(
65     'ppapi_bad_browser_test.out',
66     url='ppapi_bad.html',
67     nmf_names=nmf_names,
68     test_args=[('is_pnacl', int(env.Bit('pnacl_generate_pexe')))],
69     files=[env.File(f) for f in ppapi_bad_files],
70     args=['--allow_404'])
71
72 # This test is failing on Windows:
73 #   crbug.com/98720
74 # This test is failing on Valgrind because of multiple nexes.
75 env.AddNodeToTestSuite(node,
76                        ['chrome_browser_tests'],
77                        'run_ppapi_bad_browser_test',
78                        is_broken=env.PPAPIBrowserTesterIsBroken() or
79                                  env.Bit('host_windows') or
80                                  env.Bit('running_on_valgrind'))
81
82
83 # Bad nexe tests that won't work in PNaCl (native)
84 # For example, partly_invalid.nexe has inline assembly in its source files.
85 # Just bail out here for PNaCl, since the NMF will require the .nexe
86 # to be built.
87 if env.Bit('bitcode'):
88   Return()
89
90 nacltest_js = env.File('${SCONSTRUCT_DIR}/tools/browser_tester/browserdata/' +
91                        'nacltest.js')
92 partly_invalid = env.File('${STAGING_DIR}/partly_invalid${PROGSUFFIX}')
93 nmf = '${TEST_DIR}/partly_invalid.nmf'
94 if not env.Bit('nacl_glibc'):
95   ppapi_bad_native_files = [
96       env.File('ppapi_bad_native.html'),
97       env.File('${SCONSTRUCT_DIR}/tests/ppapi_browser/' +
98                'progress_event_listener.js'),
99       nacltest_js]
100   replicated_files = env.Replicate('${STAGING_DIR}', ppapi_bad_native_files)
101   env.Alias('all_programs', replicated_files)
102   ppapi_bad_native_files.append(partly_invalid)
103
104   node = env.PPAPIBrowserTester(
105       'ppapi_bad_native_test.out',
106       url='ppapi_bad_native.html',
107       nmfs=[nmf],
108       files=ppapi_bad_native_files,
109       )
110 else:
111   ppapi_bad_native_files = [
112       env.File('${TEST_DIR}/ppapi_bad_native_glibc.html'),
113       nacltest_js]
114   replicated_files = env.Replicate('${STAGING_DIR}', ppapi_bad_native_files)
115   env.Alias('all_programs', replicated_files)
116   ppapi_bad_native_files.append(partly_invalid)
117
118   node = env.PPAPIBrowserTester(
119       'ppapi_bad_native_test.out',
120       url='ppapi_bad_native_glibc.html',
121       nmfs=[nmf],
122       files=ppapi_bad_native_files,
123       nacl_exe_stderr={
124           'file': '${TARGET_ROOT}/test_results/ppapi_bad_native_test.log',
125           'golden': '${TEST_DIR}/ppapi_bad_native_glibc.stderr'}
126       )
127
128 env.AddNodeToTestSuite(node,
129                        ['chrome_browser_tests'],
130                        'run_ppapi_bad_native_test',
131                        is_broken=env.PPAPIBrowserTesterIsBroken())