ENH: try to get better test coverage

This commit is contained in:
Bill Hoffman 2001-08-23 13:57:45 -04:00
parent bd4c5cf362
commit 3a3b55679b
39 changed files with 570 additions and 0 deletions

View File

@ -0,0 +1,26 @@
# a simple test case
PROJECT (Complex)
ADD_DEFINITIONS(-DCMAKE_IS_FUN)
SUBDIRS(Library Executable)
SUBDIR_DEPENDS(Executable Library)
INCLUDE(${Complex_SOURCE_DIR}/VarTests.txt)
CONFIGURE_FILE(
${Complex_SOURCE_DIR}/cmTestConfigure.h.in
${Complex_BINARY_DIR}/cmTestConfigure.h)
INCLUDE_DIRECTORIES(
${Complex_BINARY_DIR}
${Complex_SOURCE_DIR}/Library
${Complex_SOURCE_DIR}/../../Source
)
LINK_DIRECTORIES(
${Complex_BINARY_DIR}/Library
)
INCLUDE_REGULAR_EXPRESSION("^(cmTest|file|sharedFile).*$")
SET (LIBRARY_OUTPUT_PATH ${Complex_BINARY_DIR}/bin/ CACHE PATH "Single output directory for building all libraries.")
SET (EXECUTABLE_OUTPUT_PATH ${Complex_BINARY_DIR}/bin/ CACHE PATH "Single output directory for building all executables.")

View File

@ -0,0 +1,4 @@
ADD_EXECUTABLE(complex complex)
TARGET_LINK_LIBRARIES(complex CMakeTestLibrary)
TARGET_LINK_LIBRARIES(complex CMakeTestLibraryShared)

View File

@ -0,0 +1,104 @@
#include "cmTestConfigure.h"
#include "ExtraSources/file1.h"
#include "file2.h"
#include "sharedFile.h"
#include "cmStandardIncludes.h"
int passed = 0;
int failed = 0;
void Failed(const char* Message, const char* m2= "")
{
std::cerr << "Failed: " << Message << m2 << "\n";
failed++;
}
void Passed(const char* Message, const char* m2="")
{
std::cout << "Passed: " << Message << m2 << "\n";
passed++;
}
main()
{
if(sharedFunction() != 1)
{
Failed("Call to sharedFunction from shared library failed.");
}
else
{
Passed("Call to sharedFunction from shared library worked.");
}
if(file1() != 1)
{
Failed("Call to file1 function from library failed.");
}
else
{
Passed("Call to file1 function returned 1.");
}
if(file2() != 1)
{
Failed("Call to file2 function from library failed.");
}
else
{
Passed("Call to file2 function returned 1.");
}
#ifndef CMAKE_IS_FUN
Failed("CMake is not fun, so it is broken and should be fixed.");
#else
Passed("CMAKE_IS_FUN is defined.");
#endif
#ifdef SHOULD_NOT_BE_DEFINED
Failed("IF or SET is broken, SHOULD_NOT_BE_DEFINED is defined.");
#else
Passed("SHOULD_NOT_BE_DEFINED is not defined.");
#endif
#ifndef SHOULD_BE_DEFINED
Failed("IF or SET is broken, SHOULD_BE_DEFINED is not defined.\n");
#else
Passed("SHOULD_BE_DEFINED is defined.");
#endif
#ifndef ONE_VAR
Failed("cmakedefine is broken, ONE_VAR is not defined.");
#else
Passed("ONE_VAR is defined.");
#endif
#ifdef ZERO_VAR
Failed("cmakedefine is broken, ZERO_VAR is defined.");
#else
Passed("ZERO_VAR is not defined.");
#endif
#ifndef STRING_VAR
Failed("configureFile is broken, STRING_VAR is not defined.");
#else
if(strcmp(STRING_VAR, "CMake is great") != 0)
{
Failed("CMake is not great, so the SET command,"
"or the configurefile comand is broken. STRING_VAR== ",
STRING_VAR);
}
else
{
Passed("STRING_VAR == ", STRING_VAR);
}
#endif
std::cout << "Passed:" << passed << "\n";
if(failed)
{
std::cout << "Failed: " << failed << "\n";
return failed;
}
return 0;
}

View File

@ -0,0 +1,8 @@
AUX_SOURCE_DIRECTORY(ExtraSources LibrarySources)
SOURCE_FILES(LibrarySources file2)
ADD_LIBRARY(CMakeTestLibrary LibrarySources)
SOURCE_FILES(SharedLibrarySources sharedFile)
ADD_LIBRARY(CMakeTestLibraryShared SHARED SharedLibrarySources)

View File

@ -0,0 +1,4 @@
int file1()
{
return 1;
}

View File

@ -0,0 +1 @@
int file1();

View File

@ -0,0 +1,4 @@
int file2()
{
return 1;
}

View File

@ -0,0 +1 @@
int file2();

View File

@ -0,0 +1,6 @@
#include "sharedFile.h"
int sharedFunction()
{
return 1;
}

View File

@ -0,0 +1,12 @@
#if defined(_WIN32) || defined(WIN32) /* Win32 version */
#ifdef CMakeTestLibraryShared_EXPORTS
# define CMakeTest_EXPORT __declspec(dllexport)
#else
# define CMakeTest_EXPORT __declspec(dllimport)
#endif
#else
// unix needs nothing
#define CMakeTest_EXPORT
#endif
CMakeTest_EXPORT int sharedFunction();

View File

@ -0,0 +1,11 @@
SET (ZERO_VAR 0)
IF(ZERO_VAR)
ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED)
ELSE(ZERO_VAR)
ADD_DEFINITIONS(-DSHOULD_BE_DEFINED)
ENDIF(ZERO_VAR)
SET(ONE_VAR 1)
SET(STRING_VAR "CMake is great" CACHE STRING "test a cache variable")

View File

@ -0,0 +1,5 @@
#cmakedefine ONE_VAR
#cmakedefine ZERO_VAR
#define STRING_VAR "${STRING_VAR}"

4
Tests/Complex/simple.cxx Normal file
View File

@ -0,0 +1,4 @@
int main ()
{
return 0;
}

View File

@ -0,0 +1,26 @@
# a simple test case
PROJECT (Complex)
ADD_DEFINITIONS(-DCMAKE_IS_FUN)
SUBDIRS(Library Executable)
SUBDIR_DEPENDS(Executable Library)
INCLUDE(${Complex_SOURCE_DIR}/VarTests.txt)
CONFIGURE_FILE(
${Complex_SOURCE_DIR}/cmTestConfigure.h.in
${Complex_BINARY_DIR}/cmTestConfigure.h)
INCLUDE_DIRECTORIES(
${Complex_BINARY_DIR}
${Complex_SOURCE_DIR}/Library
${Complex_SOURCE_DIR}/../../Source
)
LINK_DIRECTORIES(
${Complex_BINARY_DIR}/Library
)
INCLUDE_REGULAR_EXPRESSION("^(cmTest|file|sharedFile).*$")
SET (LIBRARY_OUTPUT_PATH ${Complex_BINARY_DIR}/bin/ CACHE PATH "Single output directory for building all libraries.")
SET (EXECUTABLE_OUTPUT_PATH ${Complex_BINARY_DIR}/bin/ CACHE PATH "Single output directory for building all executables.")

View File

@ -0,0 +1,4 @@
ADD_EXECUTABLE(complex complex)
TARGET_LINK_LIBRARIES(complex CMakeTestLibrary)
TARGET_LINK_LIBRARIES(complex CMakeTestLibraryShared)

View File

@ -0,0 +1,104 @@
#include "cmTestConfigure.h"
#include "ExtraSources/file1.h"
#include "file2.h"
#include "sharedFile.h"
#include "cmStandardIncludes.h"
int passed = 0;
int failed = 0;
void Failed(const char* Message, const char* m2= "")
{
std::cerr << "Failed: " << Message << m2 << "\n";
failed++;
}
void Passed(const char* Message, const char* m2="")
{
std::cout << "Passed: " << Message << m2 << "\n";
passed++;
}
main()
{
if(sharedFunction() != 1)
{
Failed("Call to sharedFunction from shared library failed.");
}
else
{
Passed("Call to sharedFunction from shared library worked.");
}
if(file1() != 1)
{
Failed("Call to file1 function from library failed.");
}
else
{
Passed("Call to file1 function returned 1.");
}
if(file2() != 1)
{
Failed("Call to file2 function from library failed.");
}
else
{
Passed("Call to file2 function returned 1.");
}
#ifndef CMAKE_IS_FUN
Failed("CMake is not fun, so it is broken and should be fixed.");
#else
Passed("CMAKE_IS_FUN is defined.");
#endif
#ifdef SHOULD_NOT_BE_DEFINED
Failed("IF or SET is broken, SHOULD_NOT_BE_DEFINED is defined.");
#else
Passed("SHOULD_NOT_BE_DEFINED is not defined.");
#endif
#ifndef SHOULD_BE_DEFINED
Failed("IF or SET is broken, SHOULD_BE_DEFINED is not defined.\n");
#else
Passed("SHOULD_BE_DEFINED is defined.");
#endif
#ifndef ONE_VAR
Failed("cmakedefine is broken, ONE_VAR is not defined.");
#else
Passed("ONE_VAR is defined.");
#endif
#ifdef ZERO_VAR
Failed("cmakedefine is broken, ZERO_VAR is defined.");
#else
Passed("ZERO_VAR is not defined.");
#endif
#ifndef STRING_VAR
Failed("configureFile is broken, STRING_VAR is not defined.");
#else
if(strcmp(STRING_VAR, "CMake is great") != 0)
{
Failed("CMake is not great, so the SET command,"
"or the configurefile comand is broken. STRING_VAR== ",
STRING_VAR);
}
else
{
Passed("STRING_VAR == ", STRING_VAR);
}
#endif
std::cout << "Passed:" << passed << "\n";
if(failed)
{
std::cout << "Failed: " << failed << "\n";
return failed;
}
return 0;
}

