Commit Graph

74 Commits

Author SHA1 Message Date
Ahmad Samir 0861fb612a Mark the whole repo with QT_NO_URL_CAST_FROM_STRING
Pick-to: 6.11
Change-Id: Ic4457f2151822e7bf2d6e4463b15f2835f860cbd
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-12-10 16:47:34 +02:00
Ivan Solovev f310b4a5a2 QCoapReply: add test for a chunked read
QCoapReply is a QIODevice, but it was not obvious if readData() is
implemented properly, or if it also needed to update pos().

This patch adds a unit test that checks a chunked read from the reply.
The test passes, so nothing needs to be fixed in the implementation.

Pick-to: 6.10 6.9 6.8 6.5
Change-Id: I0642718f21a31cf978a733bc3bc742ad1eb47b3a
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-07-30 09:32:54 +02:00
Marc Mutz 0ea08d303c Normalize signal/slot signatures 2025
This is the result of running util/normalize on the code base. The
following manual edits were needed:

(none)

Pick-to: 6.10 6.9 6.8 6.5
Change-Id: Ia18b3968bc164a8dce5e7cca7653c759646cc4da
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2025-06-04 15:00:33 +02:00
Lucie Gérard 135b399351 Correct license for tools files
According to QUIP-18 [1], all tools file should be
LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

[1]: https://contribute.qt-project.org/quips/18

Pick-to: 6.7
Task-number: QTBUG-121787
Change-Id: If7b3daf5cc2be069ab205bf10cdf653ab9d6c415
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
2024-04-04 16:08:16 +01:00
Joerg Bornemann 60ac2d0628 Enable CMake autotests
Task-number: QTBUG-84884
Change-Id: I653746159c57d78db45a1a0b8a059ffed355fa4b
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
2024-01-25 09:30:55 +01:00
Ivan Solovev 6ffcaefbe1 Update tests and docker scripts to reflect the provisioning updates
The californium docker container is updated, and now provides a
different binary to run.

This patch adjusts the tests and docker script:
* update the docker script to call the proper binary
* update the number of resources exposed by the californium server
* update the expected returned tokens to be uppercase

Task-number: QTBUG-114798
Pick-to: 6.6 6.5
Change-Id: I733793cc472769e433144a08b8f02f0120f6f29b
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Dimitrios Apostolou <jimis@qt.io>
Reviewed-by: Sona Kurazyan <kurazyan.sona@gmail.com>
2023-07-25 12:16:31 +02:00
Alexandru Croitor 1bea3e0d88 CMake: Make qtcoap tests standalone projects
Add the boilerplate standalone test prelude to each test, so that they
can be opened with an IDE without the qt-cmake-standalone-test script,
but directly with qt-cmake or cmake.

Boilerplate was added using the following scripts:
https://git.qt.io/alcroito/cmake_refactor

Manual adjustments were made where the code was inserted in the wrong
location.

Task-number: QTBUG-93020
Change-Id: Idc25fe2da6e4d6dbefa9fc669401e127beec2ae4
Reviewed-by: Amir Masoud Abdol <amir.abdol@qt.io>
2023-07-12 18:23:38 +02:00
Friedemann Kleint 2db1f76335 Remove remains of qmake conversion from CMakeLists.txt files
Pick-to: 6.5
Change-Id: I50610fc5d680151b0092adb128f8a604125792d5
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2023-02-10 08:45:31 +01:00
Amir Masoud Abdol fff5acdcf5 Fix the broken test after the retirement of qt_parse_all_arguments
As we are now processing the arguments with
cmake_parse_arguments(PARSE_ARGV, we don't need to pass the escape
characters anymore.

Task-number: QTBUG-99238
Change-Id: Iba8f0321838aa41b9b34e0a9766ada89b2a5c38b
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-01-21 11:51:08 +01:00
Marc Mutz bfb3a3e2e7 Port from container::count() and length() to size() - V4
This is a semantic patch using ClangTidyTransformator as in
qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8, but extended to
handle typedefs and accesses through pointers, too:

    const std::string o = "object";

    auto hasTypeIgnoringPointer = [](auto type) { return anyOf(hasType(type), hasType(pointsTo(type))); };

    auto derivedFromAnyOfClasses = [&](ArrayRef<StringRef> classes) {
        auto exprOfDeclaredType = [&](auto decl) {
            return expr(hasTypeIgnoringPointer(hasUnqualifiedDesugaredType(recordType(hasDeclaration(decl))))).bind(o);
        };
        return exprOfDeclaredType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes))));
    };

    auto renameMethod = [&] (ArrayRef<StringRef> classes,
                            StringRef from, StringRef to) {
        return makeRule(cxxMemberCallExpr(on(derivedFromAnyOfClasses(classes)),
                            callee(cxxMethodDecl(hasName(from), parameterCountIs(0)))),
                        changeTo(cat(access(o, cat(to)), "()")),
                        cat("use '", to, "' instead of '", from, "'"));
    };

    renameMethod(<classes>, "count", "size");
    renameMethod(<classes>, "length", "size");

a.k.a qt-port-to-std-compatible-api V4 with config Scope: 'Container'.

Change-Id: I58e1b41b91c34d2e860dbb5847b3752edbfc6fc9
Reviewed-by: Sona Kurazyan <kurazyan.sona@gmail.com>
2022-10-09 19:23:09 +02:00
Marc Mutz a01b9dfc24 Port from qAsConst() to std::as_const()
We've been requiring C++17 since Qt 6.0, and our qAsConst use finally
starts to bother us (QTBUG-99313), so time to port away from it
now.

Since qAsConst has exactly the same semantics as std::as_const (down
to rvalue treatment, constexpr'ness and noexcept'ness), there's really
nothing more to it than a global search-and-replace.

Task-number: QTBUG-99313
Change-Id: I0483bd72018332f9a1d7c60537228ea6c85f7029
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2022-10-06 17:43:41 +02:00
Marc Mutz be8150867f Port from container::count() and length() to size()
This is a semantic patch using ClangTidyTransformator as in
qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8:

  auto QtContainerClass = anyOf(
      expr(hasType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes))))).bind(o),
      expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o));
  makeRule(cxxMemberCallExpr(on(QtContainerClass),
                             callee(cxxMethodDecl(hasAnyName({"count", "length"),
                                                  parameterCountIs(0))))),
           changeTo(cat(access(o, cat("size"), "()"))),
           cat("use 'size()' instead of 'count()/length()'"))

a.k.a qt-port-to-std-compatible-api with config Scope: 'Container',
with the extended set of container classes recognized.

Change-Id: I227e49052f5f1a2a8abfc719112facb5c805d463
Reviewed-by: Sona Kurazyan <kurazyan.sona@gmail.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-10-06 17:43:37 +02:00
Lucie Gérard 96b4684826 Change the license of all CMakeLists.txt and *.cmake files to BSD
Task-number: QTBUG-105718
Change-Id: I9f2589d36e91c60df09242b1262cc660bde7537a
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-08-23 20:52:15 +02:00
Alexandru Croitor 82193fc9b1 CMake: Don't use PUBLIC_LIBRARIES for tests and test helpers
Change-Id: I917bc9e3b0761b2d27b6e0a2c3648a5bc1be1d73
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-07-27 13:09:35 +02:00
Lucie Gérard f3f41251da Add license headers to cmake files
CMakeLists.txt and .cmake files of significant size
(more than 2 lines according to our check in tst_license.pl)
now have the copyright and license header.

Existing copyright statements remain intact

Task-number: QTBUG-88621
Change-Id: I53217bc6cf8a044937785533ec42ce22d6720a49
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-07-07 17:38:56 +02:00
Lucie Gérard 283f4b3373 Use SPDX license identifiers
Replace the current license disclaimer in files by
a SPDX-License-Identifier.
License files are organized under LICENSES directory.

