2 * Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file.
11 #include "ppapi/c/pp_errors.h"
12 #include "ppapi/native_client/tests/ppapi_test_lib/get_browser_interface.h"
13 #include "ppapi/native_client/tests/ppapi_test_lib/test_interface.h"
14 #include "ppapi/native_client/tests/ppapi_test_lib/testable_callback.h"
19 void TestDlopenMainThread() {
20 // This is a valid .so to load up, but dlopen doesn't work from the main
21 // PPAPI thread, so it should always fail.
22 void* lib_handle = dlopen("libmemusage.so", RTLD_LAZY);
23 EXPECT(lib_handle == NULL);
28 void CheckSecondaryThreadSuccess(void *lib_handle, int32_t unused_result) {
29 EXPECT(lib_handle != NULL);
30 PostTestMessage("TestDlopenSecondaryThread", "PASSED");
33 void* SecondaryThreadFunc(void *unused_data) {
34 void* lib_handle = dlopen("libmemusage.so", RTLD_LAZY);
35 PP_CompletionCallback callback = PP_MakeCompletionCallback(
36 CheckSecondaryThreadSuccess,
38 PPBCore()->CallOnMainThread(0, callback, PP_OK);
42 void TestDlopenSecondaryThread() {
44 pthread_create(&p, NULL, SecondaryThreadFunc, NULL);
45 // This function must return in order for the main message loop to
46 // service the requests issued from the dlopen call, we can't wait
47 // for the result of the thread here. The 'PASSED' message will
48 // be generated by the thread.
53 RegisterTest("TestDlopenMainThread", TestDlopenMainThread);
54 RegisterTest("TestDlopenSecondaryThread", TestDlopenSecondaryThread);
57 void SetupPluginInterfaces() {