Commit 3ec729e5 authored by ncbray@chromium.org's avatar ncbray@chromium.org

Port manifest query tests from nacl_integration to browser_tests.

fgets was refactored to read because fdopen was returning null in glibc.
These tests were disabled for glibc without explanation, so working around this
bug loses no coverage.

BUG=154400

Review URL: https://codereview.chromium.org/133033002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@244313 0039d316-1c4b-4281-b951-d872f2087c98
parent 0f996998
/*
* Copyright (c) 2011 The Chromium Authors. All rights reserved.
* Copyright 2014 The Chromium Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
......@@ -45,9 +45,9 @@ void load_manifest(TYPE_nacl_irt_query *query_func) {
str = "File Contents:\n";
FILE *iob = fdopen(desc, "r");
char buffer[4096];
while (fgets(buffer, sizeof buffer, iob) != NULL) {
int len;
while ((len = read(desc, buffer, sizeof buffer - 1)) > 0) {
// NB: fgets does not discard the newline nor any carriage return
// character before that.
//
......@@ -76,10 +76,11 @@ void load_manifest(TYPE_nacl_irt_query *query_func) {
buffer[len-2] = '\n';
buffer[len-1] = '\0';
}
// Null terminate.
buffer[len] = 0;
str += buffer;
}
printf("file loaded: %s\n", str.c_str());
fclose(iob); // closed desc
return;
}
......
<!--
Copyright 2011 The Chromium Authors. All rights reserved.
Copyright 2014 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can
be found in the LICENSE file.
-->
......@@ -15,19 +15,27 @@
<body>
<h1>Native Client Open Resource Before PPAPI Test</h1>
<div>
<embed id="naclModule"
name="naclModule"
width=400 height=400
src="irt_manifest_file.nmf"
basic_tests="1"
stress_tests="0"
style="background-color:gray"
type="application/x-nacl" />
</div>
<script type="text/javascript">
//<![CDATA[
function createModule(id, src, type) {
return createNaClEmbed({
id: id,
src: src,
width: 400,
height: 400,
type: type
});
}
var mime = 'application/x-nacl';
if (getTestArguments()['pnacl'] !== undefined) {
mime = 'application/x-pnacl';
}
var embed = createModule('naclModule', 'irt_manifest_file.nmf', mime);
embed.basic_tests ='2';
embed.stress_tests = '0';
document.body.appendChild(embed);
function setupTests(tester, plugin) {
tester.addAsyncTest('Test_00_Init', function(status) {
plugin.addEventListener('message', function(message_event) {
......
/*
* Copyright (c) 2012 The Chromium Authors. All rights reserved.
* Copyright 2014 The Chromium Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
......@@ -550,9 +550,9 @@ void Worker::ManifestOpenTest(nacl::StringBuffer *sb) {
sb->DiscardOutput();
sb->Printf("File Contents:\n");
FILE *iob = fdopen(desc, "r");
char buffer[4096];
while (fgets(buffer, sizeof buffer, iob) != NULL) {
int len;
while ((len = read(desc, buffer, sizeof buffer - 1)) > 0) {
// NB: fgets does not discard the newline nor any carriage return
// character before that.
//
......@@ -576,14 +576,14 @@ void Worker::ManifestOpenTest(nacl::StringBuffer *sb) {
//
// To defend against such nonsense, we weaken the test slighty,
// and just strip the CR if it is present.
int len = strlen(buffer);
if (len >= 2 && buffer[len-1] == '\n' && buffer[len-2] == '\r') {
buffer[len-2] = '\n';
buffer[len-1] = '\0';
}
// Null terminate.
buffer[len] = 0;
sb->Printf("%s", buffer);
}
fclose(iob); // closed desc
NaClSrpcDtor(&manifest_channel);
return;
}
......
<!--
Copyright 2011 The Chromium Authors. All rights reserved.
Copyright 2014 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can
be found in the LICENSE file.
-->
......@@ -15,19 +15,26 @@
<body>
<h1>Native Client Post Message Manifest File Test</h1>
<div>
<embed id="naclModule"
name="naclModule"
width=400 height=400
src="pm_manifest_file.nmf"
basic_tests="2"
stress_tests="0"
style="background-color:gray"
type="application/x-nacl" />
</div>
<script type="text/javascript">
//<![CDATA[
function createModule(id, src, type) {
return createNaClEmbed({
id: id,
src: src,
width: 400,
height: 400,
type: type
});
}
var mime = 'application/x-nacl';
if (getTestArguments()['pnacl'] !== undefined) {
mime = 'application/x-pnacl';
}
var embed = createModule('naclModule', 'pm_manifest_file.nmf', mime);
embed.basic_tests ='2';
embed.stress_tests = '0';
document.body.appendChild(embed);
function setupTests(tester, plugin) {
tester.addAsyncTest('Test_00_Init', function(status) {
plugin.addEventListener('message', function(message_event) {
......
/*
* Copyright (c) 2012 The Chromium Authors. All rights reserved.
* Copyright 2014 The Chromium Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
......@@ -112,9 +112,9 @@ void TestManifestContents() {
sb.DiscardOutput();
sb.Printf("File Contents:\n");
FILE *iob = fdopen(desc, "r");
char buffer[4096];
while (fgets(buffer, sizeof buffer, iob) != NULL) {
int len;
while ((len = read(desc, buffer, sizeof buffer - 1)) > 0) {
// NB: fgets does not discard the newline nor any carriage return
// character before that.
//
......@@ -143,9 +143,10 @@ void TestManifestContents() {
buffer[len-2] = '\n';
buffer[len-1] = '\0';
}
// Null terminate.
buffer[len] = 0;
sb.Printf("%s", buffer);
}
fclose(iob); // closed desc
sb.Printf("\n");
sb.Printf("Opening non-existent file:\n");
......
<!--
Copyright 2011 The Chromium Authors. All rights reserved.
Copyright 2014 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can
be found in the LICENSE file.
-->
......@@ -15,19 +15,27 @@
<body>
<h1>Native Client Pre-Init Post Message Manifest File Test</h1>
<div>
<embed id="naclModule"
name="naclModule"
width=400 height=400
src="pm_pre_init_manifest_file.nmf"
basic_tests="2"
stress_tests="0"
style="background-color:gray"
type="application/x-nacl" />
</div>
<script type="text/javascript">
//<![CDATA[
function createModule(id, src, type) {
return createNaClEmbed({
id: id,
src: src,
width: 400,
height: 400,
type: type
});
}
var mime = 'application/x-nacl';
if (getTestArguments()['pnacl'] !== undefined) {
mime = 'application/x-pnacl';
}
var embed = createModule('naclModule', 'pm_pre_init_manifest_file.nmf', mime);
embed.basic_tests ='2';
embed.stress_tests = '0';
document.body.appendChild(embed);
function setupTests(tester, plugin) {
tester.addAsyncTest('Test_00_ManifestData', function(status) {
plugin.addEventListener('message', function(message_event) {
......
......@@ -30,6 +30,7 @@
'bad/ppapi_bad_manifest_bad_files.nmf',
'bad/ppapi_bad_manifest_nexe_arch.nmf',
'crash/ppapi_crash.html',
'manifest_file/test_file.txt',
],
},
},
......@@ -478,6 +479,144 @@
'<(DEPTH)/ppapi/ppapi_untrusted.gyp:ppapi_cpp_lib',
],
},
{
'target_name': 'pm_manifest_file',
'type': 'none',
'variables': {
'nexe_target': 'pm_manifest_file',
'build_newlib': 1,
'build_glibc': 1,
# TODO(ncbray) support file injection into PNaCl manifest.
'build_pnacl_newlib': 0,
'nexe_destination_dir': 'nacl_test_data',
'link_flags': [
'-lnacl_ppapi_util',
'-lppapi_cpp',
'-lppapi',
'-lsrpc',
'-lplatform',
'-lgio',
'-limc',
'-limc_syscalls',
'-lweak_ref',
],
'sources': [
'manifest_file/pm_manifest_file_test.cc',
],
'create_nmf_args_portable': [
'-xtest_file:test_file.txt',
'-xnmf says hello world:test_file.txt',
],
'test_files': [
'manifest_file/pm_manifest_file_test.html',
],
},
'dependencies': [
'<(DEPTH)/native_client/tools.gyp:prep_toolchain',
'<(DEPTH)/ppapi/ppapi_untrusted.gyp:ppapi_cpp_lib',
'<(DEPTH)/ppapi/native_client/native_client.gyp:ppapi_lib',
'<(DEPTH)/native_client/src/shared/srpc/srpc.gyp:srpc_lib',
'<(DEPTH)/native_client/src/shared/platform/platform.gyp:platform_lib',
'<(DEPTH)/native_client/src/shared/gio/gio.gyp:gio_lib',
'<(DEPTH)/native_client/src/shared/imc/imc.gyp:imc_lib',
'<(DEPTH)/native_client/src/untrusted/nacl/nacl.gyp:imc_syscalls_lib',
'<(DEPTH)/native_client/src/trusted/weak_ref/weak_ref.gyp:weak_ref_lib',
'nacl_ppapi_util',
],
},
{
'target_name': 'pm_pre_init_manifest_file',
'type': 'none',
'variables': {
'nexe_target': 'pm_pre_init_manifest_file',
'build_newlib': 1,
'build_glibc': 1,
# TODO(ncbray) support file injection into PNaCl manifest.
'build_pnacl_newlib': 0,
'nexe_destination_dir': 'nacl_test_data',
'link_flags': [
'-lnacl_ppapi_util',
'-lppapi_cpp',
'-lppapi',
'-lsrpc',
'-lplatform',
'-lgio',
'-limc',
'-limc_syscalls',
'-lweak_ref',
],
'sources': [
'manifest_file/pm_pre_init_manifest_file_test.cc',
],
'create_nmf_args_portable': [
'-xtest_file:test_file.txt',
'-xnmf says hello world:test_file.txt',
],
'test_files': [
'manifest_file/pm_pre_init_manifest_file_test.html',
],
},
'dependencies': [
'<(DEPTH)/native_client/tools.gyp:prep_toolchain',
'<(DEPTH)/ppapi/ppapi_untrusted.gyp:ppapi_cpp_lib',
'<(DEPTH)/ppapi/native_client/native_client.gyp:ppapi_lib',
'<(DEPTH)/native_client/src/shared/srpc/srpc.gyp:srpc_lib',
'<(DEPTH)/native_client/src/shared/platform/platform.gyp:platform_lib',
'<(DEPTH)/native_client/src/shared/gio/gio.gyp:gio_lib',
'<(DEPTH)/native_client/src/shared/imc/imc.gyp:imc_lib',
'<(DEPTH)/native_client/src/untrusted/nacl/nacl.gyp:imc_syscalls_lib',
'<(DEPTH)/native_client/src/trusted/weak_ref/weak_ref.gyp:weak_ref_lib',
'nacl_ppapi_util',
],
},
{
'target_name': 'irt_manifest_file',
'type': 'none',
'variables': {
'nexe_target': 'irt_manifest_file',
'build_newlib': 1,
# Linking problems - can't find __nacl_irt_query.
'build_glibc': 0,
# TODO(ncbray) support file injection into PNaCl manifest.
'build_pnacl_newlib': 0,
'nexe_destination_dir': 'nacl_test_data',
'link_flags': [
'-lnacl_ppapi_util',
'-lppapi_cpp',
'-lppapi',
'-lsrpc',
'-lplatform',
'-lgio',
'-limc',
'-limc_syscalls',
'-lweak_ref',
'-lnacl',
],
'sources': [
'manifest_file/irt_manifest_file_test.cc',
],
'create_nmf_args_portable': [
'-xtest_file:test_file.txt',
'-xnmf says hello world:test_file.txt',
],
'test_files': [
'manifest_file/irt_manifest_file_test.html',
],
},
'dependencies': [
'<(DEPTH)/native_client/tools.gyp:prep_toolchain',
'<(DEPTH)/ppapi/ppapi_untrusted.gyp:ppapi_cpp_lib',
'<(DEPTH)/ppapi/native_client/native_client.gyp:ppapi_lib',
'<(DEPTH)/native_client/src/shared/srpc/srpc.gyp:srpc_lib',
'<(DEPTH)/native_client/src/shared/platform/platform.gyp:platform_lib',
'<(DEPTH)/native_client/src/shared/gio/gio.gyp:gio_lib',
'<(DEPTH)/native_client/src/shared/imc/imc.gyp:imc_lib',
'<(DEPTH)/native_client/src/untrusted/nacl/nacl.gyp:imc_syscalls_lib',
'<(DEPTH)/native_client/src/untrusted/nacl/nacl.gyp:nacl_lib',
'<(DEPTH)/native_client/src/trusted/weak_ref/weak_ref.gyp:weak_ref_lib',
'nacl_ppapi_util',
],
},
{
'target_name': 'pm_nameservice_test',
'type': 'none',
......
......@@ -80,6 +80,25 @@ NACL_BROWSER_TEST_F(NaClBrowserTest, MAYBE_Crash, {
RunNaClIntegrationTest(FILE_PATH_LITERAL("ppapi_crash.html"));
})
// PNaCl version does not work.
IN_PROC_BROWSER_TEST_F(NaClBrowserTestNewlib, ManifestFile) {
RunNaClIntegrationTest(FILE_PATH_LITERAL("pm_manifest_file_test.html"));
}
IN_PROC_BROWSER_TEST_F(NaClBrowserTestGLibc, ManifestFile) {
RunNaClIntegrationTest(FILE_PATH_LITERAL("pm_manifest_file_test.html"));
}
IN_PROC_BROWSER_TEST_F(NaClBrowserTestNewlib, PreInitManifestFile) {
RunNaClIntegrationTest(FILE_PATH_LITERAL(
"pm_pre_init_manifest_file_test.html"));
}
IN_PROC_BROWSER_TEST_F(NaClBrowserTestGLibc, PreInitManifestFile) {
RunNaClIntegrationTest(FILE_PATH_LITERAL(
"pm_pre_init_manifest_file_test.html"));
}
IN_PROC_BROWSER_TEST_F(NaClBrowserTestNewlib, IrtManifestFile) {
RunNaClIntegrationTest(FILE_PATH_LITERAL("irt_manifest_file_test.html"));
}
NACL_BROWSER_TEST_F(NaClBrowserTest, Nameservice, {
RunNaClIntegrationTest(FILE_PATH_LITERAL("pm_nameservice_test.html"));
})
......
......@@ -37,7 +37,6 @@ ppapi_scons_files['untrusted_irt_scons_files'] = []
ppapi_scons_files['nonvariant_test_scons_files'] = [
'tests/breakpad_crash_test/nacl.scons',
'tests/nacl_browser/browser_dynamic_library/nacl.scons',
'tests/nacl_browser/manifest_file/nacl.scons',
'tests/ppapi_browser/extension_mime_handler/nacl.scons',
'tests/ppapi_browser/manifest/nacl.scons',
'tests/ppapi_test_lib/nacl.scons',
......
{
"program": {
"x86-32": {"url": "irt_manifest_file_test_x86-32.nexe"},
"x86-64": {"url": "irt_manifest_file_test_x86-64.nexe"},
"arm": {"url": "irt_manifest_file_test_arm.nexe"}
},
"files": {
"nmf says hello world": {
"x86-32": {"url": "irt_manifest_file_test_x86-32.nexe"},
"x86-64": {"url": "irt_manifest_file_test_x86-64.nexe"},
"arm": {"url": "irt_manifest_file_test_arm.nexe"}
},
"test_file": {
"portable": {"url": "test_file.txt"}
}
}
}
# -*- python -*-
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
Import('env')
# post message version
pm_mf_obj = env.ComponentObject('pm_manifest_file_test.o',
'pm_manifest_file_test.cc')
pm_mf_nexe_name = env.ProgramNameForNmf('pm_manifest_file_test')
pm_mf_nexe = env.ComponentProgram(pm_mf_nexe_name,
pm_mf_obj,
EXTRA_LIBS=['nacl_ppapi_util',
'weak_ref',
'ppapi_cpp',
'pthread',
'srpc',
'platform',
'gio',
'imc',
'imc_syscalls',
])
env.Publish(pm_mf_nexe_name, 'run',
['pm_manifest_file_test.html', 'test_file.txt'])
# chrome_browser_tests
node = env.PPAPIBrowserTester(
'pm_mf_browser_test.out',
url='pm_manifest_file_test.html',
nmfs=['pm_manifest_file.nmf'],
files=env.ExtractPublishedFiles(pm_mf_nexe_name),
# osenv=['NACLVERBOSITY=4,pp_weak_ref=4,weak_ref=4']
)
env.AddNodeToTestSuite(node,
['chrome_browser_tests'],
'run_pm_manifest_file_chrome_browser_test',
is_broken=env.PPAPIBrowserTesterIsBroken() or
env.Bit('nacl_glibc'))
# post message, pre-init version
pm_pi_mf_obj = env.ComponentObject('pm_pre_init_manifest_file_test.o',
'pm_pre_init_manifest_file_test.cc')
pm_pi_mf_nexe_name = env.ProgramNameForNmf('pm_pre_init_manifest_file_test')
pm_pi_mf_nexe = env.ComponentProgram(pm_pi_mf_nexe_name,
pm_pi_mf_obj,
EXTRA_LIBS=['nacl_ppapi_util',
'weak_ref',
'ppapi_cpp',
'pthread',
'srpc',
'platform',
'gio',
'imc',
'imc_syscalls',
])
env.Publish(pm_pi_mf_nexe_name, 'run',
['pm_pre_init_manifest_file_test.html', 'test_file.txt'])
# chrome_browser_tests
node = env.PPAPIBrowserTester(
'pm_pi_mf_browser_test.out',
url='pm_pre_init_manifest_file_test.html',
nmfs=['pm_pre_init_manifest_file.nmf'],
files=env.ExtractPublishedFiles(pm_pi_mf_nexe_name),
# osenv=['NACLVERBOSITY=4,pp_weak_ref=4,weak_ref=4']
)
env.AddNodeToTestSuite(node,
['chrome_browser_tests'],
'run_pm_pi_manifest_file_chrome_browser_test',
is_broken=env.PPAPIBrowserTesterIsBroken() or
env.Bit('nacl_glibc'))
irt_mf_nexe_name = env.ProgramNameForNmf('irt_manifest_file_test')
irt_mf_nexe = env.ComponentProgram(irt_mf_nexe_name,
'irt_manifest_file_test.cc',
EXTRA_LIBS=['nacl_ppapi_util',
'weak_ref',
'ppapi_cpp',
'pthread',
'srpc',
'platform',
'gio',
'imc',
'imc_syscalls',
'nacl',
])
env.Publish(irt_mf_nexe_name, 'run',
['irt_manifest_file_test.html', 'test_file.txt'])
node = env.PPAPIBrowserTester(
'irt_mf_browser_test.out',
url='irt_manifest_file_test.html',
nmfs=['irt_manifest_file.nmf'],
files=env.ExtractPublishedFiles(irt_mf_nexe_name),
)
env.AddNodeToTestSuite(node,
['chrome_browser_tests'],
'run_irt_manifest_file_chrome_browser_test',
is_broken=env.PPAPIBrowserTesterIsBroken() or
env.Bit('nacl_glibc'))
{
"program": {
"x86-32": {"url": "pm_manifest_file_test_x86-32.nexe"},
"x86-64": {"url": "pm_manifest_file_test_x86-64.nexe"},
"arm": {"url": "pm_manifest_file_test_arm.nexe"}
},
"files": {
"nmf says hello world": {
"x86-32": {"url": "pm_manifest_file_test_x86-32.nexe"},
"x86-64": {"url": "pm_manifest_file_test_x86-64.nexe"},
"arm": {"url": "pm_manifest_file_test_arm.nexe"}
},
"test_file": {
"portable": {"url": "test_file.txt"}
}
}
}
{
"program": {
"x86-32": {"url": "pm_pre_init_manifest_file_test_x86-32.nexe"},
"x86-64": {"url": "pm_pre_init_manifest_file_test_x86-64.nexe"},
"arm": {"url": "pm_pre_init_manifest_file_test_arm.nexe"}
},
"files": {
"nmf says hello world": {
"x86-32": {"url": "pm_pre_init_manifest_file_test_x86-32.nexe"},
"x86-64": {"url": "pm_pre_init_manifest_file_test_x86-64.nexe"},
"arm": {"url": "pm_pre_init_manifest_file_test_arm.nexe"}
},
"test_file": {
"portable": {"url": "test_file.txt"}
}
}
}
......@@ -90,6 +90,7 @@
'--strip-all',
],
'create_nmf': '<(DEPTH)/native_client_sdk/src/tools/create_nmf.py',
'create_nmf_args_portable%': [],
},
'target_conditions': [
['generate_nmf==1 and build_newlib==1', {
......@@ -100,18 +101,22 @@
'outputs': ['>(nmf_newlib)'],
'action': [
'python',
'>@(_inputs)',
'>(create_nmf)',
'--output=>(nmf_newlib)',
'>@(create_nmf_args_portable)',
],
'target_conditions': [
['enable_x86_64==1', {
'inputs': ['>(out_newlib64)'],
'action': ['>(out_newlib64)'],
}],
['enable_x86_32==1', {
'inputs': ['>(out_newlib32)'],
'action': ['>(out_newlib32)'],
}],
['enable_arm==1', {
'inputs': ['>(out_newlib_arm)'],
'action': ['>(out_newlib_arm)'],
}],
],
},
......@@ -135,16 +140,18 @@
'outputs': ['>(nmf_glibc)'],
'action': [
'python',
'>@(_inputs)',
'>(create_nmf)',
'--objdump=>(nacl_objdump)',
'--output=>(nmf_glibc)',
'--path-prefix=>(nexe_target)_libs',
'--stage-dependencies=<(nacl_glibc_out_dir)',
'>@(create_nmf_args_portable)',
],
'target_conditions': [
['enable_x86_64==1', {
'inputs': ['>(out_glibc64)'],
'action': [
'>(out_glibc64)',
'--library-path=>(libdir_glibc64)',
'--library-path=>(tc_lib_dir_glibc64)',
],
......@@ -152,6 +159,7 @@
['enable_x86_32==1', {
'inputs': ['>(out_glibc32)'],
'action': [
'>(out_glibc32)',
'--library-path=>(libdir_glibc32)',
'--library-path=>(tc_lib_dir_glibc32)',
],
......@@ -171,8 +179,10 @@
'outputs': ['>(nmf_pnacl_newlib)'],
'action': [
'python',
'>@(_inputs)',
'>(create_nmf)',
'--output=>(nmf_pnacl_newlib)',
'>(out_pnacl_newlib)',
'>@(create_nmf_args_portable)',
],
},
],
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment