diff options
author | DongHun Kwak <dh0128.kwak@samsung.com> | 2021-10-08 09:13:10 +0900 |
---|---|---|
committer | DongHun Kwak <dh0128.kwak@samsung.com> | 2021-10-08 09:13:10 +0900 |
commit | 5b13f2e6aa1ca2f812f53a40b11ff1f80277f897 (patch) | |
tree | 50b33fee97f68ab5dc1cf3a34ffba0519b043697 /Tests | |
parent | 488e9638b71b8b9cdb3055835815d77720eae06b (diff) | |
download | cmake-5b13f2e6aa1ca2f812f53a40b11ff1f80277f897.tar.gz cmake-5b13f2e6aa1ca2f812f53a40b11ff1f80277f897.tar.bz2 cmake-5b13f2e6aa1ca2f812f53a40b11ff1f80277f897.zip |
Imported Upstream version 3.10.1upstream/3.10.1
Diffstat (limited to 'Tests')
17 files changed, 257 insertions, 3 deletions
diff --git a/Tests/QtAutogen/CMakeLists.txt b/Tests/QtAutogen/CMakeLists.txt index 32c2950cb..dff9d0c66 100644 --- a/Tests/QtAutogen/CMakeLists.txt +++ b/Tests/QtAutogen/CMakeLists.txt @@ -215,6 +215,12 @@ add_subdirectory(uicInclude) add_subdirectory(objectLibrary) # -- Test +# MacOS Framework +if(APPLE AND (NOT QT_TEST_VERSION STREQUAL 4)) + add_subdirectory(macosFW) +endif() + +# -- Test # Source files with the same basename in different subdirectories add_subdirectory(sameName) diff --git a/Tests/QtAutogen/macosFW/CMakeLists.txt b/Tests/QtAutogen/macosFW/CMakeLists.txt new file mode 100644 index 000000000..114d9bac0 --- /dev/null +++ b/Tests/QtAutogen/macosFW/CMakeLists.txt @@ -0,0 +1,20 @@ +cmake_minimum_required(VERSION 3.8) +project(macos-fw-test) + +find_package(Qt5Test REQUIRED) + +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/output/bin) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/output/lib) +set(CMAKE_INSTALL_NAME_DIR ${CMAKE_BINARY_DIR}/output/lib) + +if(POLICY CMP0042) # in CMake 3.0.0+ + set (CMAKE_MACOSX_RPATH OFF) # otherwise ON by default +endif(POLICY CMP0042) + +if(POLICY CMP0068) # in CMake 3.9+ + cmake_policy(SET CMP0068 NEW) +endif(POLICY CMP0068) + +add_subdirectory(src) +add_subdirectory(test) diff --git a/Tests/QtAutogen/macosFW/src/CMakeLists.txt b/Tests/QtAutogen/macosFW/src/CMakeLists.txt new file mode 100644 index 000000000..a02be00c5 --- /dev/null +++ b/Tests/QtAutogen/macosFW/src/CMakeLists.txt @@ -0,0 +1,33 @@ +set(MACOS_FW_LIB_VERSION "0.1") +set(MACOS_FW_LIB_SRCS + macos_fw_lib.cpp +) +set(MACOS_FW_LIB_HDRS + macos_fw_lib.h +) + +include_directories( + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR} + ${Qt5Core_INCLUDE_DIRS} +) + +add_library(macos_fw_lib SHARED + ${MACOS_FW_LIB_SRCS} + ${MACOS_FW_LIB_HDRS} +) +set_target_properties(macos_fw_lib PROPERTIES AUTOMOC TRUE) +set_target_properties(macos_fw_lib PROPERTIES + CLEAN_DIRECT_OUTPUT 1 + FRAMEWORK 1 + FRAMEWORK_VERSION ${MACOS_FW_LIB_VERSION} + VERSION ${MACOS_FW_LIB_VERSION} + SOVERSION ${MACOS_FW_LIB_VERSION} + MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${MACOS_FW_LIB_VERSION} + MACOSX_FRAMEWORK_IDENTIFIER org.macos.fw_lib + POSITION_INDEPENDENT_CODE ON + PUBLIC_HEADER "${MACOS_FW_LIB_HDRS}" +) +target_link_libraries(macos_fw_lib + Qt5::Core +) diff --git a/Tests/QtAutogen/macosFW/src/macos_fw_lib.cpp b/Tests/QtAutogen/macosFW/src/macos_fw_lib.cpp new file mode 100644 index 000000000..881a8c9b6 --- /dev/null +++ b/Tests/QtAutogen/macosFW/src/macos_fw_lib.cpp @@ -0,0 +1,17 @@ +#include "macos_fw_lib.h" + +#include <QString> +#include <QtGlobal> + +MacosFWLib::MacosFWLib() +{ +} + +MacosFWLib::~MacosFWLib() +{ +} + +QString MacosFWLib::qtVersionString() const +{ + return QString(qVersion()); +} diff --git a/Tests/QtAutogen/macosFW/src/macos_fw_lib.h b/Tests/QtAutogen/macosFW/src/macos_fw_lib.h new file mode 100644 index 000000000..e66e0ea6c --- /dev/null +++ b/Tests/QtAutogen/macosFW/src/macos_fw_lib.h @@ -0,0 +1,18 @@ +#ifndef MACOSFWLIB_H +#define MACOSFWLIB_H + +#include <QObject> +#include <QString> + +class __attribute__((visibility("default"))) MacosFWLib : public QObject +{ + Q_OBJECT + +public: + explicit MacosFWLib(); + ~MacosFWLib(); + + QString qtVersionString() const; +}; + +#endif // MACOSFWLIB_H diff --git a/Tests/QtAutogen/macosFW/test/CMakeLists.txt b/Tests/QtAutogen/macosFW/test/CMakeLists.txt new file mode 100644 index 000000000..521c18450 --- /dev/null +++ b/Tests/QtAutogen/macosFW/test/CMakeLists.txt @@ -0,0 +1,19 @@ +include_directories( + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/../src +) +include_directories(SYSTEM + ${Qt5Core_INCLUDE_DIRS} + ${Qt5Widgets_INCLUDE_DIRS} +) + +set(testname AutomocMacosFWLib) +add_executable(${testname} testMacosFWLib.cpp) +set_target_properties(${testname} PROPERTIES AUTOMOC TRUE) +target_link_libraries(${testname} + Qt5::Core + Qt5::Widgets + Qt5::Test + macos_fw_lib +) diff --git a/Tests/QtAutogen/macosFW/test/testMacosFWLib.cpp b/Tests/QtAutogen/macosFW/test/testMacosFWLib.cpp new file mode 100644 index 000000000..3476d6176 --- /dev/null +++ b/Tests/QtAutogen/macosFW/test/testMacosFWLib.cpp @@ -0,0 +1,42 @@ +#include <QObject> +#include <QString> + +#include "macos_fw_lib.h" +#include "testMacosFWLib.h" + +class TestMacosFWLib : public QObject +{ + Q_OBJECT + +private slots: + void initTestCase(); + void cleanupTestCase(); + void init() {} + void cleanup() {} + + void testQtVersion(); +}; + +void TestMacosFWLib::initTestCase() +{ +} + +void TestMacosFWLib::cleanupTestCase() +{ +} + +void TestMacosFWLib::testQtVersion() +{ + MacosFWLib* testLib = new MacosFWLib(); + QVERIFY(testLib->qtVersionString().contains("5.")); + testLib->deleteLater(); +} + +int main(int argc, char* argv[]) +{ + QApplication app(argc, argv, false); + MacosFWLib testObject; + return QTest::qExec(&testObject, argc, argv); +} + +#include "testMacosFWLib.moc" diff --git a/Tests/QtAutogen/macosFW/test/testMacosFWLib.h b/Tests/QtAutogen/macosFW/test/testMacosFWLib.h new file mode 100644 index 000000000..1fe8dae65 --- /dev/null +++ b/Tests/QtAutogen/macosFW/test/testMacosFWLib.h @@ -0,0 +1,7 @@ +#ifndef TESTMACOSFWLIB_H +#define TESTMACOSFWLIB_H + +#include "qapplication.h" +#include <QtTest/QtTest> + +#endif // TESTMACOSFWLIB_H diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-test-missing-result.txt b/Tests/RunCMake/GoogleTest/GoogleTest-test-missing-result.txt new file mode 100644 index 000000000..d197c913c --- /dev/null +++ b/Tests/RunCMake/GoogleTest/GoogleTest-test-missing-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-test-missing-stderr.txt b/Tests/RunCMake/GoogleTest/GoogleTest-test-missing-stderr.txt new file mode 100644 index 000000000..55a4a7aa4 --- /dev/null +++ b/Tests/RunCMake/GoogleTest/GoogleTest-test-missing-stderr.txt @@ -0,0 +1,2 @@ +Unable to find executable: timeout_test_NOT_BUILT +Errors while running CTest diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-test-stdout.txt b/Tests/RunCMake/GoogleTest/GoogleTest-test1-stdout.txt index 5f7753dba..5f7753dba 100644 --- a/Tests/RunCMake/GoogleTest/GoogleTest-test-stdout.txt +++ b/Tests/RunCMake/GoogleTest/GoogleTest-test1-stdout.txt diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-test2-stdout.txt b/Tests/RunCMake/GoogleTest/GoogleTest-test2-stdout.txt new file mode 100644 index 000000000..960c0b9cf --- /dev/null +++ b/Tests/RunCMake/GoogleTest/GoogleTest-test2-stdout.txt @@ -0,0 +1,25 @@ +Test project .* + Start 9: TEST:basic\.case_foo!2 +1/8 Test #9: TEST:basic\.case_foo!2 \.+ +Passed +[0-9.]+ sec + Start 10: TEST:basic\.case_bar!2 +2/8 Test #10: TEST:basic\.case_bar!2 \.+ +Passed +[0-9.]+ sec + Start 11: TEST:basic\.disabled_case!2 +3/8 Test #11: TEST:basic\.disabled_case!2 \.+\*+Not Run \(Disabled\) +[0-9.]+ sec + Start 12: TEST:disabled\.case!2 +4/8 Test #12: TEST:disabled\.case!2 \.+\*+Not Run \(Disabled\) +[0-9.]+ sec + Start 13: TEST:typed/short\.case!2 +5/8 Test #13: TEST:typed/short\.case!2 \.+ +Passed +[0-9.]+ sec + Start 14: TEST:typed/float\.case!2 +6/8 Test #14: TEST:typed/float\.case!2 \.+ +Passed +[0-9.]+ sec + Start 15: TEST:value/test\.case/1!2 +7/8 Test #15: TEST:value/test\.case/1!2 \.+ +Passed +[0-9.]+ sec + Start 16: TEST:value/test\.case/"foo"!2 +8/8 Test #16: TEST:value/test\.case/"foo"!2 \.+ +Passed +[0-9.]+ sec + +100% tests passed, 0 tests failed out of 6 + +Total Test time \(real\) = +[0-9.]+ sec + +The following tests did not run: +.*11 - TEST:basic\.disabled_case!2 \(Disabled\) +.*12 - TEST:disabled\.case!2 \(Disabled\) diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-timeout-result.txt b/Tests/RunCMake/GoogleTest/GoogleTest-timeout-result.txt new file mode 100644 index 000000000..d197c913c --- /dev/null +++ b/Tests/RunCMake/GoogleTest/GoogleTest-timeout-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-timeout-stdout.txt b/Tests/RunCMake/GoogleTest/GoogleTest-timeout-stdout.txt new file mode 100644 index 000000000..8464c8034 --- /dev/null +++ b/Tests/RunCMake/GoogleTest/GoogleTest-timeout-stdout.txt @@ -0,0 +1,7 @@ +( *|[0-9]+>)CMake Error at .*GoogleTestAddTests.cmake:[0-9]+ \(message\): +( *|[0-9]+>) Error running test executable. +?( *|[0-9]+>) +( *|[0-9]+>) Path: '.*timeout_test(\.exe)?' +( *|[0-9]+>) Result: Process terminated due to timeout +( *|[0-9]+>) Output: +( *|[0-9]+>) + diff --git a/Tests/RunCMake/GoogleTest/GoogleTest.cmake b/Tests/RunCMake/GoogleTest/GoogleTest.cmake index 9a3677fae..5e4b8ef06 100644 --- a/Tests/RunCMake/GoogleTest/GoogleTest.cmake +++ b/Tests/RunCMake/GoogleTest/GoogleTest.cmake @@ -11,5 +11,19 @@ gtest_discover_tests( TEST_PREFIX TEST: TEST_SUFFIX !1 EXTRA_ARGS how now "\"brown\" cow" - PROPERTIES LABELS TEST + PROPERTIES LABELS TEST1 +) + +gtest_discover_tests( + fake_gtest + TEST_PREFIX TEST: + TEST_SUFFIX !2 + EXTRA_ARGS how now "\"brown\" cow" + PROPERTIES LABELS TEST2 +) + +add_executable(timeout_test timeout_test.cpp) + +gtest_discover_tests( + timeout_test ) diff --git a/Tests/RunCMake/GoogleTest/RunCMakeTest.cmake b/Tests/RunCMake/GoogleTest/RunCMakeTest.cmake index aec8568d0..73014d143 100644 --- a/Tests/RunCMake/GoogleTest/RunCMakeTest.cmake +++ b/Tests/RunCMake/GoogleTest/RunCMakeTest.cmake @@ -9,16 +9,43 @@ function(run_GoogleTest) endif() file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + run_cmake(GoogleTest) + run_cmake_command(GoogleTest-build ${CMAKE_COMMAND} --build . --config Debug + --target fake_gtest + ) + + set(RunCMake_TEST_OUTPUT_MERGE 1) + run_cmake_command(GoogleTest-timeout + ${CMAKE_COMMAND} + --build . + --config Debug + --target timeout_test + ) + set(RunCMake_TEST_OUTPUT_MERGE 0) + + run_cmake_command(GoogleTest-test1 + ${CMAKE_CTEST_COMMAND} + -C Debug + -L TEST1 + --no-label-summary ) - run_cmake_command(GoogleTest-test + + run_cmake_command(GoogleTest-test2 + ${CMAKE_CTEST_COMMAND} + -C Debug + -L TEST2 + --no-label-summary + ) + + run_cmake_command(GoogleTest-test-missing ${CMAKE_CTEST_COMMAND} -C Debug - -L TEST + -R timeout --no-label-summary ) endfunction() diff --git a/Tests/RunCMake/GoogleTest/timeout_test.cpp b/Tests/RunCMake/GoogleTest/timeout_test.cpp new file mode 100644 index 000000000..a8e5c1ce4 --- /dev/null +++ b/Tests/RunCMake/GoogleTest/timeout_test.cpp @@ -0,0 +1,15 @@ +#if defined(_WIN32) +#include <windows.h> +#else +#include <unistd.h> +#endif + +int main() +{ +#if defined(_WIN32) + Sleep(10000); +#else + sleep(10); +#endif + return 0; +} |