summaryrefslogtreecommitdiffstats
path: root/Source/kwsys
diff options
context:
space:
mode:
authorMathieu Malaterre <mathieu.malaterre@gmail.com>2006-03-09 22:08:33 (GMT)
committerMathieu Malaterre <mathieu.malaterre@gmail.com>2006-03-09 22:08:33 (GMT)
commit20c680e7fce1966febae6af15d698484d6a8883b (patch)
treea90ec018238748dc916c9a3c73288f5922d3656a /Source/kwsys
parent117c871790c05ab8ae95417572ce5fe6c258b9a7 (diff)
downloadCMake-20c680e7fce1966febae6af15d698484d6a8883b.zip
CMake-20c680e7fce1966febae6af15d698484d6a8883b.tar.gz
CMake-20c680e7fce1966febae6af15d698484d6a8883b.tar.bz2
ENH: Still more coverage of the DynamicLoader
Diffstat (limited to 'Source/kwsys')
-rw-r--r--Source/kwsys/CMakeLists.txt1
-rw-r--r--Source/kwsys/testDynamicLoader.cxx20
2 files changed, 19 insertions, 2 deletions
diff --git a/Source/kwsys/CMakeLists.txt b/Source/kwsys/CMakeLists.txt
index cc08056..47c4269 100644
--- a/Source/kwsys/CMakeLists.txt
+++ b/Source/kwsys/CMakeLists.txt
@@ -515,6 +515,7 @@ IF(KWSYS_C_SRCS OR KWSYS_CXX_SRCS)
# If kwsys contains the DynamicLoader, need extra library
IF(KWSYS_USE_DynamicLoader)
+ ADD_LIBRARY(testDynload SHARED testDynload.c)
IF(UNIX)
TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE} dl)
ENDIF(UNIX)
diff --git a/Source/kwsys/testDynamicLoader.cxx b/Source/kwsys/testDynamicLoader.cxx
index 08370d6..588c5fe 100644
--- a/Source/kwsys/testDynamicLoader.cxx
+++ b/Source/kwsys/testDynamicLoader.cxx
@@ -25,7 +25,18 @@
#include "testSystemTools.h"
-/* libname = Library name
+kwsys_stl::string GetLibName(const char* lname)
+{
+ // Construct proper name of lib
+ kwsys_stl::string slname;
+ slname = kwsys::DynamicLoader::LibPrefix();
+ slname += lname;
+ slname += kwsys::DynamicLoader::LibExtension();
+
+ return slname;
+}
+
+/* libname = Library name (proper prefix, proper extension)
* System = symbol to lookup in libname
* r1: should OpenLibrary succeed ?
* r2: should GetSymbolAddress succeed ?
@@ -62,7 +73,7 @@ int main(int , char *[])
{
int res;
// Make sure that inexistant lib is giving correct result
- res = TestDynamicLoader("foobar.lib", "foobar",0,0,0);
+ res = TestDynamicLoader("azerty_", "foo_bar",0,0,0);
// Make sure that random binary file cannnot be assimilated as dylib
res += TestDynamicLoader(TEST_SYSTEMTOOLS_BIN_FILE, "wp",0,0,0);
#ifdef __linux__
@@ -71,6 +82,11 @@ int main(int , char *[])
res += TestDynamicLoader("libdl.so", "dlopen",1,1,1);
res += TestDynamicLoader("libdl.so", "TestDynamicLoader",1,0,1);
#endif
+ // Now try on the generated library
+ kwsys_stl::string libname = GetLibName("testDynload");
+ res += TestDynamicLoader(libname.c_str(), "dummy",1,0,1);
+ res += TestDynamicLoader(libname.c_str(), "TestDynamicLoaderFunction",1,1,1);
+ res += TestDynamicLoader(libname.c_str(), "TestDynamicLoaderData",1,1,1);
return res;
}