blob: 92f69a051ec475c5956fc38f8e851b173bab6676 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
/*
* Copyright (c) 2021, Rodrigo Tobar <rtobarc@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibDl/dlfcn.h>
#include <LibTest/TestCase.h>
TEST_CASE(test_dlopen)
{
auto liba = dlopen("/usr/Tests/LibELF/libDynlibA.so", 0);
EXPECT_NE(liba, nullptr);
auto libb = dlopen("/usr/Tests/LibELF/libDynlibB.so", 0);
EXPECT_NE(libb, nullptr);
typedef int (*dynlib_func_t)();
dynlib_func_t func_a = (dynlib_func_t)dlsym(liba, "dynliba_function");
EXPECT_NE(func_a, nullptr);
EXPECT_EQ(0, func_a());
dynlib_func_t func_b = (dynlib_func_t)dlsym(libb, "dynlibb_function");
EXPECT_NE(func_b, nullptr);
EXPECT_EQ(0, func_b());
}
|