Pick-to: 6.4
Task-number: QTBUG-67283
Change-Id: I2f390c365ce2d50aa79d317eafd63be19e530c1e
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-06-15 11:29:34 +02:00
Edward Welbourne 8d64ca2aaa Fix various signed/unsigned comparison warnings
Change-Id: Iffbbcc451fe69e4846467679bb9f407ab87d3b30
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2021-10-04 12:45:26 +02:00
Alexandru Croitor 66f9a9c76d CMake: Bump almost all cmake_minimum_required calls to 3.16
Needed for subsequent change that will check and error out if the
version is lower than 3.16. We do that to ensure all policies
introduced by CMake up to version 3.16 have their behavior set to
NEW.

Pick-to: 6.2
Task-number: QTBUG-95018
Change-Id: Ibafb41a5c8f27305b6e5cb29a6543d0779e0dcf2
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2021-09-22 19:52:03 +02:00
Tor Arne Vestbø 0157fa221c Replace uses of deprecated QWARN macro with qWarning
Pick-to: 6.2
Change-Id: Ice1675db4bf1f074122a0438fdcf129bba2c65f9
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-08-03 10:05:02 +00:00
Sona Kurazyan e40563354f Remove the trailing token from empty acknowledgment packets
When sending Acknowledgment packets with code 0.00, the message should
be empty (RFC-7252 section 12.1). An empty message should have no token
(token length is 0), and no bytes should appear after the message ID
(RFC-7252 section 4.1, section 3). Since Reset packets have the same
structure (only the packet type differs), unified the packet creation
for both cases in one method.

Fixes: QTBUG-94763
Pick-to: 6.2 6.1 5.15
Change-Id: If2619ad6f4f5dba500e04ab10dbbbf08e4887aef
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-06-30 16:55:22 +02:00
Joerg Bornemann ca7557335b CMake: Disable usage of CMake API compatibility wrappers
Setting the QT_NO_INTERNAL_COMPATIBILITY_FUNCTIONS variable
in the project ensures we ported away from old API calls.

Task-number: QTBUG-86815
Change-Id: I034cce0921b65bf635c1d16a408bbd7141efe4a0
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-05-25 15:33:49 +02:00
Joerg Bornemann ae01eb0421 Remove left-over .pri files
Task-number: QTBUG-88742
Change-Id: I87fc754cdec77a5187d1e68f8235c7efd8c4a4af
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-05-05 10:43:59 +02:00
Joerg Bornemann 3ed6e42653 Remove qmake project files
Task-number: QTBUG-88742
Change-Id: I250bae28b177999c821c8aeec6b25c8885c2364a
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2021-04-30 17:27:43 +02:00
Sona Kurazyan 1eb23cdd2a Enable docker-based testserver in QtCoap tests
Change-Id: Ie5cc074dc7897997b33d174b0ddaed2495141ca4
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2021-01-11 15:39:54 +01:00
Sona Kurazyan 2b3abacd15 Fix QCoapOption's copy assignment operator to work on moved-from this
Also added tests verifying copy and assignment operations.

Pick-to: 6.0
Change-Id: I56a995dc7e2029c2ce1761f0a0e42f43eeec5c60
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2020-12-11 15:13:34 +01:00
Sona Kurazyan 5598329329 Fix the build with the latest dev and update dependencies
The build failing after d7ccd8cb4565c8643b158891c9de3187c1586dc9 and
update dependencies.yaml.

Fixes: QTBUG-85896
Change-Id: I52e4dfea4edf0b96de3387f36168bbd18b1cf097
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2020-08-05 14:33:51 +02:00
Sona Kurazyan a0ab76a6f5 Use QList instead of QVector in qtcoap
And fix dependencies.

