From 404c3de037a437d3f550c2207b7d7247553fad2d Mon Sep 17 00:00:00 2001 From: Daniel Hannon <12559951+notdanhan@users.noreply.github.com> Date: Tue, 15 Oct 2024 14:12:32 +0000 Subject: [PATCH 1/8] Rename method arguments to avoid collision with linux UAPI macro --- include/boost/test/impl/test_tree.ipp | 8 ++++---- include/boost/test/tree/auto_registration.hpp | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/boost/test/impl/test_tree.ipp b/include/boost/test/impl/test_tree.ipp index f17a63567a..9654718402 100644 --- a/include/boost/test/impl/test_tree.ipp +++ b/include/boost/test/impl/test_tree.ipp @@ -501,16 +501,16 @@ auto_test_unit_registrar::auto_test_unit_registrar( const_string ts_name, const_ //____________________________________________________________________________// -auto_test_unit_registrar::auto_test_unit_registrar( test_unit_generator const& tc_gen, decorator::collector_t& decorators ) +auto_test_unit_registrar::auto_test_unit_registrar( test_unit_generator const& tc_generator, decorator::collector_t& decorators ) { - framework::current_auto_test_suite().add( tc_gen, decorators ); + framework::current_auto_test_suite().add( tc_generator, decorators ); } //____________________________________________________________________________// -auto_test_unit_registrar::auto_test_unit_registrar( boost::shared_ptr tc_gen, decorator::collector_t& decorators ) +auto_test_unit_registrar::auto_test_unit_registrar( boost::shared_ptr tc_generator, decorator::collector_t& decorators ) { - framework::current_auto_test_suite().add( tc_gen, decorators ); + framework::current_auto_test_suite().add( tc_generator, decorators ); } diff --git a/include/boost/test/tree/auto_registration.hpp b/include/boost/test/tree/auto_registration.hpp index e9510be292..39f4bc4e27 100644 --- a/include/boost/test/tree/auto_registration.hpp +++ b/include/boost/test/tree/auto_registration.hpp @@ -39,8 +39,8 @@ struct BOOST_TEST_DECL auto_test_unit_registrar { // Constructors auto_test_unit_registrar( test_case* tc, decorator::collector_t& decorators, counter_t exp_fail = 0 ); explicit auto_test_unit_registrar( const_string ts_name, const_string ts_file, std::size_t ts_line, decorator::collector_t& decorators ); - explicit auto_test_unit_registrar( test_unit_generator const& tc_gen, decorator::collector_t& decorators ); - explicit auto_test_unit_registrar( boost::shared_ptr tc_gen, decorator::collector_t& decorators ); + explicit auto_test_unit_registrar( test_unit_generator const& tc_generator, decorator::collector_t& decorators ); + explicit auto_test_unit_registrar( boost::shared_ptr tc_generator, decorator::collector_t& decorators ); explicit auto_test_unit_registrar( int ); }; From 837402a4f31842cca5bfe14aeff6a9dd54d58f9d Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Sat, 7 Dec 2024 19:42:58 +0100 Subject: [PATCH 2/8] Fix node 20 issue on GHA CI --- .github/workflows/ci.yml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c7f779a37d..5fbe4bf7a9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,7 +27,6 @@ env: GIT_FETCH_JOBS: 8 NET_RETRY_COUNT: 5 DEFAULT_BUILD_VARIANT: release - ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true jobs: posix: @@ -262,7 +261,11 @@ jobs: os: macos-14 runs-on: ${{matrix.os}} - container: ${{matrix.container}} + container: + image: ${{matrix.container}} + volumes: + - /node20217:/node20217:rw,rshared + - ${{ startsWith(matrix.container, 'ubuntu:1') && '/node20217:/__e/node20:ro,rshared' || ' ' }} steps: - name: Setup environment @@ -286,9 +289,13 @@ jobs: fi apt-get -o Acquire::Retries=$NET_RETRY_COUNT install -y sudo software-properties-common tzdata wget curl apt-transport-https ca-certificates make build-essential g++ $PYTHON_PACKAGE python3 perl git cmake fi + if [[ "${{matrix.container}}" == "ubuntu:1"* ]]; then + # Node 20 doesn't work with Ubuntu 16/18 glibc: https://github.com/actions/checkout/issues/1590 + curl -sL https://unofficial-builds.nodejs.org/download/release/v20.9.0/node-v20.9.0-linux-x64-glibc-217.tar.xz | tar -xJ --strip-components 1 -C /node20217 + fi fi git config --global pack.threads 0 - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install packages if: matrix.install From 3dcea0918a1282f8253e5f6de85c5bf79488e919 Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Sun, 8 Dec 2024 13:11:21 +0100 Subject: [PATCH 3/8] Use hosted node --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5fbe4bf7a9..0b46bd7316 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -291,7 +291,7 @@ jobs: fi if [[ "${{matrix.container}}" == "ubuntu:1"* ]]; then # Node 20 doesn't work with Ubuntu 16/18 glibc: https://github.com/actions/checkout/issues/1590 - curl -sL https://unofficial-builds.nodejs.org/download/release/v20.9.0/node-v20.9.0-linux-x64-glibc-217.tar.xz | tar -xJ --strip-components 1 -C /node20217 + curl -sL https://archives.boost.io/misc/node/node-v20.9.0-linux-x64-glibc-217.tar.xz | tar -xJ --strip-components 1 -C /node20217 fi fi git config --global pack.threads 0 From 9428a50ca3dad38172f5edcbf0aa60ecbcd0aa01 Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Sun, 8 Dec 2024 14:51:42 +0100 Subject: [PATCH 4/8] Update containers --- .github/workflows/ci.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0b46bd7316..92efb3a048 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -250,9 +250,6 @@ jobs: - libc++-14-dev - libc++abi-14-dev - - toolset: clang - cxxstd: "11,14" - os: macos-12 - toolset: clang cxxstd: "20" os: macos-13 From cc04b75a1b4e20e57b6dbad60a758d61074bb887 Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Wed, 22 Jan 2025 11:41:14 -0500 Subject: [PATCH 5/8] Add additional paths to guarantee BOOST_TEST_PRIxPTR is defined --- include/boost/test/impl/execution_monitor.ipp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/include/boost/test/impl/execution_monitor.ipp b/include/boost/test/impl/execution_monitor.ipp index 848670b80c..7753ed7854 100644 --- a/include/boost/test/impl/execution_monitor.ipp +++ b/include/boost/test/impl/execution_monitor.ipp @@ -207,7 +207,18 @@ namespace { void _set_se_translator( void* ) {} } # ifdef BOOST_TEST_DEFINED_STDC_FORMAT_MACROS # undef __STDC_FORMAT_MACROS # endif -#else +#endif +// If any modern toolchain did not pick up a definition from above it will here +#ifndef BOOST_TEST_PRIxPTR +# ifdef __has_include +# if __has_include() +# include +# define BOOST_TEST_PRIxPTR PRIxPTR +# endif +# endif +#endif +// Last resort +#ifndef BOOST_TEST_PRIxPTR # define BOOST_TEST_PRIxPTR "08lx" #endif From d19ff0b661e94f9f518e30b6303f5596199ef26d Mon Sep 17 00:00:00 2001 From: Sergey Fedorov Date: Mon, 27 Jan 2025 04:22:28 +0800 Subject: [PATCH 6/8] execution_monitor.ipp: follow-up fix for macOS This fixes https://github.com/boostorg/test/issues/436 --- include/boost/test/impl/execution_monitor.ipp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/boost/test/impl/execution_monitor.ipp b/include/boost/test/impl/execution_monitor.ipp index 7753ed7854..8d7500afd2 100644 --- a/include/boost/test/impl/execution_monitor.ipp +++ b/include/boost/test/impl/execution_monitor.ipp @@ -195,8 +195,8 @@ namespace { void _set_se_translator( void* ) {} } #endif #if (!defined(BOOST_MSSTL_VERSION) || (BOOST_MSSTL_VERSION >= 120)) && (!defined(__GLIBC__) || ((__GLIBC__ > 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 2)))) -// glibc 2.2 - 2.17 required __STDC_FORMAT_MACROS to be defined for use of PRIxPTR -# if defined(__GLIBC__) && !((__GLIBC__ > 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 18))) +// glibc 2.2 - 2.17 required __STDC_FORMAT_MACROS to be defined for use of PRIxPTR, as well as some versions of macOS. +# if (defined(__GLIBC__) && !((__GLIBC__ > 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 18)))) || defined(__APPLE__) # ifndef __STDC_FORMAT_MACROS # define __STDC_FORMAT_MACROS 1 # define BOOST_TEST_DEFINED_STDC_FORMAT_MACROS From 27b4cdd397486c0f196e8b1aad8df6c6d619531b Mon Sep 17 00:00:00 2001 From: ibis-hdl <83083329+ibis-hdl@users.noreply.github.com> Date: Sun, 2 Feb 2025 15:48:03 +0100 Subject: [PATCH 7/8] Include in If datasets are used, is also included, as can be seen in the [example]( https://www.boost.org/doc/libs/1_87_0/libs/test/doc/html/boost_test/tests_organization/test_cases/test_case_generation/datasets.html#boost_test.tests_organization.test_cases.test_case_generation.datasets.dataset_interface.example_descr). MSVC and Gcc indirectly have the definition of `std::size_t`, while Clang/LibC++ do not have this and a compiler error occurs. This fix will correct this. --- include/boost/test/data/size.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/include/boost/test/data/size.hpp b/include/boost/test/data/size.hpp index 3e9ba96795..035bb2e56f 100644 --- a/include/boost/test/data/size.hpp +++ b/include/boost/test/data/size.hpp @@ -17,6 +17,7 @@ // STL #include +#include #include From 0327cb46591a52061ef45781f05251e7491be8a1 Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Mon, 3 Feb 2025 13:27:20 +0100 Subject: [PATCH 8/8] Add test for the size_t class Verify the constructor and increment/decrement operators --- include/boost/test/data/size.hpp | 2 +- test/Jamfile.v2 | 1 + test/framework-ts/dataset-size.cpp | 251 +++++++++++++++++++++++++++++ 3 files changed, 253 insertions(+), 1 deletion(-) create mode 100644 test/framework-ts/dataset-size.cpp diff --git a/include/boost/test/data/size.hpp b/include/boost/test/data/size.hpp index 3e9ba96795..daa63ea51a 100644 --- a/include/boost/test/data/size.hpp +++ b/include/boost/test/data/size.hpp @@ -30,7 +30,7 @@ namespace data { // ************** size_t ************** // // ************************************************************************** // -//! Utility for handling the size of a datasets +//! Utility for handling the size of a dataset class size_t { struct dummy { void nonnull() {} }; typedef void (dummy::*safe_bool)(); diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index ddf6ad5ac3..20ae7c7ea9 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -150,6 +150,7 @@ test-suite "framework-ts" [ boost.test-self-test run : framework-ts : decorators-datatestcase-test : : : : : : $(requirements_datasets) ] [ compile-fail framework-ts/master-test-suite-non-copyable-test.cpp ../build//included ] [ boost.test-self-test run : framework-ts : log-count-skipped-test : included : baseline-outputs/log-count-skipped-tests.pattern ] + [ boost.test-self-test run : framework-ts : dataset-size ] # ticket 13371: "Use-after-free with --log_sink=file" # this single check is not enough as we should check for various command line options: we make extensive diff --git a/test/framework-ts/dataset-size.cpp b/test/framework-ts/dataset-size.cpp new file mode 100644 index 0000000000..647ec58494 --- /dev/null +++ b/test/framework-ts/dataset-size.cpp @@ -0,0 +1,251 @@ +// (C) Copyright Alexander Grund 2025. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#define BOOST_TEST_MODULE dataset size class +#include + +#include +#include + +namespace data = boost::unit_test::data; + +BOOST_AUTO_TEST_CASE(test_constructor) +{ + data::size_t sz0; + BOOST_TEST(!sz0.is_inf()); + BOOST_TEST(sz0.value() == 0u); + BOOST_TEST(!sz0); + + data::size_t sz2 = sz0; + BOOST_TEST(!sz2.is_inf()); + BOOST_TEST(sz2.value() == 0u); + BOOST_TEST(!sz2); + + data::size_t sz1(42); + BOOST_TEST(!sz1.is_inf()); + BOOST_TEST(sz1.value() == 42u); + BOOST_TEST(!!sz1); + + data::size_t sz3 = sz1; + BOOST_TEST(!sz3.is_inf()); + BOOST_TEST(sz3.value() == 42u); + BOOST_TEST(!!sz3); + + data::size_t sz4(true); + BOOST_TEST(sz4.is_inf()); + BOOST_TEST(sz4.value() == 0u); + BOOST_TEST(!!sz4); + + data::size_t sz5(false); + BOOST_TEST(sz5.is_inf()); + BOOST_TEST(sz5.value() == 0u); + BOOST_TEST(!!sz5); + + sz2 = sz5; + BOOST_TEST(sz2.is_inf()); + BOOST_TEST(sz2.value() == 0u); + BOOST_TEST(!!sz2); + + sz2 = sz1; + BOOST_TEST(!sz2.is_inf()); + BOOST_TEST(sz2.value() == 42u); + BOOST_TEST(!!sz2); +} + +BOOST_AUTO_TEST_CASE(test_unary_ops) +{ + data::size_t sz(100); + + data::size_t sz2 = ++sz; + BOOST_TEST(!sz.is_inf()); + BOOST_TEST(sz.value() == 101u); + BOOST_TEST(!sz2.is_inf()); + BOOST_TEST(sz2.value() == 101u); + + sz2 = sz++; + BOOST_TEST(!sz.is_inf()); + BOOST_TEST(sz.value() == 102u); + BOOST_TEST(!sz2.is_inf()); + BOOST_TEST(sz2.value() == 101u); + + sz2 = --sz; + BOOST_TEST(!sz.is_inf()); + BOOST_TEST(sz.value() == 101u); + BOOST_TEST(!sz2.is_inf()); + BOOST_TEST(sz2.value() == 101u); + + sz2 = sz--; + BOOST_TEST(!sz.is_inf()); + BOOST_TEST(sz.value() == 100u); + BOOST_TEST(!sz2.is_inf()); + BOOST_TEST(sz2.value() == 101u); + + // Over- and underflow + BOOST_CONSTEXPR_OR_CONST std::size_t maxVal = (std::numeric_limits::max)(); + sz = maxVal; + sz2 = ++sz; + BOOST_TEST(!sz.is_inf()); + BOOST_TEST(sz.value() == 0u); + BOOST_TEST(!sz2.is_inf()); + BOOST_TEST(sz2.value() == 0u); + + sz = maxVal; + sz2 = sz++; + BOOST_TEST(!sz.is_inf()); + BOOST_TEST(sz.value() == 0); + BOOST_TEST(!sz2.is_inf()); + BOOST_TEST(sz2.value() == maxVal); + + sz = 0; + sz2 = --sz; + BOOST_TEST(!sz.is_inf()); + BOOST_TEST(sz.value() == maxVal); + BOOST_TEST(!sz2.is_inf()); + BOOST_TEST(sz2.value() == maxVal); + + sz = 0; + sz2 = sz--; + BOOST_TEST(!sz.is_inf()); + BOOST_TEST(sz.value() == maxVal); + BOOST_TEST(!sz2.is_inf()); + BOOST_TEST(sz2.value() == 0u); + + //____________________________________________________________________________// + sz = data::BOOST_TEST_DS_INFINITE_SIZE; + sz2 = ++sz; + BOOST_TEST(sz.is_inf()); + BOOST_TEST(sz.value() == 0u); + BOOST_TEST(sz2.is_inf()); + BOOST_TEST(sz2.value() == 0u); + + sz2 = sz++; + BOOST_TEST(sz.is_inf()); + BOOST_TEST(sz.value() == 0u); + BOOST_TEST(sz2.is_inf()); + BOOST_TEST(sz2.value() == 0u); + + sz2 = --sz; + BOOST_TEST(sz.is_inf()); + BOOST_TEST(sz.value() == 0u); + BOOST_TEST(sz2.is_inf()); + BOOST_TEST(sz2.value() == 0u); + + sz2 = sz--; + BOOST_TEST(sz.is_inf()); + BOOST_TEST(sz.value() == 0u); + BOOST_TEST(sz2.is_inf()); + BOOST_TEST(sz2.value() == 0u); +} + +BOOST_AUTO_TEST_CASE(test_binary_inc) +{ + data::size_t sz(100); + + sz += 5; + BOOST_TEST(!sz.is_inf()); + BOOST_TEST(sz.value() == 105u); + + sz += data::size_t(5); + BOOST_TEST(!sz.is_inf()); + BOOST_TEST(sz.value() == 110u); + + sz += data::BOOST_TEST_DS_INFINITE_SIZE; + BOOST_TEST(sz.is_inf()); + BOOST_TEST(sz.value() == 0u); + + //____________________________________________________________________________// + sz = data::BOOST_TEST_DS_INFINITE_SIZE; + + sz += 5; + BOOST_TEST(sz.is_inf()); + BOOST_TEST(sz.value() == 0u); + + sz += data::size_t(5); + BOOST_TEST(sz.is_inf()); + BOOST_TEST(sz.value() == 0u); + + sz += data::BOOST_TEST_DS_INFINITE_SIZE; + BOOST_TEST(sz.is_inf()); + BOOST_TEST(sz.value() == 0u); + + //____________________________________________________________________________// + data::size_t sz2(100); + + sz = sz2 + 5; + BOOST_TEST(!sz.is_inf()); + BOOST_TEST(sz.value() == 105u); + + sz = sz2 + data::size_t(5); + BOOST_TEST(!sz.is_inf()); + BOOST_TEST(sz.value() == 105u); + + sz = sz2 + data::BOOST_TEST_DS_INFINITE_SIZE; + BOOST_TEST(sz.is_inf()); + BOOST_TEST(sz.value() == 0u); + + //____________________________________________________________________________// + sz2 = data::BOOST_TEST_DS_INFINITE_SIZE; + + sz = sz2 + 5; + BOOST_TEST(sz.is_inf()); + BOOST_TEST(sz.value() == 0u); + + sz = sz2 + data::size_t(5); + BOOST_TEST(sz.is_inf()); + BOOST_TEST(sz.value() == 0u); + + sz = sz2 + data::BOOST_TEST_DS_INFINITE_SIZE; + BOOST_TEST(sz.is_inf()); + BOOST_TEST(sz.value() == 0u); +} + +BOOST_AUTO_TEST_CASE(test_binary_dec) +{ + data::size_t sz(100); + + sz -= 5; + BOOST_TEST(!sz.is_inf()); + BOOST_TEST(sz.value() == 95u); + + sz -= data::size_t(5); + BOOST_TEST(!sz.is_inf()); + BOOST_TEST(sz.value() == 90u); + + sz -= data::BOOST_TEST_DS_INFINITE_SIZE; + BOOST_TEST(!sz.is_inf()); + BOOST_TEST(sz.value() == 90u); + + //____________________________________________________________________________// + sz = data::BOOST_TEST_DS_INFINITE_SIZE; + + sz -= 5; + BOOST_TEST(sz.is_inf()); + BOOST_TEST(sz.value() == 0u); + + sz -= data::size_t(5); + BOOST_TEST(sz.is_inf()); + BOOST_TEST(sz.value() == 0u); + + sz -= data::BOOST_TEST_DS_INFINITE_SIZE; + BOOST_TEST(sz.is_inf()); + BOOST_TEST(sz.value() == 0u); + + BOOST_CONSTEXPR_OR_CONST std::size_t maxVal = (std::numeric_limits::max)(); + // Underflow is avoided for data::size_t values + sz = 1; + sz -= 5; + BOOST_TEST(!sz.is_inf()); + BOOST_TEST(sz.value() == maxVal - 5u + 2u); + + sz = 1; + sz -= data::size_t(5); + BOOST_TEST(!sz.is_inf()); + BOOST_TEST(sz.value() == 0u); + + sz = 1; + sz -= data::BOOST_TEST_DS_INFINITE_SIZE; + BOOST_TEST(!sz.is_inf()); + BOOST_TEST(sz.value() == 1u); +} \ No newline at end of file