comparison UnitTestsSources/PluginsTests.cpp @ 2884:497a637366b4 db-changes

integration mainline->db-changes
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 12 Oct 2018 15:18:10 +0200
parents be5c0f4155f6
children 3254b36a5f9b
comparison
equal deleted inserted replaced
1762:2b91363cc1d1 2884:497a637366b4
1 /** 1 /**
2 * Orthanc - A Lightweight, RESTful DICOM Store 2 * Orthanc - A Lightweight, RESTful DICOM Store
3 * Copyright (C) 2012-2015 Sebastien Jodogne, Medical Physics 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
4 * Department, University Hospital of Liege, Belgium 4 * Department, University Hospital of Liege, Belgium
5 * Copyright (C) 2017-2018 Osimis S.A., Belgium
5 * 6 *
6 * This program is free software: you can redistribute it and/or 7 * This program is free software: you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as 8 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation, either version 3 of the 9 * published by the Free Software Foundation, either version 3 of the
9 * License, or (at your option) any later version. 10 * License, or (at your option) any later version.
31 32
32 33
33 #include "PrecompiledHeadersUnitTests.h" 34 #include "PrecompiledHeadersUnitTests.h"
34 #include "gtest/gtest.h" 35 #include "gtest/gtest.h"
35 36
37 #include "../../Core/OrthancException.h"
36 #include "../Plugins/Engine/PluginsManager.h" 38 #include "../Plugins/Engine/PluginsManager.h"
37 39
38 using namespace Orthanc; 40 using namespace Orthanc;
39 41
40 42
41 #if ORTHANC_PLUGINS_ENABLED == 1 43 #if ORTHANC_ENABLE_PLUGINS == 1
42 44
43 TEST(SharedLibrary, Enumerations) 45 TEST(SharedLibrary, Enumerations)
44 { 46 {
45 // The plugin engine cannot work if the size of an enumeration does 47 // The plugin engine cannot work if the size of an enumeration does
46 // not correspond to the size of "int32_t" 48 // not correspond to the size of "int32_t"
55 ASSERT_THROW(l.GetFunction("world"), OrthancException); 57 ASSERT_THROW(l.GetFunction("world"), OrthancException);
56 ASSERT_TRUE(l.GetFunction("GetVersionExW") != NULL); 58 ASSERT_TRUE(l.GetFunction("GetVersionExW") != NULL);
57 ASSERT_TRUE(l.HasFunction("GetVersionExW")); 59 ASSERT_TRUE(l.HasFunction("GetVersionExW"));
58 ASSERT_FALSE(l.HasFunction("world")); 60 ASSERT_FALSE(l.HasFunction("world"));
59 61
60 #elif defined(__linux) || defined(__FreeBSD_kernel__) 62 #elif defined(__LSB_VERSION__)
63 // For Linux Standard Base, we use a low-level shared library coming
64 // with glibc:
65 // http://www.linuxfromscratch.org/lfs/view/6.5/chapter06/glibc.html
66 SharedLibrary l("libSegFault.so");
67 ASSERT_THROW(l.GetFunction("world"), OrthancException);
68 ASSERT_TRUE(l.GetFunction("_init") != NULL);
69 ASSERT_TRUE(l.HasFunction("_init"));
70 ASSERT_FALSE(l.HasFunction("world"));
71
72 #elif defined(__linux__) || defined(__FreeBSD_kernel__)
61 SharedLibrary l("libdl.so"); 73 SharedLibrary l("libdl.so");
62 ASSERT_THROW(l.GetFunction("world"), OrthancException); 74 ASSERT_THROW(l.GetFunction("world"), OrthancException);
63 ASSERT_TRUE(l.GetFunction("dlopen") != NULL); 75 ASSERT_TRUE(l.GetFunction("dlopen") != NULL);
64 ASSERT_TRUE(l.HasFunction("dlclose")); 76 ASSERT_TRUE(l.HasFunction("dlclose"));
65 ASSERT_FALSE(l.HasFunction("world")); 77 ASSERT_FALSE(l.HasFunction("world"));
66 78
67 #elif defined(__FreeBSD__) 79 #elif defined(__FreeBSD__) || defined(__OpenBSD__)
68 // dlopen() in FreeBSD is supplied by libc, libc.so is 80 // dlopen() in FreeBSD/OpenBSD is supplied by libc, libc.so is
69 // a ldscript, so we can't actually use it. Use thread 81 // a ldscript, so we can't actually use it. Use thread
70 // library instead - if it works - dlopen() is good. 82 // library instead - if it works - dlopen() is good.
71 SharedLibrary l("libpthread.so"); 83 SharedLibrary l("libpthread.so");
72 ASSERT_THROW(l.GetFunction("world"), OrthancException); 84 ASSERT_THROW(l.GetFunction("world"), OrthancException);
73 ASSERT_TRUE(l.GetFunction("pthread_create") != NULL); 85 ASSERT_TRUE(l.GetFunction("pthread_create") != NULL);