Task-number: QTBUG-84469
Change-Id: Ic68bcf0229b516a04ba3d9e515dfb992e12d1f49
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2020-06-24 23:39:38 +02:00
Alexandru Croitor b184a38800 CMake: Regenerate projects to be up-to-date
Change-Id: Ice26152fc6a05cbde99a9dbc981427a79e222fc6
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2020-06-12 12:49:49 +02:00
Alexandru Croitor 18c140612f Merge remote-tracking branch 'origin/wip/cmake' into dev
Change-Id: If53446f41c6576857fff305e587e8c9cc95b6656
2020-06-12 12:04:33 +02:00
Sona Kurazyan 12d9af1cd1 Fix a failing test and do some cleanups
The tst_QCoapClient::socketError was failing because it was using the
old signal connection syntax and as a result a non-existing signal. Fixed
the connection syntax in other places as well.

Additionally fixed a few unrelated warnings.

Change-Id: Ie8ab95551d945d3991debfc628497515894d539e
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2020-06-10 15:11:55 +00:00
Sona Kurazyan 3fdd85ec48 Do not overwrite the payload of a QCoapRequest
When sending POST and PUT requests via overloads taking QCoapRequest and
QByteArray data, the payload of the request will be overwritten by an empty
byte array, if no data has been passed when calling post()/put(). Do
not overwrite the payload of a QCoapRequest, if the data parameter is
empty.

Pick-to: 5.15
Change-Id: Iffa40b00ce841a5cebb09dcf59ea22a2a5f9df50
Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2020-06-02 15:35:07 +02:00
Sona Kurazyan 02dbe3346c Fix deprecation warnings
Change-Id: Ifdb8562274e0c3609e2ea35e475820d8e74a91fb
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-03-09 11:13:13 +01:00
Sona Kurazyan 1125b3bf00 Update tags for docker images to use "latest" tag
With e4f9ac5607a329bae045567a339d36469bc4fff6 we can now use the
"latest" tag instead of hard-coding the SHA for docker images.

Change-Id: I2cde7a03194fbbd4d2059898ec4394889d5fd3db
Reviewed-by: Dimitrios Apostolou <jimis@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2020-01-06 08:35:48 +00:00
Alexandru Croitor 38c3591bad Regenerate projects
Change-Id: Ic302041025304b0fbfe9630c9459396b0447d548
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-11-15 12:22:48 +00:00
Sona Kurazyan a7bfc7ebb3 Fix flaky test cases
Some tests cases are randomly failing because of the following issues:

- In tst_QCoapClient::removeReply test 'reply' is scheduled for deletion
  before calling exec, which causes it to be deleted while the request
  is still executing. Schedule it for deletion in the QCoapReply::finished
  slot.

- The timeout used in tst_QCoapClient::setMinimumTokenSize sometimes is
  not sufficient, increase it.

Fixes: QTBUG-79113
Change-Id: I151380fa4982d8c654550cf64108ab31d9b6f6b2
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2019-10-11 08:46:18 +00:00
Sona Kurazyan f7970f339f Add initial support for CMake
Task-number: QTBUG-78308
Change-Id: Id740d70f7682259066323d2ca68e8d285b8309cd
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-19 15:36:44 +00:00
Sona Kurazyan b109844c50 Remove unnecessary core-private lib includes
Change-Id: Icbb520a9fdab0adf2a0e7e8f7e3ff29b642f9aa2
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-09-17 14:16:18 +02:00
Sona Kurazyan f8e3dfedba Improve the security tests
This is a follow-up on the initial commit of the security tests.
Includes the following changes:

- Fixed the non-secure tests to run when security is not set up.

- Renamed QCoapClientForSecurityTests::securityMissing() to
  securitySetupMissing() and added some comments to clarify its
  purpose.

See 13d450eff7 for more details.

Change-Id: If9fec1fcf7a1bdb9b20883ad37bf1286c53c1f45
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2019-07-19 13:56:07 +02:00
Sona Kurazyan 13d450eff7 Add security tests
Change-Id: I2e227977f1b8d407b4c9b069d2a18043cef844c2
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2019-07-17 12:27:28 +02:00
Sona Kurazyan 8f06cb0674 Remove the blacklists for CoAP tests
The blacklists were introduced to make the tests pass on linux
systems where docker is not available. With the current solution
the tests requiring a CoAP server will be skipped if the CoAP
server is not setup. So the blacklists are not needed anymore.

