From 5eda3799074f858f7790975b7a294374720177f7 Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Mon, 25 Oct 2004 15:08:05 -0400 Subject: ENH: clean up loaded command test so you can tell what really failed --- Tests/LoadCommand/CMakeLists.txt | 6 +++-- Tests/LoadCommand/LoadedCommand.cxx | 33 ++++++++++++++++++--------- Tests/LoadCommand/LoadedCommand.h.in | 3 ++- Tests/LoadCommandOneConfig/CMakeLists.txt | 6 +++-- Tests/LoadCommandOneConfig/LoadedCommand.cxx | 33 ++++++++++++++++++--------- Tests/LoadCommandOneConfig/LoadedCommand.h.in | 3 ++- 6 files changed, 56 insertions(+), 28 deletions(-) diff --git a/Tests/LoadCommand/CMakeLists.txt b/Tests/LoadCommand/CMakeLists.txt index 1d261be..f69d292 100644 --- a/Tests/LoadCommand/CMakeLists.txt +++ b/Tests/LoadCommand/CMakeLists.txt @@ -5,6 +5,7 @@ SET (TEST_COMMAND_TEST1 1) INCLUDE (${CMAKE_ROOT}/Modules/CheckTypeSize.cmake) CHECK_TYPE_SIZE(char SIZEOF_CHAR) +CHECK_TYPE_SIZE(short SIZEOF_SHORT) INCLUDE (CheckFunctionExists) CHECK_FUNCTION_EXISTS(printf HAVE_PRINTF) @@ -55,8 +56,9 @@ ELSE (COMPILE_OK) MESSAGE("failed to compile CMAKE_LOADED_COMMANDS") ENDIF (COMPILE_OK) -IF (TEST_DEF) +# TEST_DEF is set by the loaded command cmTestCommand.c +IF (TEST_DEF AND SOME_CACHE_VARIABLE) ADD_DEFINITIONS(-DCMAKE_IS_FUN) -ENDIF (TEST_DEF) +ENDIF (TEST_DEF AND SOME_CACHE_VARIABLE) ADD_EXECUTABLE (LoadedCommand LoadedCommand.cxx) diff --git a/Tests/LoadCommand/LoadedCommand.cxx b/Tests/LoadCommand/LoadedCommand.cxx index 04daff0..c58bcf1 100644 --- a/Tests/LoadCommand/LoadedCommand.cxx +++ b/Tests/LoadCommand/LoadedCommand.cxx @@ -1,30 +1,41 @@ #include "LoadedCommand.h" #include +int testSizeOf(int s1, int s2) +{ + return s1 - s2; +} + int main () { + int ret = 0; #ifdef HAVE_VSBLABLA printf("Should not be able to find vsblabla\n"); - return 1; + ret = 1; #endif #if !defined( HAVE_PRINTF ) printf("Should be able to find printf\n"); - return 1; + ret= 1; #endif #if !defined( ADDED_DEFINITION ) printf("Should have ADDED_DEFINITION defined\n"); - return 1; + ret= 1; +#endif +#if !defined(CMAKE_IS_FUN) + printf("Loaded Command was not built with CMAKE_IS_FUN: failed.\n"); + ret = 1; #endif - if(SIZEOF_CHAR != 1) + if(testSizeOf(SIZEOF_CHAR, sizeof(char))) { - printf("Size of char is not one, something is broken\n"); + printf("Size of char is broken.\n"); + ret = 1; } - -#ifdef CMAKE_IS_FUN - return SIZEOF_CHAR-1; -#else - return SIZEOF_SHORT; -#endif + if(testSizeOf(SIZEOF_SHORT, sizeof(short))) + { + printf("Size of short is broken.\n"); + ret = 1; + } + return ret; } diff --git a/Tests/LoadCommand/LoadedCommand.h.in b/Tests/LoadCommand/LoadedCommand.h.in index b910e49..7a0a15d 100644 --- a/Tests/LoadCommand/LoadedCommand.h.in +++ b/Tests/LoadCommand/LoadedCommand.h.in @@ -1,5 +1,6 @@ /* Check for size of types */ #cmakedefine SIZEOF_CHAR ${SIZEOF_CHAR} +#cmakedefine SIZEOF_SHORT ${SIZEOF_SHORT} /* Check for functions */ #cmakedefine HAVE_PRINTF @@ -9,4 +10,4 @@ #cmakedefine HAVE_SYS_PRCTL_H /* Check for libraries */ -#cmakedefine HAVE_LIBM \ No newline at end of file +#cmakedefine HAVE_LIBM diff --git a/Tests/LoadCommandOneConfig/CMakeLists.txt b/Tests/LoadCommandOneConfig/CMakeLists.txt index 1d261be..f69d292 100644 --- a/Tests/LoadCommandOneConfig/CMakeLists.txt +++ b/Tests/LoadCommandOneConfig/CMakeLists.txt @@ -5,6 +5,7 @@ SET (TEST_COMMAND_TEST1 1) INCLUDE (${CMAKE_ROOT}/Modules/CheckTypeSize.cmake) CHECK_TYPE_SIZE(char SIZEOF_CHAR) +CHECK_TYPE_SIZE(short SIZEOF_SHORT) INCLUDE (CheckFunctionExists) CHECK_FUNCTION_EXISTS(printf HAVE_PRINTF) @@ -55,8 +56,9 @@ ELSE (COMPILE_OK) MESSAGE("failed to compile CMAKE_LOADED_COMMANDS") ENDIF (COMPILE_OK) -IF (TEST_DEF) +# TEST_DEF is set by the loaded command cmTestCommand.c +IF (TEST_DEF AND SOME_CACHE_VARIABLE) ADD_DEFINITIONS(-DCMAKE_IS_FUN) -ENDIF (TEST_DEF) +ENDIF (TEST_DEF AND SOME_CACHE_VARIABLE) ADD_EXECUTABLE (LoadedCommand LoadedCommand.cxx) diff --git a/Tests/LoadCommandOneConfig/LoadedCommand.cxx b/Tests/LoadCommandOneConfig/LoadedCommand.cxx index 04daff0..c58bcf1 100644 --- a/Tests/LoadCommandOneConfig/LoadedCommand.cxx +++ b/Tests/LoadCommandOneConfig/LoadedCommand.cxx @@ -1,30 +1,41 @@ #include "LoadedCommand.h" #include +int testSizeOf(int s1, int s2) +{ + return s1 - s2; +} + int main () { + int ret = 0; #ifdef HAVE_VSBLABLA printf("Should not be able to find vsblabla\n"); - return 1; + ret = 1; #endif #if !defined( HAVE_PRINTF ) printf("Should be able to find printf\n"); - return 1; + ret= 1; #endif #if !defined( ADDED_DEFINITION ) printf("Should have ADDED_DEFINITION defined\n"); - return 1; + ret= 1; +#endif +#if !defined(CMAKE_IS_FUN) + printf("Loaded Command was not built with CMAKE_IS_FUN: failed.\n"); + ret = 1; #endif - if(SIZEOF_CHAR != 1) + if(testSizeOf(SIZEOF_CHAR, sizeof(char))) { - printf("Size of char is not one, something is broken\n"); + printf("Size of char is broken.\n"); + ret = 1; } - -#ifdef CMAKE_IS_FUN - return SIZEOF_CHAR-1; -#else - return SIZEOF_SHORT; -#endif + if(testSizeOf(SIZEOF_SHORT, sizeof(short))) + { + printf("Size of short is broken.\n"); + ret = 1; + } + return ret; } diff --git a/Tests/LoadCommandOneConfig/LoadedCommand.h.in b/Tests/LoadCommandOneConfig/LoadedCommand.h.in index b910e49..7a0a15d 100644 --- a/Tests/LoadCommandOneConfig/LoadedCommand.h.in +++ b/Tests/LoadCommandOneConfig/LoadedCommand.h.in @@ -1,5 +1,6 @@ /* Check for size of types */ #cmakedefine SIZEOF_CHAR ${SIZEOF_CHAR} +#cmakedefine SIZEOF_SHORT ${SIZEOF_SHORT} /* Check for functions */ #cmakedefine HAVE_PRINTF @@ -9,4 +10,4 @@ #cmakedefine HAVE_SYS_PRCTL_H /* Check for libraries */ -#cmakedefine HAVE_LIBM \ No newline at end of file +#cmakedefine HAVE_LIBM -- cgit v0.12