annotate OrthancServer/UnitTestsSources/PluginsTests.cpp @ 5061:e95fadefeb72

new MaximumStorageMode configuration
author Alain Mazy <am@osimis.io>
date Tue, 09 Aug 2022 17:57:38 +0200
parents df86d2505df8
children 0ea402b4d901
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
885
0570a8c859cb SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
0570a8c859cb SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
1900
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
1288
6e7e5ed91c2d upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1032
diff changeset
4 * Department, University Hospital of Liege, Belgium
4870
43e613a7756b upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4854
diff changeset
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium
43e613a7756b upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4854
diff changeset
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
885
0570a8c859cb SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 *
0570a8c859cb SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * This program is free software: you can redistribute it and/or
0570a8c859cb SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * modify it under the terms of the GNU General Public License as
0570a8c859cb SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * published by the Free Software Foundation, either version 3 of the
0570a8c859cb SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 * License, or (at your option) any later version.
0570a8c859cb SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 *
0570a8c859cb SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful, but
0570a8c859cb SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
0570a8c859cb SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0570a8c859cb SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * General Public License for more details.
0570a8c859cb SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 *
0570a8c859cb SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
0570a8c859cb SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
0570a8c859cb SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 **/
0570a8c859cb SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
0570a8c859cb SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
0570a8c859cb SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 #include "PrecompiledHeadersUnitTests.h"
4062
0953b3dc3261 pretty-printing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
24 #include <gtest/gtest.h>
885
0570a8c859cb SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25
4813
15f9cc6c11f0 fix unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
26 #include "../../OrthancFramework/Sources/Compatibility.h"
4045
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
27 #include "../../OrthancFramework/Sources/OrthancException.h"
887
4066e6f2d134 PluginsManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 886
diff changeset
28 #include "../Plugins/Engine/PluginsManager.h"
885
0570a8c859cb SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29
0570a8c859cb SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 using namespace Orthanc;
0570a8c859cb SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31
1578
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
32
2136
dd609a99d39a uniformization of the macro naming
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1976
diff changeset
33 #if ORTHANC_ENABLE_PLUGINS == 1
1578
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
34
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
35 TEST(SharedLibrary, Enumerations)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
36 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
37 // The plugin engine cannot work if the size of an enumeration does
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
38 // not correspond to the size of "int32_t"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
39 ASSERT_EQ(sizeof(int32_t), sizeof(OrthancPluginErrorCode));
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
40 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
41
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
42
885
0570a8c859cb SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 TEST(SharedLibrary, Basic)
0570a8c859cb SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 {
0570a8c859cb SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 #if defined(_WIN32)
893
f57802f8b4dc plugins for windows
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 888
diff changeset
46 SharedLibrary l("kernel32.dll");
f57802f8b4dc plugins for windows
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 888
diff changeset
47 ASSERT_THROW(l.GetFunction("world"), OrthancException);
f57802f8b4dc plugins for windows
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 888
diff changeset
48 ASSERT_TRUE(l.GetFunction("GetVersionExW") != NULL);
f57802f8b4dc plugins for windows
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 888
diff changeset
49 ASSERT_TRUE(l.HasFunction("GetVersionExW"));
f57802f8b4dc plugins for windows
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 888
diff changeset
50 ASSERT_FALSE(l.HasFunction("world"));
885
0570a8c859cb SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51
2451
a4032b162502 lsb working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
52 #elif defined(__LSB_VERSION__)
a4032b162502 lsb working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
53 // For Linux Standard Base, we use a low-level shared library coming
a4032b162502 lsb working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
54 // with glibc:
a4032b162502 lsb working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
55 // http://www.linuxfromscratch.org/lfs/view/6.5/chapter06/glibc.html
a4032b162502 lsb working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
56 SharedLibrary l("libSegFault.so");
a4032b162502 lsb working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
57 ASSERT_THROW(l.GetFunction("world"), OrthancException);
a4032b162502 lsb working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
58 ASSERT_FALSE(l.HasFunction("world"));
a4032b162502 lsb working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
59
3035
3254b36a5f9b fix lsb compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2463
diff changeset
60 /**
3254b36a5f9b fix lsb compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2463
diff changeset
61 * On the Docker image "debian:buster-slim", the "libSegFault.so"
3254b36a5f9b fix lsb compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2463
diff changeset
62 * library does exist, but does not contain any public symbol:
3254b36a5f9b fix lsb compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2463
diff changeset
63 *
3254b36a5f9b fix lsb compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2463
diff changeset
64 * $ sudo docker run -i -t --rm --entrypoint=bash debian:buster-slim
3254b36a5f9b fix lsb compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2463
diff changeset
65 * # apt-get update && apt-get install -y binutils
3254b36a5f9b fix lsb compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2463
diff changeset
66 * # nm -C /lib/x86_64-linux-gnu/libSegFault.so
3254b36a5f9b fix lsb compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2463
diff changeset
67 * nm: /lib/x86_64-linux-gnu/libSegFault.so: no symbols
3254b36a5f9b fix lsb compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2463
diff changeset
68 *
3254b36a5f9b fix lsb compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2463
diff changeset
69 * As a consequence, this part of the test is disabled since Orthanc
3254b36a5f9b fix lsb compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2463
diff changeset
70 * 1.5.1, until we locate another shared library that is widely
3254b36a5f9b fix lsb compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2463
diff changeset
71 * spread. Reference:
3254b36a5f9b fix lsb compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2463
diff changeset
72 * https://groups.google.com/d/msg/orthanc-users/v-QFzpOzgJY/4Hm5NgxKBwAJ
3254b36a5f9b fix lsb compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2463
diff changeset
73 **/
3254b36a5f9b fix lsb compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2463
diff changeset
74
3254b36a5f9b fix lsb compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2463
diff changeset
75 //ASSERT_TRUE(l.GetFunction("_init") != NULL);
3254b36a5f9b fix lsb compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2463
diff changeset
76 //ASSERT_TRUE(l.HasFunction("_init"));
3254b36a5f9b fix lsb compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2463
diff changeset
77
1976
325772dadcd6 Macro "__linux" (now obsolete) replaced by macro "__linux__"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
78 #elif defined(__linux__) || defined(__FreeBSD_kernel__)
4854
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
79 /**
4902
df86d2505df8 Orthanc 1.9.8 is now known as Orthanc 1.10.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4892
diff changeset
80 * Since Orthanc 1.10.0, we test the "libdl.so.2" instead of the
4854
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
81 * "libdl.so", as discussed here:
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
82 * https://groups.google.com/g/orthanc-users/c/I5g1fN6MCvg/m/JVdvRyjJAAAJ
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
83 * https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1001305
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
84 * https://salsa.debian.org/med-team/orthanc/-/blob/master/debian/patches/glibc-2.34.patch
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
85 **/
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
86
4813
15f9cc6c11f0 fix unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
87 try
15f9cc6c11f0 fix unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
88 {
4854
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
89 SharedLibrary l("libdl.so.2");
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
90 ASSERT_THROW(l.GetFunction("world"), OrthancException);
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
91 ASSERT_TRUE(l.GetFunction("dlopen") != NULL);
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
92 ASSERT_TRUE(l.HasFunction("dlclose"));
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
93 ASSERT_FALSE(l.HasFunction("world"));
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
94 return; // Success
4813
15f9cc6c11f0 fix unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
95 }
15f9cc6c11f0 fix unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
96 catch (OrthancException&)
15f9cc6c11f0 fix unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
97 {
4854
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
98 }
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
99
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
100 try
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
101 {
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
102 SharedLibrary l("libdl.so"); // Fallback for backward compat
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
103 ASSERT_THROW(l.GetFunction("world"), OrthancException);
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
104 ASSERT_TRUE(l.GetFunction("dlopen") != NULL);
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
105 ASSERT_TRUE(l.HasFunction("dlclose"));
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
106 ASSERT_FALSE(l.HasFunction("world"));
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
107 return; // Success
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
108 }
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
109 catch (OrthancException&)
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
110 {
4813
15f9cc6c11f0 fix unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
111 }
15f9cc6c11f0 fix unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
112
4854
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
113 try
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
114 {
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
115 SharedLibrary l("libmemusage.so"); // Try another common library
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
116 ASSERT_THROW(l.GetFunction("world"), OrthancException);
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
117 ASSERT_TRUE(l.GetFunction("munmap") != NULL);
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
118 ASSERT_TRUE(l.HasFunction("free"));
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
119 ASSERT_FALSE(l.HasFunction("world"));
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
120 return; // Success
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
121 }
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
122 catch (OrthancException&)
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
123 {
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
124 }
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
125
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
126 ASSERT_TRUE(0);
885
0570a8c859cb SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127
2364
ae50eccd41b7 compilation succeeds on OpenBSD
jodogne
parents: 2244
diff changeset
128 #elif defined(__FreeBSD__) || defined(__OpenBSD__)
ae50eccd41b7 compilation succeeds on OpenBSD
jodogne
parents: 2244
diff changeset
129 // dlopen() in FreeBSD/OpenBSD is supplied by libc, libc.so is
1337
afaa55d42ddd FreeBSD support
jodogne
parents: 1288
diff changeset
130 // a ldscript, so we can't actually use it. Use thread
afaa55d42ddd FreeBSD support
jodogne
parents: 1288
diff changeset
131 // library instead - if it works - dlopen() is good.
afaa55d42ddd FreeBSD support
jodogne
parents: 1288
diff changeset
132 SharedLibrary l("libpthread.so");
afaa55d42ddd FreeBSD support
jodogne
parents: 1288
diff changeset
133 ASSERT_THROW(l.GetFunction("world"), OrthancException);
afaa55d42ddd FreeBSD support
jodogne
parents: 1288
diff changeset
134 ASSERT_TRUE(l.GetFunction("pthread_create") != NULL);
afaa55d42ddd FreeBSD support
jodogne
parents: 1288
diff changeset
135 ASSERT_TRUE(l.HasFunction("pthread_cancel"));
afaa55d42ddd FreeBSD support
jodogne
parents: 1288
diff changeset
136 ASSERT_FALSE(l.HasFunction("world"));
afaa55d42ddd FreeBSD support
jodogne
parents: 1288
diff changeset
137
1026
a13ccd93df28 fix OS X build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 907
diff changeset
138 #elif defined(__APPLE__) && defined(__MACH__)
a13ccd93df28 fix OS X build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 907
diff changeset
139 SharedLibrary l("libdl.dylib");
a13ccd93df28 fix OS X build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 907
diff changeset
140 ASSERT_THROW(l.GetFunction("world"), OrthancException);
a13ccd93df28 fix OS X build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 907
diff changeset
141 ASSERT_TRUE(l.GetFunction("dlopen") != NULL);
a13ccd93df28 fix OS X build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 907
diff changeset
142 ASSERT_TRUE(l.HasFunction("dlclose"));
a13ccd93df28 fix OS X build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 907
diff changeset
143 ASSERT_FALSE(l.HasFunction("world"));
a13ccd93df28 fix OS X build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 907
diff changeset
144
885
0570a8c859cb SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145 #else
0570a8c859cb SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146 #error Support your platform here
0570a8c859cb SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
147 #endif
0570a8c859cb SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
148 }
1578
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
149
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
150 #endif