Change-Id: I0bb16bc3905a47699e8d019917917b08ac3eb3d4
Reviewed-by: Ryan Chu <ryan.chu@qt.io>
2019-07-09 13:44:10 +02:00
Sona Kurazyan f8c6d66502 Use docker-based CoAP test servers for tests
- Added docker compose files for setting up CoAP test servers.

 - Enabled the disabled tests which require a californium-based CoAP
   server. These tests are enabled only on linux, since docker-based
   testing doesn't work in CI for other platforms. Note, that they
   are blacklisted for some linux platforms for the same reason.

Change-Id: Id99f9f67fb2874576524e6452250be5506bdbdf4
Reviewed-by: Ryan Chu <ryan.chu@qt.io>
2019-07-09 10:23:38 +02:00
Sona Kurazyan 9272983e46 Remove deprecated QLatin1Literal
Change-Id: If2376d7d38689001bc93ebd962507b21a05a09f9
Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
2019-06-14 17:03:51 +02:00
Sona Kurazyan ca1a8d80f1 Fix warnings
- qcoapprotocol.cpp:387: implicit conversion changes signedness: 'int' to 'uint' (aka 'unsigned int')
- tst_qcoapclient.cpp:365: implicit conversion loses integer precision: 'int' to 'quint16' (aka 'unsigned short')
- tst_qcoapclient.cpp:502: implicit conversion changes signedness: 'int' to 'uint' (aka 'unsigned int')
- tst_qcoapclient.cpp:504: implicit conversion changes signedness: 'int' to 'uint' (aka 'unsigned int')

Change-Id: I5bec42fc69925f04641285c6473d9ddc3ba6ec56
Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
2019-06-14 11:10:28 +02:00
Sona Kurazyan 577ee1cc42 Add block option tests
Change-Id: I8f18562fd543f087bd9d5f4c1d9b3bce7146025e
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2019-05-21 15:03:50 +02:00
Sona Kurazyan 0c00be007c Fix a typo: setMinumumTokenSize -> setMinimumTokenSize
Change-Id: Ifcef69e73ea89f30499063452920dd9abb446f7e
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-05-24 16:15:17 +02:00
Sona Kurazyan 430a041c2c Add a method for setting the minimum token size
For security reasons it is recommended to use tokens with a length of
at least 4 bytes. Added a method for setting the minimum token size and
changed it to be 4 by default.

Change-Id: Ib589b338df8e59ccaf24dceab6691f92d92f861c
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2019-05-22 16:10:39 +02:00
Sona Kurazyan d2744ade32 Remove QCoapClien's constructor for specifying a custom connection
Change-Id: I5b51c71ab11cbce5755a69c58f34bfa5e7cd5385
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-05-23 15:39:27 +02:00
Sona Kurazyan fd94d8e567 Conditionally enable subprojects for the private class tests
Instead of using #ifdefs for the private class tests, conditionally
enable/disable subprojects for them.

Change-Id: I574dc34dd895a4fc2eeb311dfb91a149a6715e28
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-05-14 15:16:22 +00:00
Sona Kurazyan 86b77d2da8 Use maximum/minimum instead of max/min
This change is based on the feedback from API review.

Change-Id: Ia17d061c60fcf7aa4da38542d96d75ae621f657a
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-05-14 15:16:09 +00:00
Sona Kurazyan 273f3fa6ce Improve the API of QCoapOption
- The RFC specifies the following option formats: empty, opaque, uint
   and string. Leave only the construcors for the specified types.
 - Rename value getters to reflect the expected value type.
 - Move the internally used setter methods to the private class.

This change is based on the feedback from API review.

Change-Id: I0b482770b9c02e64b0f345384ebf58ec29a7e9bc
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-05-14 15:15:56 +00:00