diff options
author | mazda@chromium.org <mazda@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-30 12:19:34 +0000 |
---|---|---|
committer | mazda@chromium.org <mazda@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-30 12:19:34 +0000 |
commit | b347ca13aa3bfcf1bb801e6c04695654c899796c (patch) | |
tree | 8b99e1578dbca2508a82e40007d852d868b2636e /ppapi | |
parent | 6b694cf881b9ff2658c6e478f10502abcab23cb6 (diff) | |
download | chromium_src-b347ca13aa3bfcf1bb801e6c04695654c899796c.zip chromium_src-b347ca13aa3bfcf1bb801e6c04695654c899796c.tar.gz chromium_src-b347ca13aa3bfcf1bb801e6c04695654c899796c.tar.bz2 |
Add a PPAPI browser tests for an issue of NaCl crash.
These tests verifie that the crash of NaCl module introduced by r200088 does
not occur when PPB_FileIO_Private::RequestOSFileHandle is called with
PPB_FileIO opened with PP_FILEOPENFLAG_EXCLUSIVE.
BUG=243241,241726
TEST=
browser_tests --gtest_filter="PPAPI*Test.FileIO" passes
Revert r200088
browser_tests --gtest_filter="PPAPI*Test.FileIO" crashes
Review URL: https://chromiumcodereview.appspot.com/15864005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@203124 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r-- | ppapi/tests/test_file_io.cc | 34 | ||||
-rw-r--r-- | ppapi/tests/test_file_io.h | 1 |
2 files changed, 35 insertions, 0 deletions
diff --git a/ppapi/tests/test_file_io.cc b/ppapi/tests/test_file_io.cc index 620344e..5006419 100644 --- a/ppapi/tests/test_file_io.cc +++ b/ppapi/tests/test_file_io.cc @@ -184,6 +184,7 @@ void TestFileIO::RunTests(const std::string& filter) { RUN_CALLBACK_TEST(TestFileIO, NotAllowMixedReadWrite, filter); RUN_CALLBACK_TEST(TestFileIO, WillWriteWillSetLength, filter); RUN_CALLBACK_TEST(TestFileIO, RequestOSFileHandle, filter); + RUN_CALLBACK_TEST(TestFileIO, RequestOSFileHandleWithOpenExclusive, filter); RUN_CALLBACK_TEST(TestFileIO, Mmap, filter); // TODO(viettrungluu): add tests: @@ -1108,6 +1109,39 @@ std::string TestFileIO::TestRequestOSFileHandle() { PASS(); } +// Calling RequestOSFileHandle with the FileIO that is opened with +// PP_FILEOPENFLAG_EXCLUSIVE used to cause NaCl module to crash while loading. +// This is a regression test for crbug.com/243241. +std::string TestFileIO::TestRequestOSFileHandleWithOpenExclusive() { + TestCompletionCallback callback(instance_->pp_instance(), callback_type()); + + pp::FileSystem file_system(instance_, PP_FILESYSTEMTYPE_LOCALTEMPORARY); + pp::FileRef file_ref(file_system, "/file_os_fd2"); + + callback.WaitForResult(file_system.Open(1024, callback.GetCallback())); + ASSERT_EQ(PP_OK, callback.result()); + + pp::FileIO_Private file_io(instance_); + callback.WaitForResult(file_io.Open(file_ref, + PP_FILEOPENFLAG_CREATE | + PP_FILEOPENFLAG_READ | + PP_FILEOPENFLAG_WRITE | + PP_FILEOPENFLAG_EXCLUSIVE, + callback.GetCallback())); + ASSERT_EQ(PP_OK, callback.result()); + + TestCompletionCallbackWithOutput<pp::PassFileHandle> output_callback( + instance_->pp_instance(), callback_type()); + output_callback.WaitForResult( + file_io.RequestOSFileHandle(output_callback.GetCallback())); + PP_FileHandle handle = output_callback.output().Release(); + if (handle == PP_kInvalidFileHandle) + return "FileIO::RequestOSFileHandle() returned a bad file handle."; + ASSERT_EQ(PP_OK, output_callback.result()); + + PASS(); +} + std::string TestFileIO::TestMmap() { #if !defined(PPAPI_OS_WIN) TestCompletionCallback callback(instance_->pp_instance(), callback_type()); diff --git a/ppapi/tests/test_file_io.h b/ppapi/tests/test_file_io.h index 799cb1e..8221f4d 100644 --- a/ppapi/tests/test_file_io.h +++ b/ppapi/tests/test_file_io.h @@ -48,6 +48,7 @@ class TestFileIO : public TestCase { std::string TestNotAllowMixedReadWrite(); std::string TestWillWriteWillSetLength(); std::string TestRequestOSFileHandle(); + std::string TestRequestOSFileHandleWithOpenExclusive(); std::string TestMmap(); // Helper method used by TestOpen(). |