Skip to content

Commit

Permalink
Port manifest query tests from nacl_integration to browser_tests.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ncbray@chromium.org committed Jan 11, 2014
1 parent 0f99699 commit 3ec729e
Show file tree
Hide file tree
Showing 15 changed files with 243 additions and 208 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* 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.
*/
Expand Down Expand Up @@ -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.
//
Expand Down Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!--
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.
-->
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* 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.
*/
Expand Down Expand Up @@ -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.
//
Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!--
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.
-->
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* 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.
*/
Expand Down Expand Up @@ -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.
//
Expand Down Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!--
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.
-->
Expand All @@ -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) {
Expand Down
139 changes: 139 additions & 0 deletions chrome/test/data/nacl/nacl_test_data.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -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',
],
},
},
Expand Down Expand Up @@ -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',
Expand Down
Loading

0 comments on commit 3ec729e

Please sign in to comment.