Revert "Omit calls to set composing region when pasting image."
[chromium-blink-merge.git] / third_party / android_crazy_linker / src / tests / test_dl_wrappers.cpp
blob5cfddac5322d3d4c6ff4d059cc731a471f9659d0
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // A crazy linker test to:
6 // - Load a library (libzoo.so) with the linker.
7 // - Find the address of the "Zoo" function in libzoo.so.
8 // - Call the Zoo() function, which will use dlopen() / dlsym() to
9 // find libbar.so (which depends on libfoo.so).
10 // - Close the library.
12 // This tests the dlopen/dlsym/dlclose wrappers provided by the crazy
13 // linker to loaded libraries.
15 #include <stdio.h>
16 #include <crazy_linker.h>
18 #include "test_util.h"
20 typedef bool (*FunctionPtr)();
22 int main() {
23 crazy_context_t* context = crazy_context_create();
24 crazy_library_t* library;
26 // Load libzoo.so
27 if (!crazy_library_open(&library, "libzoo.so", context)) {
28 Panic("Could not open library: %s\n", crazy_context_get_error(context));
31 // Find the "Zoo" symbol.
32 FunctionPtr zoo_func;
33 if (!crazy_library_find_symbol(
34 library, "Zoo", reinterpret_cast<void**>(&zoo_func))) {
35 Panic("Could not find 'Zoo' in libzoo.so\n");
38 // Call it.
39 bool ret = (*zoo_func)();
40 if (!ret)
41 Panic("'Zoo' function failed!");
43 // Close the library.
44 printf("Closing libzoo.so\n");
45 crazy_library_close(library);
47 crazy_context_destroy(context);
49 return 0;