From 6a611288d3671c24f5aa403ece0edfd55d7da468 Mon Sep 17 00:00:00 2001 From: Andrey Saranchin Date: Tue, 1 Apr 2025 17:09:16 +0300 Subject: [PATCH 1/5] ci: replace ubuntu-20.04 workflows with newer ones GitHub Actions has deprecated `ubuntu-20.04`, its jobs are getting canceled often and it is going to be completely removed in a few weeks, so let's replace it with the newer `ubuntu-24.04` version. --- .github/workflows/testing.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index d67566278..fbbe11654 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -14,8 +14,8 @@ jobs: fail-fast: false matrix: runs-on: - - ubuntu-20.04 - ubuntu-22.04 + - ubuntu-24.04 - macos-13 - macos-14 - macos-15 @@ -35,8 +35,8 @@ jobs: fail-fast: false matrix: runs-on: - - ubuntu-20.04 - ubuntu-22.04 + - ubuntu-24.04 - macos-13 - macos-14 - macos-15 From daa8a408cf6a3bf94f4b14755c60f72621367bbb Mon Sep 17 00:00:00 2001 From: Andrey Saranchin Date: Tue, 1 Apr 2025 10:17:20 +0300 Subject: [PATCH 2/5] ci: fix build on runners with CMake 4.0 Lately, CMake 4.0 was released, and some GitHub Actions runners started to use it. CMake 4.0 does not support versions older than 3.5 anymore, and we fetch MsgPuck library for the tests that requires 2.8 minimum version. Let's override minimum required version with CMake option in order to generate build files of MsgPuck successfully. --- .github/actions/build-tntcxx/action.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/actions/build-tntcxx/action.yml b/.github/actions/build-tntcxx/action.yml index 369324d18..dba8f8cef 100644 --- a/.github/actions/build-tntcxx/action.yml +++ b/.github/actions/build-tntcxx/action.yml @@ -29,6 +29,7 @@ runs: -DTNTCXX_ENABLE_SANITIZERS=${{ inputs.enable-sanitizers }} \ -DCMAKE_CXX_STANDARD=${{ inputs.cxx-standard }} \ -DCMAKE_C_COMPILER=${{ inputs.c-compiler }} \ - -DCMAKE_CXX_COMPILER=${{ inputs.cxx-compiler }} + -DCMAKE_CXX_COMPILER=${{ inputs.cxx-compiler }} \ + -DCMAKE_POLICY_VERSION_MINIMUM=3.5 make -j shell: bash From c98fd676bd95063849cbc464549bc87a6b34b22d Mon Sep 17 00:00:00 2001 From: Andrey Saranchin Date: Tue, 1 Apr 2025 17:58:42 +0300 Subject: [PATCH 3/5] test: ignore self-move warning in buffer unit test The new warning forbids to move an objects to itself - in our case, it's the purpose of the case, so let's ignore the warning there. The problem failed build on `ubuntu-24.04` GitHub Actions runner. --- test/BufferUnitTest.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/test/BufferUnitTest.cpp b/test/BufferUnitTest.cpp index 9a63c72da..b3edafbf9 100644 --- a/test/BufferUnitTest.cpp +++ b/test/BufferUnitTest.cpp @@ -613,6 +613,24 @@ auto itr_at(BUF &buf, size_t pos) return itr; } +/** A helper to move buffer to itself - disables warning on GCC compiler. */ +template +static inline void +buffer_move_to_self(BUF &buf) +{ +/* Self-move warning was introduced in GCC 13. */ +#if __GNUC__ >= 13 +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wself-move" +#endif + + buf = std::move(buf); + +#if __GNUC__ >= 13 +#pragma GCC diagnostic pop +#endif +} + /** * Test move constructor and assignment. */ @@ -626,7 +644,7 @@ buffer_move() tnt::Buffer buf1; fillBuffer(buf1, S); /* It is ok to move to itself. */ - buf1 = std::move(buf1); + buffer_move_to_self(buf1); /* Create three iterators pointing to different parts. */ auto itr0 = buf1.begin(); @@ -655,7 +673,7 @@ buffer_move() fail_unless(!buf1.has(buf1.begin(), S + ins_cnt + 1)); /* It is ok to move to itself. */ - buf1 = std::move(buf1); + buffer_move_to_self(buf1); fail_unless(itr0 == buf1.begin()); fail_unless(itr1 == itr_at(buf1, 1 + ins_cnt)); fail_unless(itr2 == itr_at(buf1, S / 2 + ins_cnt)); From 24ab6c6d230fbc7bd304c88263b2f9a51c50aa4b Mon Sep 17 00:00:00 2001 From: Andrey Saranchin Date: Tue, 1 Apr 2025 18:56:34 +0300 Subject: [PATCH 4/5] test: get rid of VLAs in buffer test Some compilers produce a warning when variable-length arrays are used, so using them in buffer test failed CI on `ubuntu-24.04` GitHub Actions runner. We don't use VLAs across the connector, so let's simply get rid of them in the buffer test - mark variables used for their sizes as `constexpr`. --- src/Buffer/Buffer.hpp | 2 +- test/BufferUnitTest.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Buffer/Buffer.hpp b/src/Buffer/Buffer.hpp index 459af3335..68f405578 100644 --- a/src/Buffer/Buffer.hpp +++ b/src/Buffer/Buffer.hpp @@ -1362,7 +1362,7 @@ std::string dump(Buffer &buffer) { size_t vec_len = 0; - size_t IOVEC_MAX = 1024; + constexpr size_t IOVEC_MAX = 1024; size_t block_cnt = 0; struct iovec vec[IOVEC_MAX]; std::string output; diff --git a/test/BufferUnitTest.cpp b/test/BufferUnitTest.cpp index b3edafbf9..acf678d0c 100644 --- a/test/BufferUnitTest.cpp +++ b/test/BufferUnitTest.cpp @@ -71,7 +71,7 @@ template static void eraseBuffer(tnt::Buffer &buffer) { - int IOVEC_MAX = 1024; + constexpr int IOVEC_MAX = 1024; struct iovec vec[IOVEC_MAX]; do { size_t vec_size = buffer.getIOV(buffer.begin(), vec, IOVEC_MAX); @@ -89,7 +89,7 @@ static void dumpBuffer(tnt::Buffer &buffer, std::string &output) { size_t vec_len = 0; - int IOVEC_MAX = 1024; + constexpr int IOVEC_MAX = 1024; size_t block_cnt = 0; struct iovec vec[IOVEC_MAX]; for (auto itr = buffer.begin(); itr != buffer.end(); itr += vec_len) { @@ -575,7 +575,7 @@ buffer_out() fail_if(buf.debugSelfCheck()); save.unlink(); do { - int IOVEC_MAX = 1024; + constexpr int IOVEC_MAX = 1024; struct iovec vec[IOVEC_MAX]; size_t vec_size = buf.getIOV(buf.begin(), vec, IOVEC_MAX); buf.dropFront(vec_size); @@ -592,7 +592,7 @@ buffer_iterator_get() { TEST_INIT(1, N); tnt::Buffer buf; - size_t DATA_SIZE = SAMPLES_CNT * 10; + constexpr size_t DATA_SIZE = SAMPLES_CNT * 10; fillBuffer(buf, DATA_SIZE); buf.write(end_marker); fail_if(buf.debugSelfCheck()); From b50f17a73ffd9d8c220dde99cd2c256d6210fe1f Mon Sep 17 00:00:00 2001 From: Andrey Saranchin Date: Tue, 1 Apr 2025 16:57:29 +0300 Subject: [PATCH 5/5] client: use universal reference in data decoder Our MsgPack decoder allows to pass rvalue reference - it is needed to use tags like `mpp::as_raw` or handy `std::forward_as_tuple` helper. However, we accept only lvalues in the data decoder, hence, client cannot use those features of MsgPack decoder. Let's accept universal reference instead to accept both lvalues and rvalues in client data decoder - do not forget to use `std::forward` for perfect passing. Closes #106 --- src/Client/ResponseReader.hpp | 4 ++-- test/ClientTest.cpp | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/Client/ResponseReader.hpp b/src/Client/ResponseReader.hpp index 8b213c9af..3cac8dc8d 100644 --- a/src/Client/ResponseReader.hpp +++ b/src/Client/ResponseReader.hpp @@ -102,10 +102,10 @@ struct Data { /** Unpacks tuples to passed container. */ template - bool decode(T& tuples) + bool decode(T&& tuples) { it_t itr = iters.first; - bool ok = mpp::decode(itr, tuples); + bool ok = mpp::decode(itr, std::forward(tuples)); assert(!ok || itr == iters.second); return ok; } diff --git a/test/ClientTest.cpp b/test/ClientTest.cpp index 0fdde8c29..16adbafa0 100644 --- a/test/ClientTest.cpp +++ b/test/ClientTest.cpp @@ -1125,6 +1125,17 @@ response_decoding(Connector &client) fail_if(response->body.data->decode(arr_of_str)); /* We should successfully decode data after all. */ fail_unless(response->body.data->decode(arr_of_num)); + fail_unless(std::get<0>(arr_of_num) == 666); + + TEST_CASE("decode data to rvalue object"); + num = 0; + fail_unless(response->body.data->decode(std::forward_as_tuple(num))); + fail_unless(num == 666); + + TEST_CASE("decode data to object with an mpp tag"); + std::get<0>(arr_of_num) = 0; + fail_unless(response->body.data->decode(mpp::as_arr(arr_of_num))); + fail_unless(std::get<0>(arr_of_num) == 666); client.close(conn); }