View File

@ -0,0 +1,8 @@
AUX_SOURCE_DIRECTORY(ExtraSources LibrarySources)
SOURCE_FILES(LibrarySources file2)
ADD_LIBRARY(CMakeTestLibrary LibrarySources)
SOURCE_FILES(SharedLibrarySources sharedFile)
ADD_LIBRARY(CMakeTestLibraryShared SHARED SharedLibrarySources)

View File

@ -0,0 +1,4 @@
int file1()
{
return 1;
}

View File

@ -0,0 +1 @@
int file1();

View File

@ -0,0 +1,4 @@
int file2()
{
return 1;
}

View File

@ -0,0 +1 @@
int file2();

View File

@ -0,0 +1,6 @@
#include "sharedFile.h"
int sharedFunction()
{
return 1;
}

View File

@ -0,0 +1,12 @@
#if defined(_WIN32) || defined(WIN32) /* Win32 version */
#ifdef CMakeTestLibraryShared_EXPORTS
# define CMakeTest_EXPORT __declspec(dllexport)
#else
# define CMakeTest_EXPORT __declspec(dllimport)
#endif
#else
// unix needs nothing
#define CMakeTest_EXPORT
#endif
CMakeTest_EXPORT int sharedFunction();

View File

@ -0,0 +1,11 @@
SET (ZERO_VAR 0)
IF(ZERO_VAR)
ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED)
ELSE(ZERO_VAR)
ADD_DEFINITIONS(-DSHOULD_BE_DEFINED)
ENDIF(ZERO_VAR)
SET(ONE_VAR 1)
SET(STRING_VAR "CMake is great" CACHE STRING "test a cache variable")

View File

@ -0,0 +1,5 @@
#cmakedefine ONE_VAR
#cmakedefine ZERO_VAR
#define STRING_VAR "${STRING_VAR}"

View File

@ -0,0 +1,4 @@
int main ()
{
return 0;
}

View File

@ -0,0 +1,26 @@
# a simple test case
PROJECT (Complex)
ADD_DEFINITIONS(-DCMAKE_IS_FUN)
SUBDIRS(Library Executable)
SUBDIR_DEPENDS(Executable Library)
INCLUDE(${Complex_SOURCE_DIR}/VarTests.txt)
CONFIGURE_FILE(
${Complex_SOURCE_DIR}/cmTestConfigure.h.in
${Complex_BINARY_DIR}/cmTestConfigure.h)
INCLUDE_DIRECTORIES(
${Complex_BINARY_DIR}
${Complex_SOURCE_DIR}/Library
${Complex_SOURCE_DIR}/../../Source
)
LINK_DIRECTORIES(
${Complex_BINARY_DIR}/Library
)
INCLUDE_REGULAR_EXPRESSION("^(cmTest|file|sharedFile).*$")
SET (LIBRARY_OUTPUT_PATH ${Complex_BINARY_DIR}/bin/ CACHE PATH "Single output directory for building all libraries.")
SET (EXECUTABLE_OUTPUT_PATH ${Complex_BINARY_DIR}/bin/ CACHE PATH "Single output directory for building all executables.")

View File

@ -0,0 +1,4 @@
ADD_EXECUTABLE(complex complex)
TARGET_LINK_LIBRARIES(complex CMakeTestLibrary)
TARGET_LINK_LIBRARIES(complex CMakeTestLibraryShared)

