annotate OrthancServer/UnitTestsSources/PluginsTests.cpp @ 5640:f7adfb22e20e

updated copyright, as Orthanc Team now replaces Osimis
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 30 May 2024 21:19:57 +0200
parents 48b8dae6dc77
children
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
5640
f7adfb22e20e updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5485
diff changeset
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium
f7adfb22e20e updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5485
diff changeset
6 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium
5485
48b8dae6dc77 upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
7 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
885
0570a8c859cb SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 *
0570a8c859cb SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * This program is free software: you can redistribute it and/or
0570a8c859cb SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * modify it under the terms of the GNU General Public License as
0570a8c859cb SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 * published by the Free Software Foundation, either version 3 of the
0570a8c859cb SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * License, or (at your option) any later version.
0570a8c859cb SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 *
0570a8c859cb SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * 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
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
0570a8c859cb SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0570a8c859cb SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * General Public License for more details.
0570a8c859cb SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 *
0570a8c859cb SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
0570a8c859cb SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
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
0570a8c859cb SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #include "PrecompiledHeadersUnitTests.h"
4062
0953b3dc3261 pretty-printing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
25 #include <gtest/gtest.h>
885
0570a8c859cb SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26
4813
15f9cc6c11f0 fix unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
27 #include "../../OrthancFramework/Sources/Compatibility.h"
4045
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
28 #include "../../OrthancFramework/Sources/OrthancException.h"
887
4066e6f2d134 PluginsManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 886
diff changeset
29 #include "../Plugins/Engine/PluginsManager.h"
885
0570a8c859cb SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30
0570a8c859cb SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 using namespace Orthanc;
0570a8c859cb SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
1578
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
33
2136
dd609a99d39a uniformization of the macro naming
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1976
diff changeset
34 #if ORTHANC_ENABLE_PLUGINS == 1
1578
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
35
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
36 TEST(SharedLibrary, Enumerations)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
37 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
38 // The plugin engine cannot work if the size of an enumeration does
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
39 // not correspond to the size of "int32_t"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
40 ASSERT_EQ(sizeof(int32_t), sizeof(OrthancPluginErrorCode));
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
41 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
42
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
43
885
0570a8c859cb SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 TEST(SharedLibrary, Basic)
0570a8c859cb SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 {
0570a8c859cb SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 #if defined(_WIN32)
893
f57802f8b4dc plugins for windows
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 888
diff changeset
47 SharedLibrary l("kernel32.dll");
f57802f8b4dc plugins for windows
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 888
diff changeset
48 ASSERT_THROW(l.GetFunction("world"), OrthancException);
f57802f8b4dc plugins for windows
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 888
diff changeset
49 ASSERT_TRUE(l.GetFunction("GetVersionExW") != NULL);
f57802f8b4dc plugins for windows
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 888
diff changeset
50 ASSERT_TRUE(l.HasFunction("GetVersionExW"));
f57802f8b4dc plugins for windows
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 888
diff changeset
51 ASSERT_FALSE(l.HasFunction("world"));
885
0570a8c859cb SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52
2451
a4032b162502 lsb working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
53 #elif defined(__LSB_VERSION__)
a4032b162502 lsb working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
54 // 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
55 // with glibc:
a4032b162502 lsb working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
56 // http://www.linuxfromscratch.org/lfs/view/6.5/chapter06/glibc.html
a4032b162502 lsb working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
57 SharedLibrary l("libSegFault.so");
a4032b162502 lsb working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
58 ASSERT_THROW(l.GetFunction("world"), OrthancException);
a4032b162502 lsb working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
59 ASSERT_FALSE(l.HasFunction("world"));
a4032b162502 lsb working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
60
3035
3254b36a5f9b fix lsb compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2463
diff changeset
61 /**
3254b36a5f9b fix lsb compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2463
diff changeset
62 * On the Docker image "debian:buster-slim", the "libSegFault.so"
3254b36a5f9b fix lsb compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2463
diff changeset
63 * library does exist, but does not contain any public symbol:
3254b36a5f9b fix lsb compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2463
diff changeset
64 *
3254b36a5f9b fix lsb compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2463
diff changeset
65 * $ 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
66 * # apt-get update && apt-get install -y binutils
3254b36a5f9b fix lsb compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2463
diff changeset
67 * # nm -C /lib/x86_64-linux-gnu/libSegFault.so
3254b36a5f9b fix lsb compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2463
diff changeset
68 * nm: /lib/x86_64-linux-gnu/libSegFault.so: no symbols
3254b36a5f9b fix lsb compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2463
diff changeset
69 *
3254b36a5f9b fix lsb compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2463
diff changeset
70 * 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
71 * 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
72 * spread. Reference:
3254b36a5f9b fix lsb compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2463
diff changeset
73 * 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
74 **/
3254b36a5f9b fix lsb compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2463
diff changeset
75
3254b36a5f9b fix lsb compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2463
diff changeset
76 //ASSERT_TRUE(l.GetFunction("_init") != NULL);
3254b36a5f9b fix lsb compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2463
diff changeset
77 //ASSERT_TRUE(l.HasFunction("_init"));
3254b36a5f9b fix lsb compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2463
diff changeset
78
1976
325772dadcd6 Macro "__linux" (now obsolete) replaced by macro "__linux__"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
79 #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
80 /**
4902
df86d2505df8 Orthanc 1.9.8 is now known as Orthanc 1.10.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4892
diff changeset
81 * 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
82 * "libdl.so", as discussed here:
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
83 * 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
84 * 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
85 * 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
86 **/
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
87
4813
15f9cc6c11f0 fix unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
88 try
15f9cc6c11f0 fix unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
89 {
4854
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
90 SharedLibrary l("libdl.so.2");
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
91 ASSERT_THROW(l.GetFunction("world"), OrthancException);
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
92 ASSERT_TRUE(l.GetFunction("dlopen") != NULL);
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
93 ASSERT_TRUE(l.HasFunction("dlclose"));
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
94 ASSERT_FALSE(l.HasFunction("world"));
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
95 return; // Success
4813
15f9cc6c11f0 fix unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
96 }
15f9cc6c11f0 fix unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
97 catch (OrthancException&)
15f9cc6c11f0 fix unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
98 {
4854
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
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
101 try
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
102 {
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
103 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
104 ASSERT_THROW(l.GetFunction("world"), OrthancException);
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
105 ASSERT_TRUE(l.GetFunction("dlopen") != NULL);
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
106 ASSERT_TRUE(l.HasFunction("dlclose"));
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
107 ASSERT_FALSE(l.HasFunction("world"));
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
108 return; // Success
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
109 }
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
110 catch (OrthancException&)
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
111 {
4813
15f9cc6c11f0 fix unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
112 }
15f9cc6c11f0 fix unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
113
4854
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
114 try
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
115 {
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
116 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
117 ASSERT_THROW(l.GetFunction("world"), OrthancException);
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
118 ASSERT_TRUE(l.GetFunction("munmap") != NULL);
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
119 ASSERT_TRUE(l.HasFunction("free"));
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
120 ASSERT_FALSE(l.HasFunction("world"));
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
121 return; // Success
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
122 }
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
123 catch (OrthancException&)
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
8bd1f0d9506e improved fix of unit test SharedLibrary.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
127 ASSERT_TRUE(0);
885
0570a8c859cb SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128
2364
ae50eccd41b7 compilation succeeds on OpenBSD
jodogne
parents: 2244
diff changeset
129 #elif defined(__FreeBSD__) || defined(__OpenBSD__)
ae50eccd41b7 compilation succeeds on OpenBSD
jodogne
parents: 2244
diff changeset
130 // dlopen() in FreeBSD/OpenBSD is supplied by libc, libc.so is
1337
afaa55d42ddd FreeBSD support
jodogne
parents: 1288
diff changeset
131 // a ldscript, so we can't actually use it. Use thread
afaa55d42ddd FreeBSD support
jodogne
parents: 1288
diff changeset
132 // library instead - if it works - dlopen() is good.
afaa55d42ddd FreeBSD support
jodogne
parents: 1288
diff changeset
133 SharedLibrary l("libpthread.so");
afaa55d42ddd FreeBSD support
jodogne
parents: 1288
diff changeset
134 ASSERT_THROW(l.GetFunction("world"), OrthancException);
afaa55d42ddd FreeBSD support
jodogne
parents: 1288
diff changeset
135 ASSERT_TRUE(l.GetFunction("pthread_create") != NULL);
afaa55d42ddd FreeBSD support
jodogne
parents: 1288
diff changeset
136 ASSERT_TRUE(l.HasFunction("pthread_cancel"));
afaa55d42ddd FreeBSD support
jodogne
parents: 1288
diff changeset
137 ASSERT_FALSE(l.HasFunction("world"));
afaa55d42ddd FreeBSD support
jodogne
parents: 1288
diff changeset
138
1026
a13ccd93df28 fix OS X build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 907
diff changeset
139 #elif defined(__APPLE__) && defined(__MACH__)
a13ccd93df28 fix OS X build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 907
diff changeset
140 SharedLibrary l("libdl.dylib");
a13ccd93df28 fix OS X build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 907
diff changeset
141 ASSERT_THROW(l.GetFunction("world"), OrthancException);
a13ccd93df28 fix OS X build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 907
diff changeset
142 ASSERT_TRUE(l.GetFunction("dlopen") != NULL);
a13ccd93df28 fix OS X build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 907
diff changeset
143 ASSERT_TRUE(l.HasFunction("dlclose"));
a13ccd93df28 fix OS X build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 907
diff changeset
144 ASSERT_FALSE(l.HasFunction("world"));
a13ccd93df28 fix OS X build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 907
diff changeset
145
885
0570a8c859cb SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146 #else
0570a8c859cb SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
147 #error Support your platform here
0570a8c859cb SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
148 #endif
0570a8c859cb SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
149 }
1578
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
150
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
151 #endif