summaryrefslogtreecommitdiffstats
path: root/Source/kwsys/testDynamicLoader.cxx
diff options
context:
space:
mode:
authorMathieu Malaterre <mathieu.malaterre@gmail.com>2006-03-09 19:35:56 (GMT)
committerMathieu Malaterre <mathieu.malaterre@gmail.com>2006-03-09 19:35:56 (GMT)
commit428bc2482305b757d930e337eab353615b49ed65 (patch)
treea66bf01672ccb5b86f02368cca07598b12d8e043 /Source/kwsys/testDynamicLoader.cxx
parent4c5ba06fa13a2bc07f7e0a26bf455dc0b09d5e9c (diff)
downloadCMake-428bc2482305b757d930e337eab353615b49ed65.zip
CMake-428bc2482305b757d930e337eab353615b49ed65.tar.gz
CMake-428bc2482305b757d930e337eab353615b49ed65.tar.bz2
ENH: Adding initial test for DynamicLoader
Diffstat (limited to 'Source/kwsys/testDynamicLoader.cxx')
-rw-r--r--Source/kwsys/testDynamicLoader.cxx58
1 files changed, 58 insertions, 0 deletions
diff --git a/Source/kwsys/testDynamicLoader.cxx b/Source/kwsys/testDynamicLoader.cxx
new file mode 100644
index 0000000..b988767
--- /dev/null
+++ b/Source/kwsys/testDynamicLoader.cxx
@@ -0,0 +1,58 @@
+/*=========================================================================
+
+ Program: KWSys - Kitware System Library
+ Module: $RCSfile$
+
+ Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved.
+ See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the above copyright notices for more information.
+
+=========================================================================*/
+#include "kwsysPrivate.h"
+
+#include KWSYS_HEADER(DynamicLoader.hxx)
+#include KWSYS_HEADER(ios/iostream)
+
+// Work-around CMake dependency scanning limitation. This must
+// duplicate the above list of headers.
+#if 0
+# include "DynamicLoader.hxx.in"
+# include "kwsys_ios_iostream.h.in"
+#endif
+
+int TestDynamicLoader(const char* libname, const char* symbol)
+{
+ kwsys::LibHandle l = kwsys::DynamicLoader::OpenLibrary(libname);
+ if( l )
+ {
+ kwsys_ios::cerr
+ << kwsys::DynamicLoader::LastError() << kwsys_ios::endl;
+ return 1;
+ }
+ kwsys::DynamicLoaderFunction f =
+ kwsys::DynamicLoader::GetSymbolAddress(l, symbol);
+ if( f )
+ {
+ kwsys_ios::cerr
+ << kwsys::DynamicLoader::LastError() << kwsys_ios::endl;
+ return 1;
+ }
+ int success = kwsys::DynamicLoader::CloseLibrary(l);
+ if( success )
+ {
+ kwsys_ios::cerr
+ << kwsys::DynamicLoader::LastError() << kwsys_ios::endl;
+ return 1;
+ }
+ return 0;
+}
+
+int main(int , char *[])
+{
+ int res = TestDynamicLoader("foobar.lib", "foobar");
+
+ return res;
+}