summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2007-03-03 15:47:06 (GMT)
committerBrad King <brad.king@kitware.com>2007-03-03 15:47:06 (GMT)
commit0edbb68352475ae48dd31dde7384dd0816a8fb39 (patch)
tree24c06cb86f783cee05bd43508ba2d86414cc30d4
parent42e1ffb7f5ef5c8a570e08f4a587f34458172325 (diff)
downloadCMake-0edbb68352475ae48dd31dde7384dd0816a8fb39.zip
CMake-0edbb68352475ae48dd31dde7384dd0816a8fb39.tar.gz
CMake-0edbb68352475ae48dd31dde7384dd0816a8fb39.tar.bz2
ENH: Cleaned up KWSys tests to use test drivers.
-rw-r--r--Source/CMakeLists.txt2
-rw-r--r--Source/kwsys/CMakeLists.txt128
-rw-r--r--Source/kwsys/testCommandLineArguments.cxx2
-rw-r--r--Source/kwsys/testCommandLineArguments1.cxx2
-rw-r--r--Source/kwsys/testDynamicLoader.cxx4
-rw-r--r--Source/kwsys/testFail.c2
-rw-r--r--Source/kwsys/testHashSTL.cxx2
-rw-r--r--Source/kwsys/testIOS.cxx2
-rw-r--r--Source/kwsys/testRegistry.cxx2
-rw-r--r--Source/kwsys/testSystemTools.cxx2
-rw-r--r--Source/kwsys/testTerminal.c4
11 files changed, 87 insertions, 65 deletions
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt
index 217d407..a8c262a 100644
--- a/Source/CMakeLists.txt
+++ b/Source/CMakeLists.txt
@@ -982,7 +982,7 @@ IF(BUILD_TESTING)
--build-generator ${CMAKE_TEST_GENERATOR}
--build-makeprogram ${CMAKE_TEST_MAKEPROGRAM}
--build-project kwsys
- --test-command testIOS
+ --test-command kwsysTestsCxx testIOS
)
ENDIF(NOT CMAKE_TEST_DIFFERENT_GENERATOR)
SET(MAKE_IS_GNU )
diff --git a/Source/kwsys/CMakeLists.txt b/Source/kwsys/CMakeLists.txt
index e8f1646..4e6b4ec 100644
--- a/Source/kwsys/CMakeLists.txt
+++ b/Source/kwsys/CMakeLists.txt
@@ -112,6 +112,11 @@ IF(NOT KWSYS_NAMESPACE)
SET(KWSYS_STANDALONE 1)
ENDIF(NOT KWSYS_NAMESPACE)
+#-----------------------------------------------------------------------------
+# The project name is that of the specified namespace.
+PROJECT(${KWSYS_NAMESPACE})
+
+# Select library components.
IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
SET(KWSYS_ENABLE_C 1)
@@ -131,9 +136,14 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
SET(KWSYS_USE_IOStream 1)
ENDIF(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
-#-----------------------------------------------------------------------------
-# The project name is that of the specified namespace.
-PROJECT(${KWSYS_NAMESPACE})
+# Disable deprecation warnings for standard C and STL functions in
+# VS2005 and later.
+IF(KWSYS_STANDALONE)
+ IF(MSVC80)
+ ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
+ ADD_DEFINITIONS(-D_SCL_SECURE_NO_DEPRECATE)
+ ENDIF(MSVC80)
+ENDIF(KWSYS_STANDALONE)
# Setup the large file support default.
IF(KWSYS_LFS_DISABLE)
@@ -836,41 +846,49 @@ ENDIF(KWSYS_USE_Process)
# Setup testing if not being built as part of another project.
IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
IF(BUILD_TESTING)
- # C++ tests
- IF(KWSYS_USE_DynamicLoader)
- SET(EXTRA_TESTS
- testDynamicLoader
- )
- # If kwsys contains the DynamicLoader, need extra library
- ADD_LIBRARY(testDynload MODULE testDynload.c)
- ENDIF(KWSYS_USE_DynamicLoader)
- FOREACH(test
- testSystemTools
- testIOS
- testHashSTL
- testCommandLineArguments
- testCommandLineArguments1
- testRegistry
- ${EXTRA_TESTS}
- )
- ADD_EXECUTABLE(${test} ${test}.cxx)
- TARGET_LINK_LIBRARIES(${test} ${KWSYS_NAMESPACE})
- ENDFOREACH(test)
- # C tests
- FOREACH(test
- testProcess
- testFail
- testTerminal
- )
- ADD_EXECUTABLE(${test} ${test}.c)
- TARGET_LINK_LIBRARIES(${test} ${KWSYS_NAMESPACE}_c)
- ENDFOREACH(test)
-
+ # Compute the location of executables.
SET(EXEC_DIR "${CMAKE_CURRENT_BINARY_DIR}")
IF(EXECUTABLE_OUTPUT_PATH)
SET(EXEC_DIR "${EXECUTABLE_OUTPUT_PATH}")
ENDIF(EXECUTABLE_OUTPUT_PATH)
+ # C tests
+ SET(KWSYS_C_TESTS
+ testTerminal
+ )
+ IF(COMMAND SET_TESTS_PROPERTIES AND COMMAND GET_TEST_PROPERTY AND KWSYS_STANDALONE)
+ SET(KWSYS_C_TESTS ${KWSYS_C_TESTS} testFail)
+ ENDIF(COMMAND SET_TESTS_PROPERTIES AND COMMAND GET_TEST_PROPERTY AND KWSYS_STANDALONE)
+ CREATE_TEST_SOURCELIST(
+ KWSYS_C_TEST_SRCS ${KWSYS_NAMESPACE}TestsC.c
+ ${KWSYS_C_TESTS}
+ )
+ ADD_EXECUTABLE(${KWSYS_NAMESPACE}TestsC ${KWSYS_C_TEST_SRCS})
+ TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE}TestsC ${KWSYS_NAMESPACE}_c)
+ FOREACH(test ${KWSYS_C_TESTS})
+ ADD_TEST(kwsys.${test} ${EXEC_DIR}/${KWSYS_NAMESPACE}TestsC ${test} ${KWSYS_TEST_ARGS_${test}})
+ ENDFOREACH(test)
+
+ # C++ tests
+ SET(KWSYS_CXX_TESTS
+ testHashSTL
+ testRegistry
+ testIOS
+ testSystemTools
+ testCommandLineArguments
+ testCommandLineArguments1
+ )
+ IF(KWSYS_USE_DynamicLoader)
+ SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS} testDynamicLoader)
+ # If kwsys contains the DynamicLoader, need extra library
+ ADD_LIBRARY(${KWSYS_NAMESPACE}TestDynload MODULE testDynload.c)
+ ENDIF(KWSYS_USE_DynamicLoader)
+ CREATE_TEST_SOURCELIST(
+ KWSYS_CXX_TEST_SRCS ${KWSYS_NAMESPACE}TestsCxx.cxx
+ ${KWSYS_CXX_TESTS}
+ )
+ ADD_EXECUTABLE(${KWSYS_NAMESPACE}TestsCxx ${KWSYS_CXX_TEST_SRCS})
+ TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE}TestsCxx ${KWSYS_NAMESPACE})
SET(TEST_SYSTEMTOOLS_BIN_FILE
"${CMAKE_CURRENT_SOURCE_DIR}/testSystemTools.bin")
@@ -886,22 +904,8 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
"${CMAKE_CURRENT_BINARY_DIR}/ExtraTest.cmake")
SET_DIRECTORY_PROPERTIES(PROPERTIES TEST_INCLUDE_FILE "${CMAKE_CURRENT_BINARY_DIR}/ExtraTest.cmake")
ENDIF(CTEST_TEST_KWSYS)
- ADD_TEST(kwsys.testSystemTools ${EXEC_DIR}/testSystemTools)
- IF(KWSYS_USE_DynamicLoader)
- ADD_TEST(kwsys.testDynamicLoader ${EXEC_DIR}/testDynamicLoader)
- ENDIF(KWSYS_USE_DynamicLoader)
- ADD_TEST(kwsys.testProcess-1 ${EXEC_DIR}/testProcess 1)
- ADD_TEST(kwsys.testProcess-2 ${EXEC_DIR}/testProcess 2)
- ADD_TEST(kwsys.testProcess-3 ${EXEC_DIR}/testProcess 3)
- ADD_TEST(kwsys.testProcess-4 ${EXEC_DIR}/testProcess 4)
- ADD_TEST(kwsys.testProcess-5 ${EXEC_DIR}/testProcess 5)
- ADD_TEST(kwsys.testProcess-6 ${EXEC_DIR}/testProcess 6)
- IF(NOT CYGWIN)
- ADD_TEST(kwsys.testProcess-7 ${EXEC_DIR}/testProcess 7)
- ENDIF(NOT CYGWIN)
- ADD_TEST(kwsys.testHashSTL ${EXEC_DIR}/testHashSTL)
- ADD_TEST(kwsys.testRegistry ${EXEC_DIR}/testRegistry)
- ADD_TEST(kwsys.testCommandLineArguments ${EXEC_DIR}/testCommandLineArguments
+
+ SET(KWSYS_TEST_ARGS_testCommandLineArguments
--another-bool-variable
--long3=opt
--set-bool-arg1
@@ -913,22 +917,38 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
--some-multi-argument 5 1 8 3 7 1 3 9 7 1
-N 12.5 -SS=andy -N 1.31 -N 22
-SS=bill -BBtrue -SS=brad
- -BBtrue
+ -BBtrue
-BBfalse
-SS=ken
-A
-C=test
- --long2 hello)
- ADD_TEST(kwsys.testCommandLineArguments1 ${EXEC_DIR}/testCommandLineArguments1
+ --long2 hello
+ )
+ SET(KWSYS_TEST_ARGS_testCommandLineArguments1
--ignored
-n 24
--second-ignored
"-m=test value"
third-ignored
-p
- some junk at the end)
+ some junk at the end
+ )
+ FOREACH(test ${KWSYS_CXX_TESTS})
+ ADD_TEST(kwsys.${test} ${EXEC_DIR}/${KWSYS_NAMESPACE}TestsCxx ${test} ${KWSYS_TEST_ARGS_${test}})
+ ENDFOREACH(test)
+
+ # Process tests.
+ ADD_EXECUTABLE(${KWSYS_NAMESPACE}TestProcess testProcess.c)
+ TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE}TestProcess ${KWSYS_NAMESPACE}_c)
+ IF(NOT CYGWIN)
+ SET(KWSYS_TEST_PROCESS_7 7)
+ ENDIF(NOT CYGWIN)
+ FOREACH(n 1 2 3 4 5 6 ${KWSYS_TEST_PROCESS_7})
+ ADD_TEST(kwsys.testProcess-${n} ${EXEC_DIR}/${KWSYS_NAMESPACE}TestProcess ${n})
+ ENDFOREACH(n)
+
+ # Configure some test properties.
IF(COMMAND SET_TESTS_PROPERTIES AND COMMAND GET_TEST_PROPERTY AND KWSYS_STANDALONE)
- ADD_TEST(kwsys.testFail ${EXEC_DIR}/testFail)
# We expect test to fail
SET_TESTS_PROPERTIES(kwsys.testFail PROPERTIES WILL_FAIL ON)
GET_TEST_PROPERTY(kwsys.testFail WILL_FAIL wfv)
diff --git a/Source/kwsys/testCommandLineArguments.cxx b/Source/kwsys/testCommandLineArguments.cxx
index 8a2a3ad..dba4eb0 100644
--- a/Source/kwsys/testCommandLineArguments.cxx
+++ b/Source/kwsys/testCommandLineArguments.cxx
@@ -58,7 +58,7 @@ bool CompareTwoItemsOnList(const char* i1,
bool CompareTwoItemsOnList(const kwsys_stl::string& i1,
const kwsys_stl::string& i2) { return i1 == i2; }
-int main(int argc, char* argv[])
+int testCommandLineArguments(int argc, char* argv[])
{
// Example run: ./testCommandLineArguments --some-int-variable 4
// --another-bool-variable --some-bool-variable=yes
diff --git a/Source/kwsys/testCommandLineArguments1.cxx b/Source/kwsys/testCommandLineArguments1.cxx
index 26ec5f5..0a4b0d7 100644
--- a/Source/kwsys/testCommandLineArguments1.cxx
+++ b/Source/kwsys/testCommandLineArguments1.cxx
@@ -25,7 +25,7 @@
#include <string.h> /* strcmp */
-int main(int argc, char* argv[])
+int testCommandLineArguments1(int argc, char* argv[])
{
kwsys::CommandLineArguments arg;
arg.Initialize(argc, argv);
diff --git a/Source/kwsys/testDynamicLoader.cxx b/Source/kwsys/testDynamicLoader.cxx
index b13dec6..d9d72d5 100644
--- a/Source/kwsys/testDynamicLoader.cxx
+++ b/Source/kwsys/testDynamicLoader.cxx
@@ -88,7 +88,7 @@ int TestDynamicLoader(const char* libname, const char* symbol, int r1, int r2, i
return 0;
}
-int main(int argc, char *argv[])
+int testDynamicLoader(int argc, char *argv[])
{
#if defined(_WIN32)
SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX);
@@ -113,7 +113,7 @@ int main(int argc, char *argv[])
res += TestDynamicLoader("libdl.so", "TestDynamicLoader",1,0,1);
#endif
// Now try on the generated library
- kwsys_stl::string libname = GetLibName("testDynload");
+ kwsys_stl::string libname = GetLibName(KWSYS_NAMESPACE_STRING "TestDynload");
res += TestDynamicLoader(libname.c_str(), "dummy",1,0,1);
res += TestDynamicLoader(libname.c_str(), "TestDynamicLoaderSymbolPointer",1,1,1);
res += TestDynamicLoader(libname.c_str(), "_TestDynamicLoaderSymbolPointer",1,0,1);
diff --git a/Source/kwsys/testFail.c b/Source/kwsys/testFail.c
index 612295b..c9d62f4 100644
--- a/Source/kwsys/testFail.c
+++ b/Source/kwsys/testFail.c
@@ -2,7 +2,7 @@
#include <stdlib.h>
#include <string.h>
-int main(int argc, char* argv[])
+int testFail(int argc, char* argv[])
{
char* env = getenv("DASHBOARD_TEST_FROM_CTEST");
int oldCtest = 0;
diff --git a/Source/kwsys/testHashSTL.cxx b/Source/kwsys/testHashSTL.cxx
index b8cdab1..9d1c016 100644
--- a/Source/kwsys/testHashSTL.cxx
+++ b/Source/kwsys/testHashSTL.cxx
@@ -68,7 +68,7 @@ bool test_hash_set()
return sum == 3;
}
-int main()
+int testHashSTL(int, char*[])
{
bool result = true;
result = test_hash_map() && result;
diff --git a/Source/kwsys/testIOS.cxx b/Source/kwsys/testIOS.cxx
index d699ae5..632b5c2 100644
--- a/Source/kwsys/testIOS.cxx
+++ b/Source/kwsys/testIOS.cxx
@@ -11,7 +11,7 @@
# include "kwsys_ios_iostream.h.in"
#endif
-int main()
+int testIOS(int, char*[])
{
kwsys_ios::ostringstream ostr;
ostr << "Hello, World!";
diff --git a/Source/kwsys/testRegistry.cxx b/Source/kwsys/testRegistry.cxx
index 09e9737..86a0211 100644
--- a/Source/kwsys/testRegistry.cxx
+++ b/Source/kwsys/testRegistry.cxx
@@ -42,7 +42,7 @@
kwsys_ios::cout << "Error, " << x << " != " << y << kwsys_ios::endl; \
}
-int main(int, char**)
+int testRegistry(int, char*[])
{
int res = 0;
diff --git a/Source/kwsys/testSystemTools.cxx b/Source/kwsys/testSystemTools.cxx
index d633b3d..b88a72e 100644
--- a/Source/kwsys/testSystemTools.cxx
+++ b/Source/kwsys/testSystemTools.cxx
@@ -328,7 +328,7 @@ bool CheckStringOperations()
}
//----------------------------------------------------------------------------
-int main(/*int argc, char* argv*/)
+int testSystemTools(int, char*[])
{
bool res = true;
diff --git a/Source/kwsys/testTerminal.c b/Source/kwsys/testTerminal.c
index fc04bbc..d6d7bda 100644
--- a/Source/kwsys/testTerminal.c
+++ b/Source/kwsys/testTerminal.c
@@ -20,8 +20,10 @@
# include "Terminal.h.in"
#endif
-int main()
+int testTerminal(int argc, char* argv[])
{
+ (void)argc;
+ (void)argv;
kwsysTerminal_cfprintf(kwsysTerminal_Color_ForegroundYellow |
kwsysTerminal_Color_BackgroundBlue |
kwsysTerminal_Color_AssumeTTY,