1
/* EVIL - EFL library for Windows port
2
* Copyright (C) 2015 Vincent Torri
4
* This library is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU Lesser General Public
6
* License as published by the Free Software Foundation; either
7
* version 2.1 of the License, or (at your option) any later version.
9
* This library is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
* Lesser General Public License for more details.
14
* You should have received a copy of the GNU Lesser General Public
15
* License along with this library;
16
* if not, see <http://www.gnu.org/licenses/>.
23
#include <evil_private.h>
25
#include "evil_suite.h"
28
typedef int (*_evil_init)(void);
29
typedef int (*_evil_shutdwon)(void);
32
EFL_START_TEST(evil_dlfcn_dlopen_success)
37
mod = dlopen("c:\\windows\\system32\\kernel32.dll", 0);
45
EFL_START_TEST(evil_dlfcn_dlopen_failure)
49
/* non existent DLL */
50
mod = dlopen("c:\\windows\\system32\\kernel32.dl", 0);
55
EFL_START_TEST(evil_dlfcn_dlsym_success)
58
_evil_shutdwon sym_shutdown;
62
mod = dlopen("libevil-1.dll", 0);
65
sym_init = dlsym(mod, "evil_init");
66
fail_if(sym_init == NULL);
67
fail_if(sym_init() != 2);
69
sym_shutdown = dlsym(mod, "evil_shutdown");
70
fail_if(sym_shutdown == NULL);
71
fail_if(sym_shutdown() != 1);
78
EFL_START_TEST(evil_dlfcn_dlsym_failure)
84
mod = dlopen("libevil-1.dll", 0);
87
/* non-existent symbol */
88
sym = dlsym(mod, "evil_ini");
96
EFL_START_TEST(evil_dlfcn_dladdr)
104
mod = dlopen("libevil-1.dll", 0);
105
fail_if(mod == NULL);
107
sym = dlsym(mod, "evil_init");
108
fail_if(sym == NULL);
110
res = dladdr(sym, &info);
113
fail_if(mod != info.dli_fbase);
114
dll = strrchr(info.dli_fname, '\\') + 1;
115
fail_if(strcmp("libevil-1.dll", dll) != 0);
116
fail_if(sym != info.dli_saddr);
117
fail_if(strcmp("evil_init", info.dli_sname) != 0);
124
void evil_test_dlfcn(TCase *tc)
126
tcase_add_test(tc, evil_dlfcn_dlopen_success);
127
tcase_add_test(tc, evil_dlfcn_dlopen_failure);
128
tcase_add_test(tc, evil_dlfcn_dlsym_success);
129
tcase_add_test(tc, evil_dlfcn_dlsym_failure);
130
tcase_add_test(tc, evil_dlfcn_dladdr);