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

Side by Side Diff: third_party/android_crazy_linker/src/tests/test_dl_wrappers.cpp

Issue 322433006: Fork of the Android NDK crazy linker. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add a required license header to a cpp module, missing in the original. Created 6 years, 6 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2013 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.
4
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.
11
12 // This tests the dlopen/dlsym/dlclose wrappers provided by the crazy
13 // linker to loaded libraries.
14
15 #include <stdio.h>
16 #include <crazy_linker.h>
17
18 #include "test_util.h"
19
20 typedef bool (*FunctionPtr)();
21
22 int main() {
23 crazy_context_t* context = crazy_context_create();
24 crazy_library_t* library;
25
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));
29 }
30
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");
36 }
37
38 // Call it.
39 bool ret = (*zoo_func)();
40 if (!ret)
41 Panic("'Zoo' function failed!");
42
43 // Close the library.
44 printf("Closing libzoo.so\n");
45 crazy_library_close(library);
46
47 crazy_context_destroy(context);
48
49 return 0;
50 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698