summaryrefslogtreecommitdiffstats
path: root/ppapi
diff options
context:
space:
mode:
Diffstat (limited to 'ppapi')
-rw-r--r--ppapi/tests/test_file_io.cc34
-rw-r--r--ppapi/tests/test_file_io.h1
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().