diff options
Diffstat (limited to 'Tests')
28 files changed, 243 insertions, 27 deletions
diff --git a/Tests/CMakeCommands/target_link_libraries/empty.cpp b/Tests/CMakeCommands/target_link_libraries/empty.cpp index ab32cf6..a6ecef8 100644 --- a/Tests/CMakeCommands/target_link_libraries/empty.cpp +++ b/Tests/CMakeCommands/target_link_libraries/empty.cpp @@ -1 +1,3 @@ -// No content +// Solaris needs non-empty content so ensure +// we have at least one symbol +int Solaris_requires_a_symbol_here = 0; diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 2f53cfc9..4b335bd 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1391,6 +1391,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release if(CMake_TEST_FindGTest) add_subdirectory(FindGTest) + add_subdirectory(GoogleTest) endif() if(CMake_TEST_FindICU) @@ -1437,6 +1438,10 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release add_subdirectory(FindPNG) endif() + if(CMake_TEST_FindProtobuf) + add_subdirectory(FindProtobuf) + endif() + if(CMake_TEST_FindTIFF) add_subdirectory(FindTIFF) endif() diff --git a/Tests/ExportImport/Export/testLibNoSONAME.c b/Tests/ExportImport/Export/testLibNoSONAME.c index 30acc83..4d98562 100644 --- a/Tests/ExportImport/Export/testLibNoSONAME.c +++ b/Tests/ExportImport/Export/testLibNoSONAME.c @@ -4,7 +4,7 @@ #define testLibNoSONAME_EXPORT #endif -testLibNoSONAME_EXPORT int testLibNoSONAME(void) +testLibNoSONAME_EXPORT int testLibNoSoName(void) { return 0; } diff --git a/Tests/FindGTest/Test/CMakeLists.txt b/Tests/FindGTest/Test/CMakeLists.txt index 99368ac..b65b9d2 100644 --- a/Tests/FindGTest/Test/CMakeLists.txt +++ b/Tests/FindGTest/Test/CMakeLists.txt @@ -2,9 +2,6 @@ cmake_minimum_required(VERSION 3.1) project(TestFindGTest CXX) include(CTest) -# CMake does not actually provide FindGTest publicly. -set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../Source/Modules) - find_package(GTest REQUIRED) add_executable(test_gtest_tgt main.cxx) diff --git a/Tests/FindProtobuf/CMakeLists.txt b/Tests/FindProtobuf/CMakeLists.txt new file mode 100644 index 0000000..1cdb2ae --- /dev/null +++ b/Tests/FindProtobuf/CMakeLists.txt @@ -0,0 +1,10 @@ +add_test(NAME FindProtobuf.Test COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindProtobuf/Test" + "${CMake_BINARY_DIR}/Tests/FindProtobuf/Test" + ${build_generator_args} + --build-project TestFindProtobuf + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) diff --git a/Tests/FindProtobuf/Test/CMakeLists.txt b/Tests/FindProtobuf/Test/CMakeLists.txt new file mode 100644 index 0000000..d7a5081 --- /dev/null +++ b/Tests/FindProtobuf/Test/CMakeLists.txt @@ -0,0 +1,32 @@ +cmake_minimum_required(VERSION 3.4) +project(TestFindProtobuf CXX) +include(CTest) + +find_package(Protobuf REQUIRED) + +add_executable(test_tgt main.cxx) +target_link_libraries(test_tgt Protobuf::protobuf) +add_test(NAME test_tgt COMMAND test_tgt) + +add_executable(test_var main.cxx) +target_include_directories(test_var PRIVATE ${Protobuf_INCLUDE_DIRS}) +target_link_libraries(test_var PRIVATE ${Protobuf_LIBRARIES}) +add_test(NAME test_var COMMAND test_var) + +add_executable(test_tgt_lite main.cxx) +target_link_libraries(test_tgt_lite Protobuf::protobuf-lite) +add_test(NAME test_tgt_lite COMMAND test_tgt_lite) + +add_executable(test_var_lite main.cxx) +target_include_directories(test_var_lite PRIVATE ${Protobuf_INCLUDE_DIRS}) +target_link_libraries(test_var_lite PRIVATE ${Protobuf_LITE_LIBRARIES}) +add_test(NAME test_var_lite COMMAND test_var_lite) + +add_executable(test_tgt_protoc main-protoc.cxx) +target_link_libraries(test_tgt_protoc Protobuf::protoc) +add_test(NAME test_tgt_protoc COMMAND test_tgt_protoc) + +add_executable(test_var_protoc main-protoc.cxx) +target_include_directories(test_var_protoc PRIVATE ${Protobuf_INCLUDE_DIRS}) +target_link_libraries(test_var_protoc PRIVATE ${Protobuf_PROTOC_LIBRARIES}) +add_test(NAME test_var_protoc COMMAND test_var_protoc) diff --git a/Tests/FindProtobuf/Test/main-protoc.cxx b/Tests/FindProtobuf/Test/main-protoc.cxx new file mode 100644 index 0000000..64e5ada --- /dev/null +++ b/Tests/FindProtobuf/Test/main-protoc.cxx @@ -0,0 +1,8 @@ +#include <google/protobuf/compiler/command_line_interface.h> + +int main() +{ + google::protobuf::compiler::CommandLineInterface(); + + return 0; +} diff --git a/Tests/FindProtobuf/Test/main.cxx b/Tests/FindProtobuf/Test/main.cxx new file mode 100644 index 0000000..87d5c12 --- /dev/null +++ b/Tests/FindProtobuf/Test/main.cxx @@ -0,0 +1,8 @@ +#include <google/protobuf/stubs/common.h> + +int main() +{ + GOOGLE_PROTOBUF_VERIFY_VERSION; + + return 0; +} diff --git a/Tests/FindTIFF/Test/CMakeLists.txt b/Tests/FindTIFF/Test/CMakeLists.txt index 6985e3f..85453ed 100644 --- a/Tests/FindTIFF/Test/CMakeLists.txt +++ b/Tests/FindTIFF/Test/CMakeLists.txt @@ -2,9 +2,6 @@ cmake_minimum_required(VERSION 3.1) project(TestFindTIFF C) include(CTest) -# CMake does not actually provide FindTIFF publicly. -set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../Source/Modules) - find_package(TIFF REQUIRED) add_executable(test_tiff_tgt main.c) diff --git a/Tests/FindXalanC/Test/CMakeLists.txt b/Tests/FindXalanC/Test/CMakeLists.txt index b445e0e..a8c2a0a 100644 --- a/Tests/FindXalanC/Test/CMakeLists.txt +++ b/Tests/FindXalanC/Test/CMakeLists.txt @@ -2,9 +2,6 @@ cmake_minimum_required(VERSION 3.1) project(TestFindXalanC CXX) include(CTest) -# CMake does not actually provide FindXalanC publicly. -set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../Source/Modules) - find_package(XalanC REQUIRED) add_executable(test_xalanc_tgt main.cxx) diff --git a/Tests/FindXercesC/Test/CMakeLists.txt b/Tests/FindXercesC/Test/CMakeLists.txt index 8e7767c..267c6a9 100644 --- a/Tests/FindXercesC/Test/CMakeLists.txt +++ b/Tests/FindXercesC/Test/CMakeLists.txt @@ -2,9 +2,6 @@ cmake_minimum_required(VERSION 3.1) project(TestFindXercesC CXX) include(CTest) -# CMake does not actually provide FindXercesC publicly. -set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../Source/Modules) - find_package(XercesC REQUIRED) add_executable(test_xercesc_tgt main.cxx) diff --git a/Tests/GoogleTest/CMakeLists.txt b/Tests/GoogleTest/CMakeLists.txt new file mode 100644 index 0000000..21f8b8b --- /dev/null +++ b/Tests/GoogleTest/CMakeLists.txt @@ -0,0 +1,10 @@ +add_test(NAME GoogleTest.Test COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/GoogleTest/Test" + "${CMake_BINARY_DIR}/Tests/GoogleTest/Test" + ${build_generator_args} + --build-project TestGoogleTest + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) diff --git a/Tests/GoogleTest/Test/CMakeLists.txt b/Tests/GoogleTest/Test/CMakeLists.txt new file mode 100644 index 0000000..a1f08d4 --- /dev/null +++ b/Tests/GoogleTest/Test/CMakeLists.txt @@ -0,0 +1,82 @@ +cmake_minimum_required(VERSION 3.8) +project(TestGoogleTest) +include(CTest) + +include(GoogleTest) + +find_package(GTest REQUIRED) + +add_executable(test_gtest1 main1.cxx) +target_link_libraries(test_gtest1 GTest::GTest) + +# Simple test of defaults +gtest_add_tests(TARGET test_gtest1 + TEST_LIST testList +) +set(expectedTests + GoogleTest.LinksAndRuns + GoogleTest.ConditionalFail +) +if(NOT testList STREQUAL "${expectedTests}") + message(FATAL_ERROR "Expected test list: ${expectedTests} +Actual test list: ${testList}") +endif() + + +# Same target, different arguments, so use test prefix and suffix to +# differentiate from the above test cases +gtest_add_tests(TARGET test_gtest1 + TEST_LIST testList + TEST_PREFIX "set2." + TEST_SUFFIX ".foo" + EXTRA_ARGS --forceFail +) + +set(expectedTests + set2.GoogleTest.LinksAndRuns.foo + set2.GoogleTest.ConditionalFail.foo +) +if(NOT testList STREQUAL "${expectedTests}") + message(FATAL_ERROR "Expected test list: ${expectedTests} +Actual test list: ${testList}") +endif() + +set_tests_properties(set2.GoogleTest.ConditionalFail.foo PROPERTIES WILL_FAIL YES) + + +# Search specific sources to get the test list +add_executable(test_gtest2 main2.cxx) +target_link_libraries(test_gtest2 GTest::Main) +gtest_add_tests(TARGET test_gtest2 + TEST_LIST testList + SOURCES main2.h +) +set(expectedTests + GoogleTest.SomethingElse +) +if(NOT testList STREQUAL "${expectedTests}") + message(FATAL_ERROR "Expected test list: ${expectedTests} +Actual test list: ${testList}") +endif() + + +# Non-keyword form, auto-find sources +add_executable(test_gtest3 main3.cxx) +target_link_libraries(test_gtest3 GTest::Main) +gtest_add_tests(test_gtest3 "" AUTO) +if(NOT TEST GoogleTest.Foo) + message(FATAL_ERROR "Test case GoogleTest.Foo not defined") +endif() +if(NOT TEST GoogleTest.Bar) + message(FATAL_ERROR "Test case GoogleTest.Bar not defined") +endif() + + +# Non-keyword form, explicitly specified sources. Allows a non-target to be +# given for the executable. +add_executable(test_gtest4 main4.cxx) +target_link_libraries(test_gtest4 GTest::Main) +gtest_add_tests($<TARGET_FILE:test_gtest4> "" main4.h) +if(NOT TEST GoogleTest.NoKeywords) + message(FATAL_ERROR "Test case GoogleTest.NoKeywords not defined") +endif() diff --git a/Tests/GoogleTest/Test/main1.cxx b/Tests/GoogleTest/Test/main1.cxx new file mode 100644 index 0000000..03d604b --- /dev/null +++ b/Tests/GoogleTest/Test/main1.cxx @@ -0,0 +1,30 @@ +#include <gtest/gtest.h> + +#include <string> + +namespace { +bool shouldFail = false; +} + +TEST(GoogleTest, LinksAndRuns) +{ + ASSERT_TRUE(true); +} + +TEST(GoogleTest, ConditionalFail) +{ + ASSERT_FALSE(shouldFail); +} + +int main(int argc, char* argv[]) +{ + ::testing::InitGoogleTest(&argc, argv); + + if (argc > 1) { + if (argv[1] != std::string("--forceFail")) { + throw "Unexpected argument"; + } + shouldFail = true; + } + return RUN_ALL_TESTS(); +} diff --git a/Tests/GoogleTest/Test/main2.cxx b/Tests/GoogleTest/Test/main2.cxx new file mode 100644 index 0000000..05ffb4a --- /dev/null +++ b/Tests/GoogleTest/Test/main2.cxx @@ -0,0 +1 @@ +#include "main2.h" diff --git a/Tests/GoogleTest/Test/main2.h b/Tests/GoogleTest/Test/main2.h new file mode 100644 index 0000000..7243f53 --- /dev/null +++ b/Tests/GoogleTest/Test/main2.h @@ -0,0 +1,6 @@ +#include <gtest/gtest.h> + +TEST(GoogleTest, SomethingElse) +{ + ASSERT_TRUE(true); +} diff --git a/Tests/GoogleTest/Test/main3.cxx b/Tests/GoogleTest/Test/main3.cxx new file mode 100644 index 0000000..98ce13c --- /dev/null +++ b/Tests/GoogleTest/Test/main3.cxx @@ -0,0 +1,11 @@ +#include <gtest/gtest.h> + +TEST(GoogleTest, Foo) +{ + ASSERT_TRUE(true); +} + +TEST(GoogleTest, Bar) +{ + ASSERT_TRUE(true); +} diff --git a/Tests/GoogleTest/Test/main4.cxx b/Tests/GoogleTest/Test/main4.cxx new file mode 100644 index 0000000..8023bc1 --- /dev/null +++ b/Tests/GoogleTest/Test/main4.cxx @@ -0,0 +1 @@ +#include "main4.h" diff --git a/Tests/GoogleTest/Test/main4.h b/Tests/GoogleTest/Test/main4.h new file mode 100644 index 0000000..19da12a --- /dev/null +++ b/Tests/GoogleTest/Test/main4.h @@ -0,0 +1,6 @@ +#include <gtest/gtest.h> + +TEST(GoogleTest, NoKeywords) +{ + ASSERT_TRUE(true); +} diff --git a/Tests/RunCMake/CPack/RunCMakeTest.cmake b/Tests/RunCMake/CPack/RunCMakeTest.cmake index 752ce8a..faf151a 100644 --- a/Tests/RunCMake/CPack/RunCMakeTest.cmake +++ b/Tests/RunCMake/CPack/RunCMakeTest.cmake @@ -5,7 +5,7 @@ include("${RunCMake_SOURCE_DIR}/CPackTestHelpers.cmake") # run_cpack_test args: TEST_NAME "GENERATORS" RUN_CMAKE_BUILD_STEP "PACKAGING_TYPES" run_cpack_test(CUSTOM_BINARY_SPEC_FILE "RPM" false "MONOLITHIC;COMPONENT") -run_cpack_test(CUSTOM_NAMES "RPM;DEB" true "COMPONENT") +run_cpack_test(CUSTOM_NAMES "RPM;DEB;TGZ" true "COMPONENT") run_cpack_test(DEBUGINFO "RPM" true "COMPONENT") run_cpack_test(DEPENDENCIES "RPM;DEB" true "COMPONENT") run_cpack_test(DIST "RPM" false "MONOLITHIC") diff --git a/Tests/RunCMake/CPack/tests/CUSTOM_NAMES/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/CUSTOM_NAMES/ExpectedFiles.cmake index ae5f0af..5cb280c 100644 --- a/Tests/RunCMake/CPack/tests/CUSTOM_NAMES/ExpectedFiles.cmake +++ b/Tests/RunCMake/CPack/tests/CUSTOM_NAMES/ExpectedFiles.cmake @@ -9,4 +9,7 @@ set(EXPECTED_FILE_CONTENT_3_LIST "/usr;/usr/foo;/usr/foo/CMakeLists.txt") if(GENERATOR_TYPE STREQUAL "DEB" OR GENERATOR_TYPE STREQUAL "RPM") string(TOLOWER "${GENERATOR_TYPE}" file_extension_) set(EXPECTED_FILE_3 "pkg_3_abc.${file_extension_}") +elseif(GENERATOR_TYPE STREQUAL "TGZ") + set(EXPECTED_FILE_2 "second.tar.gz") + set(EXPECTED_FILE_3 "pkg_3_abc.tar.gz") endif() diff --git a/Tests/RunCMake/CPack/tests/CUSTOM_NAMES/test.cmake b/Tests/RunCMake/CPack/tests/CUSTOM_NAMES/test.cmake index 0c2b37b..4c20e41 100644 --- a/Tests/RunCMake/CPack/tests/CUSTOM_NAMES/test.cmake +++ b/Tests/RunCMake/CPack/tests/CUSTOM_NAMES/test.cmake @@ -7,6 +7,9 @@ if(GENERATOR_TYPE STREQUAL "DEB" OR GENERATOR_TYPE STREQUAL "RPM") set(CPACK_${GENERATOR_TYPE}${generator_type_suffix_}_PKG_2_PACKAGE_NAME "second") string(TOLOWER "${GENERATOR_TYPE}" file_extension_) set(CPACK_${GENERATOR_TYPE}${generator_type_suffix_}_PKG_3_FILE_NAME "pkg_3_abc.${file_extension_}") +elseif(GENERATOR_TYPE STREQUAL "TGZ") + set(CPACK_ARCHIVE_PKG_2_FILE_NAME "second") + set(CPACK_ARCHIVE_PKG_3_FILE_NAME "pkg_3_abc") endif() install(FILES CMakeLists.txt DESTINATION foo COMPONENT pkg_1) diff --git a/Tests/SourceGroups/CMakeLists.txt b/Tests/SourceGroups/CMakeLists.txt index 9289e84..4e4a030 100644 --- a/Tests/SourceGroups/CMakeLists.txt +++ b/Tests/SourceGroups/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.6) +cmake_minimum_required (VERSION 3.8) project(SourceGroups) # this is not really a test which can fail @@ -33,10 +33,11 @@ source_group(EmptyGroup) set(root ${CMAKE_CURRENT_SOURCE_DIR}) set(tree_files_without_prefix ${root}/sub1/tree_bar.c - ${root}/sub1/tree_baz.c - ${root}/sub1/tree_subdir/tree_foobar.c) + sub1/tree_baz.c + sub1/../sub1/tree_subdir/tree_foobar.c) -set(tree_files_with_prefix ${root}/tree_foo.c) +set(tree_files_with_prefix ${root}/tree_prefix_foo.c + tree_prefix_bar.c) source_group(TREE ${root} FILES ${tree_files_without_prefix}) diff --git a/Tests/SourceGroups/main.c b/Tests/SourceGroups/main.c index b88f2f8..4d84cf2 100644 --- a/Tests/SourceGroups/main.c +++ b/Tests/SourceGroups/main.c @@ -5,7 +5,8 @@ extern int bar(void); extern int foobar(void); extern int barbar(void); extern int baz(void); -extern int tree_foo(void); +extern int tree_prefix_foo(void); +extern int tree_prefix_bar(void); extern int tree_bar(void); extern int tree_foobar(void); extern int tree_baz(void); @@ -15,7 +16,9 @@ int main() printf("foo: %d bar: %d foobar: %d barbar: %d baz: %d\n", foo(), bar(), foobar(), barbar(), baz()); - printf("tree_foo: %d tree_bar: %d tree_foobar: %d tree_baz: %d\n", - tree_foo(), tree_bar(), tree_foobar(), tree_baz()); + printf("tree_prefix_foo: %d tree_prefix_bar: %d tree_bar: %d tree_foobar: " + "%d tree_baz: %d\n", + tree_prefix_foo(), tree_prefix_bar(), tree_bar(), tree_foobar(), + tree_baz()); return 0; } diff --git a/Tests/SourceGroups/tree_foo.c b/Tests/SourceGroups/tree_foo.c deleted file mode 100644 index d392e41..0000000 --- a/Tests/SourceGroups/tree_foo.c +++ /dev/null @@ -1,4 +0,0 @@ -int tree_foo(void) -{ - return 6; -} diff --git a/Tests/SourceGroups/tree_prefix_bar.c b/Tests/SourceGroups/tree_prefix_bar.c new file mode 100644 index 0000000..bd98476 --- /dev/null +++ b/Tests/SourceGroups/tree_prefix_bar.c @@ -0,0 +1,4 @@ +int tree_prefix_bar(void) +{ + return 66; +} diff --git a/Tests/SourceGroups/tree_prefix_foo.c b/Tests/SourceGroups/tree_prefix_foo.c new file mode 100644 index 0000000..92c2fd7 --- /dev/null +++ b/Tests/SourceGroups/tree_prefix_foo.c @@ -0,0 +1,4 @@ +int tree_prefix_foo(void) +{ + return 6; +} diff --git a/Tests/Wrapping/fakefluid.cxx b/Tests/Wrapping/fakefluid.cxx index 02c0c52..a118bbd 100644 --- a/Tests/Wrapping/fakefluid.cxx +++ b/Tests/Wrapping/fakefluid.cxx @@ -6,7 +6,9 @@ int main(int ac, char** av) if (strcmp(av[i], "-o") == 0 || strcmp(av[i], "-h") == 0) { fprintf(stdout, "fakefluid is creating file \"%s\"\n", av[i + 1]); FILE* file = fopen(av[i + 1], "w"); - fprintf(file, "// hello\n"); + fprintf(file, "// Solaris needs non-empty content so ensure\n" + "// we have at least one symbol\n" + "int Solaris_requires_a_symbol_here = 0;\n"); fclose(file); } } |