Mercurial > hg > orthanc
changeset 4854:8bd1f0d9506e
improved fix of unit test SharedLibrary.Basic
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 16 Dec 2021 16:13:03 +0100 |
parents | b3d0a3a4d890 |
children | ffc03a1d60c3 |
files | OrthancServer/UnitTestsSources/PluginsTests.cpp |
diffstat | 1 files changed, 41 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/OrthancServer/UnitTestsSources/PluginsTests.cpp Thu Dec 16 14:48:46 2021 +0100 +++ b/OrthancServer/UnitTestsSources/PluginsTests.cpp Thu Dec 16 16:13:03 2021 +0100 @@ -88,25 +88,54 @@ //ASSERT_TRUE(l.HasFunction("_init")); #elif defined(__linux__) || defined(__FreeBSD_kernel__) - std::unique_ptr<SharedLibrary> l; + /** + * Since Orthanc 1.9.8, we test the "libdl.so.2" instead of the + * "libdl.so", as discussed here: + * https://groups.google.com/g/orthanc-users/c/I5g1fN6MCvg/m/JVdvRyjJAAAJ + * https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1001305 + * https://salsa.debian.org/med-team/orthanc/-/blob/master/debian/patches/glibc-2.34.patch + **/ + try { - /** - * Since Orthanc 1.9.8, we test the "libdl.so.2" instead of the - * "libdl.so", as discussed here: - * https://groups.google.com/g/orthanc-users/c/I5g1fN6MCvg/m/JVdvRyjJAAAJ - **/ - l.reset(new SharedLibrary("libdl.so.2")); + SharedLibrary l("libdl.so.2"); + ASSERT_THROW(l.GetFunction("world"), OrthancException); + ASSERT_TRUE(l.GetFunction("dlopen") != NULL); + ASSERT_TRUE(l.HasFunction("dlclose")); + ASSERT_FALSE(l.HasFunction("world")); + return; // Success } catch (OrthancException&) { - l.reset(new SharedLibrary("libdl.so")); // Fallback for backward compat + } + + try + { + SharedLibrary l("libdl.so"); // Fallback for backward compat + ASSERT_THROW(l.GetFunction("world"), OrthancException); + ASSERT_TRUE(l.GetFunction("dlopen") != NULL); + ASSERT_TRUE(l.HasFunction("dlclose")); + ASSERT_FALSE(l.HasFunction("world")); + return; // Success + } + catch (OrthancException&) + { } - ASSERT_THROW(l->GetFunction("world"), OrthancException); - ASSERT_TRUE(l->GetFunction("dlopen") != NULL); - ASSERT_TRUE(l->HasFunction("dlclose")); - ASSERT_FALSE(l->HasFunction("world")); + try + { + SharedLibrary l("libmemusage.so"); // Try another common library + ASSERT_THROW(l.GetFunction("world"), OrthancException); + ASSERT_TRUE(l.GetFunction("munmap") != NULL); + ASSERT_TRUE(l.HasFunction("free")); + ASSERT_FALSE(l.HasFunction("world")); + return; // Success + } + catch (OrthancException&) + { + } + + ASSERT_TRUE(0); #elif defined(__FreeBSD__) || defined(__OpenBSD__) // dlopen() in FreeBSD/OpenBSD is supplied by libc, libc.so is