summaryrefslogtreecommitdiffstats
path: root/testDynamicLoader.cxx
diff options
context:
space:
mode:
authorKWSys Upstream <kwrobot@kitware.com>2019-03-28 15:02:39 (GMT)
committerBrad King <brad.king@kitware.com>2019-03-28 15:06:33 (GMT)
commit816663495874e123c2d4a187edb6eab07593f10d (patch)
treef5c66bdc6feb14075ebcf3911896b1a044fa2598 /testDynamicLoader.cxx
parent868dc1a121f9876a19852e0c6467483ad0d67951 (diff)
downloadCMake-816663495874e123c2d4a187edb6eab07593f10d.zip
CMake-816663495874e123c2d4a187edb6eab07593f10d.tar.gz
CMake-816663495874e123c2d4a187edb6eab07593f10d.tar.bz2
KWSys 2019-03-28 (e92bdbe8)
Code extracted from: https://gitlab.kitware.com/utils/kwsys.git at commit e92bdbe8e6eca2a8b6dcf14920e5e25308504206 (master). Upstream Shortlog ----------------- Ben Boeckel (7): 30198dbc DynamicLoader: fix error reporting on Windows cf6b5f69 DynamicLoader: use Encoding::ToWindowsExtendedPath for the libname d17291ad DynamicLoader: support loading libraries using flags 40d9e482 DynamicLoader: support loading sibling libraries on Windows 971809c5 DynamicLoader: test the SearchBesideLibrary flag efb006b9 DynamicLoader: include stdio.h for _snprintf 9e8e9ba0 DynamicLoader: avoid the min/max macros from windows.h Brad King (1): 92334e76 SystemTools: CopyFileAlways: avoid copying file over self
Diffstat (limited to 'testDynamicLoader.cxx')
-rw-r--r--testDynamicLoader.cxx28
1 files changed, 22 insertions, 6 deletions
diff --git a/testDynamicLoader.cxx b/testDynamicLoader.cxx
index ce87117..eff2ed7 100644
--- a/testDynamicLoader.cxx
+++ b/testDynamicLoader.cxx
@@ -21,11 +21,15 @@
// left on disk.
#include <testSystemTools.h>
-static std::string GetLibName(const char* lname)
+static std::string GetLibName(const char* lname, const char* subdir = NULL)
{
// Construct proper name of lib
std::string slname;
slname = EXECUTABLE_OUTPUT_PATH;
+ if (subdir) {
+ slname += "/";
+ slname += subdir;
+ }
#ifdef CMAKE_INTDIR
slname += "/";
slname += CMAKE_INTDIR;
@@ -45,26 +49,29 @@ static std::string GetLibName(const char* lname)
* r3: should CloseLibrary succeed ?
*/
static int TestDynamicLoader(const char* libname, const char* symbol, int r1,
- int r2, int r3)
+ int r2, int r3, int flags = 0)
{
std::cerr << "Testing: " << libname << std::endl;
kwsys::DynamicLoader::LibraryHandle l =
- kwsys::DynamicLoader::OpenLibrary(libname);
+ kwsys::DynamicLoader::OpenLibrary(libname, flags);
// If result is incompatible with expectation just fails (xor):
if ((r1 && !l) || (!r1 && l)) {
- std::cerr << kwsys::DynamicLoader::LastError() << std::endl;
+ std::cerr << "OpenLibrary: " << kwsys::DynamicLoader::LastError()
+ << std::endl;
return 1;
}
kwsys::DynamicLoader::SymbolPointer f =
kwsys::DynamicLoader::GetSymbolAddress(l, symbol);
if ((r2 && !f) || (!r2 && f)) {
- std::cerr << kwsys::DynamicLoader::LastError() << std::endl;
+ std::cerr << "GetSymbolAddress: " << kwsys::DynamicLoader::LastError()
+ << std::endl;
return 1;
}
#ifndef __APPLE__
int s = kwsys::DynamicLoader::CloseLibrary(l);
if ((r3 && !s) || (!r3 && s)) {
- std::cerr << kwsys::DynamicLoader::LastError() << std::endl;
+ std::cerr << "CloseLibrary: " << kwsys::DynamicLoader::LastError()
+ << std::endl;
return 1;
}
#else
@@ -113,5 +120,14 @@ int testDynamicLoader(int argc, char* argv[])
res += TestDynamicLoader(libname.c_str(), "TestDynamicLoaderData", 1, 1, 1);
res += TestDynamicLoader(libname.c_str(), "_TestDynamicLoaderData", 1, 0, 1);
+#ifdef _WIN32
+ libname = GetLibName(KWSYS_NAMESPACE_STRING "TestDynloadUse", "dynloaddir");
+ res += TestDynamicLoader(libname.c_str(), "dummy", 0, 0, 0);
+ res += TestDynamicLoader(libname.c_str(), "TestLoad", 1, 1, 1,
+ kwsys::DynamicLoader::SearchBesideLibrary);
+ res += TestDynamicLoader(libname.c_str(), "_TestLoad", 1, 0, 1,
+ kwsys::DynamicLoader::SearchBesideLibrary);
+#endif
+
return res;
}