Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(167)

Unified Diff: ppapi/native_client/tests/nacl_browser/browser_dynamic_library/browser_dlopen_test.cc

Issue 10914053: Relocating files in the nacl repo that belong in chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ppapi/native_client/tests/nacl_browser/browser_dynamic_library/browser_dlopen_test.cc
diff --git a/ppapi/native_client/tests/nacl_browser/browser_dynamic_library/browser_dlopen_test.cc b/ppapi/native_client/tests/nacl_browser/browser_dynamic_library/browser_dlopen_test.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c2ac14b8bfd3c1a92825326d982a5b6626d7ad86
--- /dev/null
+++ b/ppapi/native_client/tests/nacl_browser/browser_dynamic_library/browser_dlopen_test.cc
@@ -0,0 +1,59 @@
+/*
+ * 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.
+ */
+
+#include <dlfcn.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "native_client/tests/ppapi_test_lib/get_browser_interface.h"
+#include "native_client/tests/ppapi_test_lib/test_interface.h"
+#include "native_client/tests/ppapi_test_lib/testable_callback.h"
+#include "ppapi/c/pp_errors.h"
+
+
+namespace {
+
+void TestDlopenMainThread() {
+ // This is a valid .so to load up, but dlopen doesn't work from the main
+ // PPAPI thread, so it should always fail.
+ void* lib_handle = dlopen("libmemusage.so", RTLD_LAZY);
+ EXPECT(lib_handle == NULL);
+ TEST_PASSED;
+}
+
+
+void CheckSecondaryThreadSuccess(void *lib_handle, int32_t unused_result) {
+ EXPECT(lib_handle != NULL);
+ PostTestMessage("TestDlopenSecondaryThread", "PASSED");
+}
+
+void* SecondaryThreadFunc(void *unused_data) {
+ void* lib_handle = dlopen("libmemusage.so", RTLD_LAZY);
+ PP_CompletionCallback callback = PP_MakeCompletionCallback(
+ CheckSecondaryThreadSuccess,
+ lib_handle);
+ PPBCore()->CallOnMainThread(0, callback, PP_OK);
+ return NULL;
+}
+
+void TestDlopenSecondaryThread() {
+ pthread_t p;
+ pthread_create(&p, NULL, SecondaryThreadFunc, NULL);
+ // This function must return in order for the main message loop to
+ // service the requests issued from the dlopen call, we can't wait
+ // for the result of the thread here. The 'PASSED' message will
+ // be generated by the thread.
+}
+}
+
+void SetupTests() {
+ RegisterTest("TestDlopenMainThread", TestDlopenMainThread);
+ RegisterTest("TestDlopenSecondaryThread", TestDlopenSecondaryThread);
+}
+
+void SetupPluginInterfaces() {
+ // none
+}

Powered by Google App Engine
This is Rietveld 408576698