From a9987b1bc7f789f3063c06ed23e1f51024341463 Mon Sep 17 00:00:00 2001 From: Carl Schwan Date: Thu, 21 Jan 2021 19:16:31 +0100 Subject: Move tests --- quotest/CMakeLists.txt | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 quotest/CMakeLists.txt (limited to 'quotest/CMakeLists.txt') diff --git a/quotest/CMakeLists.txt b/quotest/CMakeLists.txt new file mode 100644 index 00000000..4553abb6 --- /dev/null +++ b/quotest/CMakeLists.txt @@ -0,0 +1,9 @@ +# SPDX-FileCopyrightText: 2021 Carl Schwan +# +# SPDX-License-Identifier: BSD-3-Clause + +set(quotest_SRCS quotest.cpp) + +add_executable(quotest ${quotest_SRCS}) +add_test(NAME quotest COMMAND quotest) +target_link_libraries(quotest PRIVATE Qt5::Core Qt5::Test ${PROJECT_NAME}) -- cgit v1.2.3 From 390162a0c707c51590acb27df81e98a85d3b6cf7 Mon Sep 17 00:00:00 2001 From: Carl Schwan Date: Fri, 22 Jan 2021 15:40:52 +0100 Subject: Remove quotest from ctest --- quotest/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) (limited to 'quotest/CMakeLists.txt') diff --git a/quotest/CMakeLists.txt b/quotest/CMakeLists.txt index 4553abb6..d17e8620 100644 --- a/quotest/CMakeLists.txt +++ b/quotest/CMakeLists.txt @@ -5,5 +5,4 @@ set(quotest_SRCS quotest.cpp) add_executable(quotest ${quotest_SRCS}) -add_test(NAME quotest COMMAND quotest) target_link_libraries(quotest PRIVATE Qt5::Core Qt5::Test ${PROJECT_NAME}) -- cgit v1.2.3 From a1b1b96bcd78c6efb0ad3c1ba9c93284497d74a6 Mon Sep 17 00:00:00 2001 From: Alexey Rusakov Date: Mon, 25 Jan 2021 10:38:02 +0100 Subject: CMakeLists.txt: refactor configuration of features - The feature summary is only generated at the end of the configuration. - InstallQuotest feature is defined in quotest/CMakeLists.txt now, and therefore is only available if quotest is getting built (i.e., if BUILD_TESTING is on). - API generation configuration code merged from two places into one. --- CMakeLists.txt | 78 +++++++++++++++++++++++--------------------------- quotest/CMakeLists.txt | 8 ++++++ 2 files changed, 44 insertions(+), 42 deletions(-) (limited to 'quotest/CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index a458c9ff..39b1b03a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,10 +12,6 @@ message(STATUS "Configuring ${PROJECT_NAME} ${PROJECT_VERSION} ==>") include(FeatureSummary) include(CTest) -option(${PROJECT_NAME}_INSTALL_TESTS "install quotest (former qmc-example) application" ON) -add_feature_info(InstallQuotest ${PROJECT_NAME}_INSTALL_TESTS - "the library functional test suite") - # https://github.com/quotient-im/libQuotient/issues/369 option(${PROJECT_NAME}_ENABLE_E2EE "end-to-end encryption (E2EE) support" OFF) add_feature_info(EnableE2EE ${PROJECT_NAME}_ENABLE_E2EE @@ -115,36 +111,6 @@ if (${PROJECT_NAME}_ENABLE_E2EE) endif () endif () -if (GTAD_PATH) - get_filename_component(ABS_GTAD_PATH "${GTAD_PATH}" REALPATH) -endif () -if (MATRIX_DOC_PATH) - get_filename_component(ABS_API_DEF_PATH "${MATRIX_DOC_PATH}/api" REALPATH) -endif () -if (ABS_GTAD_PATH AND ABS_API_DEF_PATH) - message( STATUS "Using GTAD at ${ABS_GTAD_PATH}" ) - message( STATUS "Using API files at ${ABS_API_DEF_PATH}" ) - set(API_GENERATION_ENABLED 1) - if (NOT CLANG_FORMAT) - set(CLANG_FORMAT clang-format) - endif() - get_filename_component(ABS_CLANG_FORMAT "${CLANG_FORMAT}" PROGRAM) - if (ABS_CLANG_FORMAT) - set(API_FORMATTING_ENABLED 1) - message( STATUS "clang-format is at ${ABS_CLANG_FORMAT}") - else () - message( STATUS "${CLANG_FORMAT} is NOT FOUND; API files won't be reformatted") - endif () -endif() -add_feature_info(EnableApiCodeGeneration "${API_GENERATION_ENABLED}" - "build target update-api") -add_feature_info(EnableApiFormatting "${API_FORMATTING_ENABLED}" - "formatting of generated API files with clang-format") - -message(STATUS) -feature_summary(WHAT ENABLED_FEATURES DISABLED_FEATURES - FATAL_ON_MISSING_REQUIRED_PACKAGES) - # Set up source files set(lib_SRCS lib/networkaccessmanager.cpp @@ -192,12 +158,34 @@ set(lib_SRCS lib/jobs/downloadfilejob.cpp ) +# Configure API files generation + set(CSAPI_DIR csapi) set(FULL_CSAPI_DIR lib/${CSAPI_DIR}) set(ASAPI_DEF_DIR application-service/definitions) set(ISAPI_DEF_DIR identity/definitions) -if (MATRIX_DOC_PATH AND GTAD_PATH) +if (GTAD_PATH) + get_filename_component(ABS_GTAD_PATH "${GTAD_PATH}" REALPATH) +endif () +if (MATRIX_DOC_PATH) + get_filename_component(ABS_API_DEF_PATH "${MATRIX_DOC_PATH}/api" REALPATH) +endif () +if (ABS_GTAD_PATH AND ABS_API_DEF_PATH) + message( STATUS "Using GTAD at ${ABS_GTAD_PATH}" ) + message( STATUS "Using API files at ${ABS_API_DEF_PATH}" ) + set(API_GENERATION_ENABLED 1) + if (NOT CLANG_FORMAT) + set(CLANG_FORMAT clang-format) + endif() + get_filename_component(ABS_CLANG_FORMAT "${CLANG_FORMAT}" PROGRAM) + if (ABS_CLANG_FORMAT) + set(API_FORMATTING_ENABLED 1) + message( STATUS "clang-format is at ${ABS_CLANG_FORMAT}") + else () + message( STATUS "${CLANG_FORMAT} is NOT FOUND; API files won't be reformatted") + endif () + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.12.0") # We use globbing with CONFIGURE_DEPENDS to produce two file lists: # one of all API files for clang-format and another of just .cpp @@ -250,6 +238,10 @@ if (MATRIX_DOC_PATH AND GTAD_PATH) endif() endif() endif() +add_feature_info(EnableApiCodeGeneration "${API_GENERATION_ENABLED}" + "build target update-api") +add_feature_info(EnableApiFormatting "${API_FORMATTING_ENABLED}" + "formatting of generated API files with clang-format") # Make no mistake: CMake cannot run gtad first and then populate the list of # resulting api_SRCS files. In other words, placing the below statement after @@ -289,15 +281,17 @@ if (${PROJECT_NAME}_ENABLE_E2EE) endif() target_link_libraries(${PROJECT_NAME} Qt5::Core Qt5::Network Qt5::Gui Qt5::Multimedia) +configure_file(${PROJECT_NAME}.pc.in ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc @ONLY NEWLINE_STYLE UNIX) + +# Configure testing + if (BUILD_TESTING) enable_testing() add_subdirectory(quotest) add_subdirectory(autotests) endif() -configure_file(${PROJECT_NAME}.pc.in ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc @ONLY NEWLINE_STYLE UNIX) - -# Installation +# Configure installation install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}Targets ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} @@ -338,13 +332,13 @@ if (WIN32) install(FILES mime/packages/freedesktop.org.xml DESTINATION mime/packages) endif (WIN32) -if (${PROJECT_NAME}_INSTALL_TESTS) - install(TARGETS ${TEST_BINARY} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) -endif () - if (UNIX AND NOT APPLE) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) endif() +message(STATUS) +feature_summary(WHAT ENABLED_FEATURES DISABLED_FEATURES + FATAL_ON_MISSING_REQUIRED_PACKAGES) + message(STATUS "<== End of libQuotient configuration") diff --git a/quotest/CMakeLists.txt b/quotest/CMakeLists.txt index d17e8620..29c53fae 100644 --- a/quotest/CMakeLists.txt +++ b/quotest/CMakeLists.txt @@ -6,3 +6,11 @@ set(quotest_SRCS quotest.cpp) add_executable(quotest ${quotest_SRCS}) target_link_libraries(quotest PRIVATE Qt5::Core Qt5::Test ${PROJECT_NAME}) + +option(${PROJECT_NAME}_INSTALL_TESTS "install quotest (former qmc-example) application" ON) +add_feature_info(InstallQuotest ${PROJECT_NAME}_INSTALL_TESTS + "the library functional test suite") + +if (${PROJECT_NAME}_INSTALL_TESTS) + install(TARGETS quotest RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) +endif () -- cgit v1.2.3 From dcbb2cfd0e238f788105d7d249f8aac6ad0823e4 Mon Sep 17 00:00:00 2001 From: Alexey Rusakov Date: Fri, 11 Jun 2021 17:46:58 +0200 Subject: CMakeLists: require at least Qt 5.12; add Qt 6 support --- CMakeLists.txt | 23 +++++++++++++++++++---- autotests/CMakeLists.txt | 2 +- quotest/CMakeLists.txt | 2 +- 3 files changed, 21 insertions(+), 6 deletions(-) (limited to 'quotest/CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index 39b1b03a..9b53a53a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -72,9 +72,21 @@ message(STATUS " Header files will be installed to ${CMAKE_INSTALL_PREFIX}/${${ # Instruct CMake to run moc automatically when needed. set(CMAKE_AUTOMOC ON) -find_package(Qt5 5.9 REQUIRED Core Network Gui Multimedia Test) -get_filename_component(Qt5_Prefix "${Qt5_DIR}/../../../.." ABSOLUTE) -message(STATUS "Using Qt ${Qt5_VERSION} at ${Qt5_Prefix}") +option(BUILD_WITH_QT6 "Build Quotient with Qt 6" OFF) + +if (NOT BUILD_WITH_QT6) + # Use Qt5 by default + find_package(Qt5 5.12 QUIET COMPONENTS Core) +endif() +if (NOT Qt5Core_FOUND OR BUILD_WITH_Qt6) + find_package(Qt6 6.2 REQUIRED Core Network Gui Test) # TODO: Multimedia + set(Qt Qt6) +else() + find_package(Qt5 5.12 REQUIRED Core Network Gui Multimedia Test) + set(Qt Qt5) +endif() +get_filename_component($Qt_Prefix "${${Qt}_DIR}/../../../.." ABSOLUTE) +message(STATUS "Using Qt ${${Qt}_VERSION} at ${Qt_Prefix}") if (${PROJECT_NAME}_ENABLE_E2EE) if ((NOT DEFINED USE_INTREE_LIBQOLM OR USE_INTREE_LIBQOLM) @@ -279,7 +291,10 @@ if (${PROJECT_NAME}_ENABLE_E2EE) target_link_libraries(${PROJECT_NAME} QtOlm) set(FIND_DEPS "find_dependency(QtOlm)") # For QuotientConfig.cmake.in endif() -target_link_libraries(${PROJECT_NAME} Qt5::Core Qt5::Network Qt5::Gui Qt5::Multimedia) +target_link_libraries(${PROJECT_NAME} ${Qt}::Core ${Qt}::Network ${Qt}::Gui) +if (Qt STREQUAL Qt5) # Qt 6 hasn't got Multimedia component as yet + target_link_libraries(${PROJECT_NAME} ${Qt}::Multimedia) +endif() configure_file(${PROJECT_NAME}.pc.in ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc @ONLY NEWLINE_STYLE UNIX) diff --git a/autotests/CMakeLists.txt b/autotests/CMakeLists.txt index 07f1f046..282ab036 100644 --- a/autotests/CMakeLists.txt +++ b/autotests/CMakeLists.txt @@ -7,7 +7,7 @@ include(CMakeParseArguments) function(QUOTIENT_ADD_TEST) cmake_parse_arguments(ARG "" "NAME" "" ${ARGN}) add_executable(${ARG_NAME} ${ARG_NAME}.cpp) - target_link_libraries(${ARG_NAME} Qt5::Core Qt5::Test Quotient) + target_link_libraries(${ARG_NAME} ${Qt}::Core ${Qt}::Test Quotient) add_test(NAME ${ARG_NAME} COMMAND ${ARG_NAME}) endfunction() diff --git a/quotest/CMakeLists.txt b/quotest/CMakeLists.txt index 29c53fae..bf9af796 100644 --- a/quotest/CMakeLists.txt +++ b/quotest/CMakeLists.txt @@ -5,7 +5,7 @@ set(quotest_SRCS quotest.cpp) add_executable(quotest ${quotest_SRCS}) -target_link_libraries(quotest PRIVATE Qt5::Core Qt5::Test ${PROJECT_NAME}) +target_link_libraries(quotest PRIVATE ${Qt}::Core ${Qt}::Test ${PROJECT_NAME}) option(${PROJECT_NAME}_INSTALL_TESTS "install quotest (former qmc-example) application" ON) add_feature_info(InstallQuotest ${PROJECT_NAME}_INSTALL_TESTS -- cgit v1.2.3 From 693b5da2920f173a9e3f723b845d35a7b4aa9823 Mon Sep 17 00:00:00 2001 From: Alexey Rusakov Date: Sun, 12 Sep 2021 04:35:43 +0200 Subject: Add a download test to quotest --- quotest/CMakeLists.txt | 3 ++- quotest/quotest.cpp | 37 +++++++++++++++++++++++++++++++------ 2 files changed, 33 insertions(+), 7 deletions(-) (limited to 'quotest/CMakeLists.txt') diff --git a/quotest/CMakeLists.txt b/quotest/CMakeLists.txt index bf9af796..59334e30 100644 --- a/quotest/CMakeLists.txt +++ b/quotest/CMakeLists.txt @@ -4,8 +4,9 @@ set(quotest_SRCS quotest.cpp) +find_package(${Qt} COMPONENTS Concurrent) add_executable(quotest ${quotest_SRCS}) -target_link_libraries(quotest PRIVATE ${Qt}::Core ${Qt}::Test ${PROJECT_NAME}) +target_link_libraries(quotest PRIVATE ${Qt}::Core ${Qt}::Test ${Qt}::Concurrent ${PROJECT_NAME}) option(${PROJECT_NAME}_INSTALL_TESTS "install quotest (former qmc-example) application" ON) add_feature_info(InstallQuotest ${PROJECT_NAME}_INSTALL_TESTS diff --git a/quotest/quotest.cpp b/quotest/quotest.cpp index ec7d4dcb..3f886676 100644 --- a/quotest/quotest.cpp +++ b/quotest/quotest.cpp @@ -5,6 +5,7 @@ #include "room.h" #include "user.h" #include "uriresolver.h" +#include "networkaccessmanager.h" #include "csapi/joining.h" #include "csapi/leaving.h" @@ -20,6 +21,8 @@ #include #include #include +#include +#include #include #include @@ -435,6 +438,27 @@ TEST_IMPL(sendFile) return false; } +bool testDownload(const QUrl& url) +{ + // Move out actual test from the multithreaded code + // to help debugging + auto results = + QtConcurrent::blockingMapped(QVector { 1, 2, 3 }, [url](int) { + QEventLoop el; + auto reply = + NetworkAccessManager::instance()->get(QNetworkRequest(url)); + QObject::connect( + reply, &QNetworkReply::finished, &el, [&el] { el.exit(); }, + Qt::QueuedConnection); + el.exec(); + return reply->error(); + }); + return std::all_of(results.cbegin(), results.cend(), + [](QNetworkReply::NetworkError ne) { + return ne == QNetworkReply::NoError; + }); +} + bool TestSuite::checkFileSendingOutcome(const TestToken& thisTest, const QString& txnId, const QString& fileName) @@ -465,14 +489,15 @@ bool TestSuite::checkFileSendingOutcome(const TestToken& thisTest, return visit( *evt, [&](const RoomMessageEvent& e) { - // TODO: actually try to download it to check, e.g., #366 - // (and #368 would help to test against bad file names). + // TODO: check #366 once #368 is implemented FINISH_TEST( !e.id().isEmpty() - && pendingEvents[size_t(pendingIdx)]->transactionId() - == txnId - && e.hasFileContent() - && e.content()->fileInfo()->originalName == fileName); + && pendingEvents[size_t(pendingIdx)]->transactionId() + == txnId + && e.hasFileContent() + && e.content()->fileInfo()->originalName == fileName + && testDownload(targetRoom->connection()->makeMediaUrl( + e.content()->fileInfo()->url))); }, [this, thisTest](const RoomEvent&) { FAIL_TEST(); }); }); -- cgit v1.2.3 From 7981c654c0cd53f6e100ecae25882246a9de5d6e Mon Sep 17 00:00:00 2001 From: Alexey Rusakov Date: Sun, 5 Dec 2021 21:47:25 +0100 Subject: Drop 'qmc-example' from one last(?) place --- quotest/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'quotest/CMakeLists.txt') diff --git a/quotest/CMakeLists.txt b/quotest/CMakeLists.txt index 59334e30..8d67b6f1 100644 --- a/quotest/CMakeLists.txt +++ b/quotest/CMakeLists.txt @@ -8,7 +8,7 @@ find_package(${Qt} COMPONENTS Concurrent) add_executable(quotest ${quotest_SRCS}) target_link_libraries(quotest PRIVATE ${Qt}::Core ${Qt}::Test ${Qt}::Concurrent ${PROJECT_NAME}) -option(${PROJECT_NAME}_INSTALL_TESTS "install quotest (former qmc-example) application" ON) +option(${PROJECT_NAME}_INSTALL_TESTS "install quotest application" ON) add_feature_info(InstallQuotest ${PROJECT_NAME}_INSTALL_TESTS "the library functional test suite") -- cgit v1.2.3 From 53c494f1b9f273395caade35c93e3fb520d083ec Mon Sep 17 00:00:00 2001 From: Alexey Rusakov Date: Mon, 27 Dec 2021 20:15:47 +0100 Subject: Quotest: add compile warnings from libQuotient --- quotest/CMakeLists.txt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'quotest/CMakeLists.txt') diff --git a/quotest/CMakeLists.txt b/quotest/CMakeLists.txt index 8d67b6f1..cb41141d 100644 --- a/quotest/CMakeLists.txt +++ b/quotest/CMakeLists.txt @@ -8,6 +8,21 @@ find_package(${Qt} COMPONENTS Concurrent) add_executable(quotest ${quotest_SRCS}) target_link_libraries(quotest PRIVATE ${Qt}::Core ${Qt}::Test ${Qt}::Concurrent ${PROJECT_NAME}) +if (MSVC) + target_compile_options(quotest PUBLIC /EHsc /W4 + /wd4100 /wd4127 /wd4242 /wd4244 /wd4245 /wd4267 /wd4365 /wd4456 /wd4459 + /wd4464 /wd4505 /wd4514 /wd4571 /wd4619 /wd4623 /wd4625 /wd4626 /wd4706 + /wd4710 /wd4774 /wd4820 /wd4946 /wd5026 /wd5027) +else() + foreach (FLAG W Wall Wpedantic Wextra Wno-unused-parameter Werror=return-type) + CHECK_CXX_COMPILER_FLAG("-${FLAG}" COMPILER_${FLAG}_SUPPORTED) + if (COMPILER_${FLAG}_SUPPORTED AND + NOT CMAKE_CXX_FLAGS MATCHES "(^| )-?${FLAG}($| )") + target_compile_options(quotest PUBLIC -${FLAG}) + endif () + endforeach () +endif() + option(${PROJECT_NAME}_INSTALL_TESTS "install quotest application" ON) add_feature_info(InstallQuotest ${PROJECT_NAME}_INSTALL_TESTS "the library functional test suite") -- cgit v1.2.3 From 39b50a13a0379ea32be114c85f3c697d75d4e03b Mon Sep 17 00:00:00 2001 From: Alexey Rusakov Date: Wed, 29 Dec 2021 21:22:26 +0100 Subject: Quotest: build with hidden visibility too --- quotest/CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'quotest/CMakeLists.txt') diff --git a/quotest/CMakeLists.txt b/quotest/CMakeLists.txt index cb41141d..ec305620 100644 --- a/quotest/CMakeLists.txt +++ b/quotest/CMakeLists.txt @@ -8,6 +8,11 @@ find_package(${Qt} COMPONENTS Concurrent) add_executable(quotest ${quotest_SRCS}) target_link_libraries(quotest PRIVATE ${Qt}::Core ${Qt}::Test ${Qt}::Concurrent ${PROJECT_NAME}) +set_target_properties(quotest PROPERTIES + VISIBILITY_INLINES_HIDDEN ON + CXX_VISIBILITY_PRESET hidden +) + if (MSVC) target_compile_options(quotest PUBLIC /EHsc /W4 /wd4100 /wd4127 /wd4242 /wd4244 /wd4245 /wd4267 /wd4365 /wd4456 /wd4459 -- cgit v1.2.3