View File

@ -0,0 +1,104 @@
#include "cmTestConfigure.h"
#include "ExtraSources/file1.h"
#include "file2.h"
#include "sharedFile.h"
#include "cmStandardIncludes.h"
int passed = 0;
int failed = 0;
void Failed(const char* Message, const char* m2= "")
{
std::cerr << "Failed: " << Message << m2 << "\n";
failed++;
}
void Passed(const char* Message, const char* m2="")
{
std::cout << "Passed: " << Message << m2 << "\n";
passed++;
}
main()
{
if(sharedFunction() != 1)
{
Failed("Call to sharedFunction from shared library failed.");
}
else
{
Passed("Call to sharedFunction from shared library worked.");
}
if(file1() != 1)
{
Failed("Call to file1 function from library failed.");
}
else
{
Passed("Call to file1 function returned 1.");
}
if(file2() != 1)
{
Failed("Call to file2 function from library failed.");
}
else
{
Passed("Call to file2 function returned 1.");
}
#ifndef CMAKE_IS_FUN
Failed("CMake is not fun, so it is broken and should be fixed.");
#else
Passed("CMAKE_IS_FUN is defined.");
#endif
#ifdef SHOULD_NOT_BE_DEFINED
Failed("IF or SET is broken, SHOULD_NOT_BE_DEFINED is defined.");
#else
Passed("SHOULD_NOT_BE_DEFINED is not defined.");
#endif
#ifndef SHOULD_BE_DEFINED
Failed("IF or SET is broken, SHOULD_BE_DEFINED is not defined.\n");
#else
Passed("SHOULD_BE_DEFINED is defined.");
#endif
#ifndef ONE_VAR
Failed("cmakedefine is broken, ONE_VAR is not defined.");
#else
Passed("ONE_VAR is defined.");
#endif
#ifdef ZERO_VAR
Failed("cmakedefine is broken, ZERO_VAR is defined.");
#else
Passed("ZERO_VAR is not defined.");
#endif
#ifndef STRING_VAR
Failed("configureFile is broken, STRING_VAR is not defined.");
#else
if(strcmp(STRING_VAR, "CMake is great") != 0)
{
Failed("CMake is not great, so the SET command,"
"or the configurefile comand is broken. STRING_VAR== ",
STRING_VAR);
}
else
{
Passed("STRING_VAR == ", STRING_VAR);
}
#endif
std::cout << "Passed:" << passed << "\n";
if(failed)
{
std::cout << "Failed: " << failed << "\n";
return failed;
}
return 0;
}

View File

@ -0,0 +1,8 @@
AUX_SOURCE_DIRECTORY(ExtraSources LibrarySources)
SOURCE_FILES(LibrarySources file2)
ADD_LIBRARY(CMakeTestLibrary LibrarySources)
SOURCE_FILES(SharedLibrarySources sharedFile)
ADD_LIBRARY(CMakeTestLibraryShared SHARED SharedLibrarySources)

View File

@ -0,0 +1,4 @@
int file1()
{
return 1;
}

View File

@ -0,0 +1 @@
int file1();

View File

@ -0,0 +1,4 @@
int file2()
{
return 1;
}

View File

@ -0,0 +1 @@
int file2();

View File

@ -0,0 +1,6 @@
#include "sharedFile.h"
int sharedFunction()
{
return 1;
}

View File

@ -0,0 +1,12 @@
#if defined(_WIN32) || defined(WIN32) /* Win32 version */
#ifdef CMakeTestLibraryShared_EXPORTS
# define CMakeTest_EXPORT __declspec(dllexport)
#else
# define CMakeTest_EXPORT __declspec(dllimport)
#endif
#else
// unix needs nothing
#define CMakeTest_EXPORT
#endif
CMakeTest_EXPORT int sharedFunction();

View File

@ -0,0 +1,11 @@
SET (ZERO_VAR 0)
IF(ZERO_VAR)
ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED)
ELSE(ZERO_VAR)
ADD_DEFINITIONS(-DSHOULD_BE_DEFINED)
ENDIF(ZERO_VAR)
SET(ONE_VAR 1)
SET(STRING_VAR "CMake is great" CACHE STRING "test a cache variable")

View File

@ -0,0 +1,5 @@
#cmakedefine ONE_VAR
#cmakedefine ZERO_VAR
#define STRING_VAR "${STRING_VAR}"

View File

@ -0,0 +1,4 @@
int main ()
{
return 0;
}