From ed783a8ccccc8673c0f55eb1780c08668880a745 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Tue, 24 Nov 2020 16:43:52 +0000 Subject: [PATCH 01/19] clang.yml hack for testing --- .github/workflows/clang.yml | 62 +------------------------------------ 1 file changed, 1 insertion(+), 61 deletions(-) diff --git a/.github/workflows/clang.yml b/.github/workflows/clang.yml index 35b012c1..ea88089a 100644 --- a/.github/workflows/clang.yml +++ b/.github/workflows/clang.yml @@ -1,50 +1,11 @@ name: clang on: push: - branches: [ master ] + branches: [ hotfix/clang-ci-unit-test-crash ] pull_request: branches: [ master ] jobs: - build-clang-9-linux: - name: Clang-9 Linux - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-20.04] - - steps: - - uses: actions/checkout@v2 - - - name: Build - run: | - export CC=clang-9 - export CXX=clang++-9 - cmake -D BUILD_TESTS=ON ./ - clang --version - make - - - name: Run tests - run: ./test/etl_tests - - build-clang-9-linux-no-stl: - name: Clang-9 Linux - No STL - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-20.04] - - steps: - - uses: actions/checkout@v2 - - - name: Build - run: | - cmake -DBUILD_TESTS=ON -DNO_STL=ON ./ - gcc --version - make - - - name: Run tests - run: ./test/etl_tests build-clang-10-osx: name: Clang-10 OSX @@ -66,24 +27,3 @@ jobs: - name: Run tests run: ./test/etl_tests - - build-clang-10-osx-no-stl: - name: Clang-10 OSX - No STL - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [macos-10.15] - - steps: - - uses: actions/checkout@v2 - - - name: Build - run: | - export CC=clang - export CXX=clang++ - cmake -D BUILD_TESTS=ON -DNO_STL=ON ./ - clang --version - make - - - name: Run tests - run: ./test/etl_tests From e97d8f90d5527349324ea84fd578c1d879d7a5a4 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Tue, 24 Nov 2020 16:48:52 +0000 Subject: [PATCH 02/19] Refactor buffer_descriptors test --- test/test_buffer_descriptors.cpp | 570 +++++++++++++++---------------- 1 file changed, 285 insertions(+), 285 deletions(-) diff --git a/test/test_buffer_descriptors.cpp b/test/test_buffer_descriptors.cpp index 8f568309..c8fc65b7 100644 --- a/test/test_buffer_descriptors.cpp +++ b/test/test_buffer_descriptors.cpp @@ -41,7 +41,7 @@ SOFTWARE. #include "etl/buffer_descriptors.h" #if defined(ETL_TARGET_OS_WINDOWS) - #include +#include #endif #define REALTIME_TEST 0 @@ -49,8 +49,8 @@ SOFTWARE. namespace { constexpr size_t BUFFER_SIZE = 16U; - constexpr size_t N_BUFFERS = 4U; - constexpr size_t DATA_COUNT = BUFFER_SIZE / 2; + constexpr size_t N_BUFFERS = 4U; + constexpr size_t DATA_COUNT = BUFFER_SIZE / 2; using BD = etl::buffer_descriptors; @@ -62,13 +62,13 @@ namespace void receive(BD::notification n) { pbuffer = n.get_descriptor().data(); - count = n.get_count(); + count = n.get_count(); } void clear() { pbuffer = nullptr; - count = 0U; + count = 0U; } BD::pointer pbuffer; @@ -79,49 +79,49 @@ namespace SUITE(test_buffer_descriptors) { - //************************************************************************* - TEST(test_constructor_plus_buffer) - { - BD bd(&buffers[0][0]); + ////************************************************************************* + //TEST(test_constructor_plus_buffer) + //{ + // BD bd(&buffers[0][0]); - CHECK_EQUAL(N_BUFFERS, bd.N_BUFFERS); - CHECK_EQUAL(BUFFER_SIZE, bd.BUFFER_SIZE); - CHECK(!bd.is_valid()); - } + // CHECK_EQUAL(N_BUFFERS, bd.N_BUFFERS); + // CHECK_EQUAL(BUFFER_SIZE, bd.BUFFER_SIZE); + // CHECK(!bd.is_valid()); + //} - //************************************************************************* - TEST(test_constructor_plus_buffer_and_callback) - { - receiver.clear(); - BD::callback_type callback = BD::callback_type::create(receiver); + ////************************************************************************* + //TEST(test_constructor_plus_buffer_and_callback) + //{ + // receiver.clear(); + // BD::callback_type callback = BD::callback_type::create(receiver); - BD bd(&buffers[0][0], callback); + // BD bd(&buffers[0][0], callback); - CHECK_EQUAL(N_BUFFERS, bd.N_BUFFERS); - CHECK_EQUAL(BUFFER_SIZE, bd.BUFFER_SIZE); - CHECK(bd.is_valid()); - } + // CHECK_EQUAL(N_BUFFERS, bd.N_BUFFERS); + // CHECK_EQUAL(BUFFER_SIZE, bd.BUFFER_SIZE); + // CHECK(bd.is_valid()); + //} - //************************************************************************* - TEST(test_constructor_plus_buffer_set_callback) - { - receiver.clear(); - BD::callback_type callback = BD::callback_type::create(receiver); + ////************************************************************************* + //TEST(test_constructor_plus_buffer_set_callback) + //{ + // receiver.clear(); + // BD::callback_type callback = BD::callback_type::create(receiver); - BD bd(&buffers[0][0]); - bd.set_callback(callback); + // BD bd(&buffers[0][0]); + // bd.set_callback(callback); - CHECK_EQUAL(N_BUFFERS, bd.N_BUFFERS); - CHECK_EQUAL(BUFFER_SIZE, bd.BUFFER_SIZE); - CHECK(bd.is_valid()); - } + // CHECK_EQUAL(N_BUFFERS, bd.N_BUFFERS); + // CHECK_EQUAL(BUFFER_SIZE, bd.BUFFER_SIZE); + // CHECK(bd.is_valid()); + //} //************************************************************************* TEST(test_buffers) { BD bd(&buffers[0][0]); - for (size_t i = 0U; i < N_BUFFERS - 1; ++i) + for (size_t i = 0U; i < 1; ++i) { BD::descriptor desc = bd.allocate(); @@ -129,255 +129,255 @@ namespace //CHECK_EQUAL(uintptr_t(&buffers[i][0]), uintptr_t(desc.data())); } } - - //************************************************************************* - TEST(test_buffers_with_allocate_fill) - { - std::array test = - { - char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF), - char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF) - }; - - BD bd(&buffers[0][0]); - - for (size_t i = 0U; i < N_BUFFERS; ++i) - { - BD::descriptor desc = bd.allocate(char(0xFF)); - - CHECK_EQUAL(BUFFER_SIZE, desc.max_size()); - CHECK_EQUAL(uintptr_t(&buffers[i][0]), uintptr_t(desc.data())); - CHECK_ARRAY_EQUAL(test.data(), desc.data(), BUFFER_SIZE); - } - } - - //************************************************************************* - TEST(test_notifications) - { - std::array test = { 0, 1, 2, 3, 4, 5, 6, 7, 0, 0, 0, 0, 0, 0, 0, 0 }; - - std::fill(&buffers[0][0], &buffers[N_BUFFERS - 1][0] + BUFFER_SIZE , 0U); - - receiver.clear(); - BD::callback_type callback = BD::callback_type::create(receiver); - - BD bd(&buffers[0][0], callback); - - for (size_t i = 0U; i < N_BUFFERS; ++i) - { - BD::descriptor desc = bd.allocate(); - - CHECK(desc.is_valid()); - - std::copy(test.begin(), test.begin() + DATA_COUNT, desc.data()); - bd.notify(BD::notification(desc, DATA_COUNT)); - desc.release(); - - CHECK_EQUAL(DATA_COUNT, receiver.count); - CHECK_EQUAL(uintptr_t(&buffers[i][0]), uintptr_t(receiver.pbuffer)); - CHECK_ARRAY_EQUAL(test.data(), desc.data(), BUFFER_SIZE); - } - } - - //************************************************************************* - TEST(test_allocate_overflow) - { - BD bd(&buffers[0][0]); - - // Use up all of the descriptors. - for (size_t i = 0U; i < N_BUFFERS; ++i) - { - BD::descriptor desc = bd.allocate(); - CHECK(desc.is_valid()); - } - - BD::descriptor desc = bd.allocate(); - CHECK(!desc.is_valid()); - } - - //************************************************************************* - TEST(test_allocate_release_rollover) - { - std::queue desc_queue; - - BD bd(&buffers[0][0]); - - // Use up all of the descriptors, then release/allocate for the rest. - for (size_t i = 0U; i < (N_BUFFERS * 2); ++i) - { - BD::descriptor desc = bd.allocate(); - desc_queue.push(desc); - - CHECK(desc.is_valid()); - - if (i >= (N_BUFFERS - 1)) - { - desc_queue.front().release(); - desc_queue.pop(); - } - } - } - - //************************************************************************* - TEST(test_descriptors) - { - BD bd(&buffers[0][0]); - - BD::descriptor desc1 = bd.allocate(); - BD::descriptor desc2 = bd.allocate(); - BD::descriptor desc3 = bd.allocate(); - BD::descriptor desc4 = bd.allocate(); - - CHECK(desc1.is_allocated()); - CHECK(desc2.is_allocated()); - CHECK(desc3.is_allocated()); - CHECK(desc4.is_allocated()); - - CHECK(desc1.data() == &buffers[0][0]); - CHECK(desc2.data() == &buffers[1][0]); - CHECK(desc3.data() == &buffers[2][0]); - CHECK(desc4.data() == &buffers[3][0]); - - CHECK(desc1.max_size() == BUFFER_SIZE); - CHECK(desc2.max_size() == BUFFER_SIZE); - CHECK(desc3.max_size() == BUFFER_SIZE); - CHECK(desc4.max_size() == BUFFER_SIZE); - - CHECK(desc1.MAX_SIZE == BUFFER_SIZE); - CHECK(desc2.MAX_SIZE == BUFFER_SIZE); - CHECK(desc3.MAX_SIZE == BUFFER_SIZE); - CHECK(desc4.MAX_SIZE == BUFFER_SIZE); - - CHECK(desc1.is_valid()); - CHECK(desc2.is_valid()); - CHECK(desc3.is_valid()); - CHECK(desc4.is_valid()); - - desc1.release(); - desc2.release(); - desc3.release(); - desc4.release(); - - CHECK(desc1.is_released()); - CHECK(desc2.is_released()); - CHECK(desc3.is_released()); - CHECK(desc4.is_released()); - } - - //************************************************************************* -#if REALTIME_TEST - -#if defined(ETL_TARGET_OS_WINDOWS) // Only Windows priority is currently supported -#define RAISE_THREAD_PRIORITY SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST) -#define FIX_PROCESSOR_AFFINITY1 SetThreadAffinityMask(GetCurrentThread(), 1) -#define FIX_PROCESSOR_AFFINITY2 SetThreadAffinityMask(GetCurrentThread(), 2) -#else -#define RAISE_THREAD_PRIORITY -#define FIX_PROCESSOR_AFFINITY1 -#define FIX_PROCESSOR_AFFINITY2 -#endif - - std::atomic_bool start = false; - - //********************************* - struct Notification - { - BD::descriptor desc; - BD::size_type count; - }; - - constexpr int N_ITERATIONS = 1000000; - - etl::queue_spsc_atomic desc_queue; - - //********************************* - void Callback(BD::notification n) - { - desc_queue.push(n); - } - - //********************************* - void Producer() - { - static char buffers[N_BUFFERS][BUFFER_SIZE]; - - BD bd(&buffers[0][0], BD::callback_type::create()); - - RAISE_THREAD_PRIORITY; - FIX_PROCESSOR_AFFINITY1; - - // Wait for the start flag. - while (!start); - - int errors = 0; - - for (int i = 0; i < N_ITERATIONS; ++i) - { - BD::descriptor desc; - - // Wait until we can allocate a descriptor. - do - { - desc = bd.allocate(); - } while (desc.is_valid() == false); - - if (!desc.is_allocated()) - { - ++errors; - } - - // Send a notification to the callback function. - bd.notify(BD::notification(desc, BUFFER_SIZE)); - } - - CHECK_EQUAL(0, errors); - } - - //********************************* - void Consumer() - { - RAISE_THREAD_PRIORITY; - FIX_PROCESSOR_AFFINITY2; - - // Wait for the start flag. - while (!start); - - int errors = 0; - - for (int i = 0; i < N_ITERATIONS;) - { - BD::notification notification; - - // Try to get a notification from the queue. - if (desc_queue.pop(notification)) - { - CHECK_EQUAL(BUFFER_SIZE, notification.get_count()); - CHECK(notification.get_descriptor().is_allocated()); - - if (!notification.get_descriptor().is_allocated()) - { - ++errors; - } - - notification.get_descriptor().release(); - ++i; - } - - CHECK_EQUAL(0, errors); - } - } - - //********************************* - TEST(test_multi_thread) - { - std::thread t1(Producer); - std::thread t2(Consumer); - - start = true; - - t1.join(); - t2.join(); - } -#endif + // + // //************************************************************************* + // TEST(test_buffers_with_allocate_fill) + // { + // std::array test = + // { + // char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF), + // char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF) + // }; + // + // BD bd(&buffers[0][0]); + // + // for (size_t i = 0U; i < N_BUFFERS; ++i) + // { + // BD::descriptor desc = bd.allocate(char(0xFF)); + // + // CHECK_EQUAL(BUFFER_SIZE, desc.max_size()); + // CHECK_EQUAL(uintptr_t(&buffers[i][0]), uintptr_t(desc.data())); + // CHECK_ARRAY_EQUAL(test.data(), desc.data(), BUFFER_SIZE); + // } + // } + // + // //************************************************************************* + // TEST(test_notifications) + // { + // std::array test = { 0, 1, 2, 3, 4, 5, 6, 7, 0, 0, 0, 0, 0, 0, 0, 0 }; + // + // std::fill(&buffers[0][0], &buffers[N_BUFFERS - 1][0] + BUFFER_SIZE , 0U); + // + // receiver.clear(); + // BD::callback_type callback = BD::callback_type::create(receiver); + // + // BD bd(&buffers[0][0], callback); + // + // for (size_t i = 0U; i < N_BUFFERS; ++i) + // { + // BD::descriptor desc = bd.allocate(); + // + // CHECK(desc.is_valid()); + // + // std::copy(test.begin(), test.begin() + DATA_COUNT, desc.data()); + // bd.notify(BD::notification(desc, DATA_COUNT)); + // desc.release(); + // + // CHECK_EQUAL(DATA_COUNT, receiver.count); + // CHECK_EQUAL(uintptr_t(&buffers[i][0]), uintptr_t(receiver.pbuffer)); + // CHECK_ARRAY_EQUAL(test.data(), desc.data(), BUFFER_SIZE); + // } + // } + // + // //************************************************************************* + // TEST(test_allocate_overflow) + // { + // BD bd(&buffers[0][0]); + // + // // Use up all of the descriptors. + // for (size_t i = 0U; i < N_BUFFERS; ++i) + // { + // BD::descriptor desc = bd.allocate(); + // CHECK(desc.is_valid()); + // } + // + // BD::descriptor desc = bd.allocate(); + // CHECK(!desc.is_valid()); + // } + // + // //************************************************************************* + // TEST(test_allocate_release_rollover) + // { + // std::queue desc_queue; + // + // BD bd(&buffers[0][0]); + // + // // Use up all of the descriptors, then release/allocate for the rest. + // for (size_t i = 0U; i < (N_BUFFERS * 2); ++i) + // { + // BD::descriptor desc = bd.allocate(); + // desc_queue.push(desc); + // + // CHECK(desc.is_valid()); + // + // if (i >= (N_BUFFERS - 1)) + // { + // desc_queue.front().release(); + // desc_queue.pop(); + // } + // } + // } + // + // //************************************************************************* + // TEST(test_descriptors) + // { + // BD bd(&buffers[0][0]); + // + // BD::descriptor desc1 = bd.allocate(); + // BD::descriptor desc2 = bd.allocate(); + // BD::descriptor desc3 = bd.allocate(); + // BD::descriptor desc4 = bd.allocate(); + // + // CHECK(desc1.is_allocated()); + // CHECK(desc2.is_allocated()); + // CHECK(desc3.is_allocated()); + // CHECK(desc4.is_allocated()); + // + // CHECK(desc1.data() == &buffers[0][0]); + // CHECK(desc2.data() == &buffers[1][0]); + // CHECK(desc3.data() == &buffers[2][0]); + // CHECK(desc4.data() == &buffers[3][0]); + // + // CHECK(desc1.max_size() == BUFFER_SIZE); + // CHECK(desc2.max_size() == BUFFER_SIZE); + // CHECK(desc3.max_size() == BUFFER_SIZE); + // CHECK(desc4.max_size() == BUFFER_SIZE); + // + // CHECK(desc1.MAX_SIZE == BUFFER_SIZE); + // CHECK(desc2.MAX_SIZE == BUFFER_SIZE); + // CHECK(desc3.MAX_SIZE == BUFFER_SIZE); + // CHECK(desc4.MAX_SIZE == BUFFER_SIZE); + // + // CHECK(desc1.is_valid()); + // CHECK(desc2.is_valid()); + // CHECK(desc3.is_valid()); + // CHECK(desc4.is_valid()); + // + // desc1.release(); + // desc2.release(); + // desc3.release(); + // desc4.release(); + // + // CHECK(desc1.is_released()); + // CHECK(desc2.is_released()); + // CHECK(desc3.is_released()); + // CHECK(desc4.is_released()); + // } + // + // //************************************************************************* + //#if REALTIME_TEST + // + //#if defined(ETL_TARGET_OS_WINDOWS) // Only Windows priority is currently supported + //#define RAISE_THREAD_PRIORITY SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST) + //#define FIX_PROCESSOR_AFFINITY1 SetThreadAffinityMask(GetCurrentThread(), 1) + //#define FIX_PROCESSOR_AFFINITY2 SetThreadAffinityMask(GetCurrentThread(), 2) + //#else + //#define RAISE_THREAD_PRIORITY + //#define FIX_PROCESSOR_AFFINITY1 + //#define FIX_PROCESSOR_AFFINITY2 + //#endif + // + // std::atomic_bool start = false; + // + // //********************************* + // struct Notification + // { + // BD::descriptor desc; + // BD::size_type count; + // }; + // + // constexpr int N_ITERATIONS = 1000000; + // + // etl::queue_spsc_atomic desc_queue; + // + // //********************************* + // void Callback(BD::notification n) + // { + // desc_queue.push(n); + // } + // + // //********************************* + // void Producer() + // { + // static char buffers[N_BUFFERS][BUFFER_SIZE]; + // + // BD bd(&buffers[0][0], BD::callback_type::create()); + // + // RAISE_THREAD_PRIORITY; + // FIX_PROCESSOR_AFFINITY1; + // + // // Wait for the start flag. + // while (!start); + // + // int errors = 0; + // + // for (int i = 0; i < N_ITERATIONS; ++i) + // { + // BD::descriptor desc; + // + // // Wait until we can allocate a descriptor. + // do + // { + // desc = bd.allocate(); + // } while (desc.is_valid() == false); + // + // if (!desc.is_allocated()) + // { + // ++errors; + // } + // + // // Send a notification to the callback function. + // bd.notify(BD::notification(desc, BUFFER_SIZE)); + // } + // + // CHECK_EQUAL(0, errors); + // } + // + // //********************************* + // void Consumer() + // { + // RAISE_THREAD_PRIORITY; + // FIX_PROCESSOR_AFFINITY2; + // + // // Wait for the start flag. + // while (!start); + // + // int errors = 0; + // + // for (int i = 0; i < N_ITERATIONS;) + // { + // BD::notification notification; + // + // // Try to get a notification from the queue. + // if (desc_queue.pop(notification)) + // { + // CHECK_EQUAL(BUFFER_SIZE, notification.get_count()); + // CHECK(notification.get_descriptor().is_allocated()); + // + // if (!notification.get_descriptor().is_allocated()) + // { + // ++errors; + // } + // + // notification.get_descriptor().release(); + // ++i; + // } + // + // CHECK_EQUAL(0, errors); + // } + // } + // + // //********************************* + // TEST(test_multi_thread) + // { + // std::thread t1(Producer); + // std::thread t2(Consumer); + // + // start = true; + // + // t1.join(); + // t2.join(); + // } + //#endif }; } From 658d592c96eb7eaf1afb5d09fef38e293ea6f79b Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Tue, 24 Nov 2020 16:58:52 +0000 Subject: [PATCH 03/19] Refactor buffer_descriptors test --- test/test_buffer_descriptors.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_buffer_descriptors.cpp b/test/test_buffer_descriptors.cpp index c8fc65b7..70db8519 100644 --- a/test/test_buffer_descriptors.cpp +++ b/test/test_buffer_descriptors.cpp @@ -121,7 +121,7 @@ namespace { BD bd(&buffers[0][0]); - for (size_t i = 0U; i < 1; ++i) + for (size_t i = 0U; i < N_BUFFERS; ++i) { BD::descriptor desc = bd.allocate(); From 297ef42c60e4228bfbcb2adcddeb6b8a617c4113 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Tue, 24 Nov 2020 17:08:45 +0000 Subject: [PATCH 04/19] Refactor buffer_descriptors test --- .gitignore | 1 + test/test_buffer_descriptors.cpp | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 3cf711a9..6a8c9f5c 100644 --- a/.gitignore +++ b/.gitignore @@ -274,3 +274,4 @@ test/random_pcg.csv test/random_xorshift.csv test/cmake_install.cmake test/Makefile +test/vs2019/enc_temp_folder diff --git a/test/test_buffer_descriptors.cpp b/test/test_buffer_descriptors.cpp index 70db8519..d2ae9c2d 100644 --- a/test/test_buffer_descriptors.cpp +++ b/test/test_buffer_descriptors.cpp @@ -125,8 +125,8 @@ namespace { BD::descriptor desc = bd.allocate(); - //CHECK_EQUAL(BUFFER_SIZE, desc.max_size()); - //CHECK_EQUAL(uintptr_t(&buffers[i][0]), uintptr_t(desc.data())); + CHECK_EQUAL(BUFFER_SIZE, desc.max_size()); + CHECK_EQUAL(uintptr_t(&buffers[i][0]), uintptr_t(desc.data())); } } // From 3564ac5b7ef89c41b240d9f54fce36042408daa0 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Tue, 24 Nov 2020 17:17:50 +0000 Subject: [PATCH 05/19] Refactor buffer_descriptors test --- test/test_buffer_descriptors.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test_buffer_descriptors.cpp b/test/test_buffer_descriptors.cpp index d2ae9c2d..70db8519 100644 --- a/test/test_buffer_descriptors.cpp +++ b/test/test_buffer_descriptors.cpp @@ -125,8 +125,8 @@ namespace { BD::descriptor desc = bd.allocate(); - CHECK_EQUAL(BUFFER_SIZE, desc.max_size()); - CHECK_EQUAL(uintptr_t(&buffers[i][0]), uintptr_t(desc.data())); + //CHECK_EQUAL(BUFFER_SIZE, desc.max_size()); + //CHECK_EQUAL(uintptr_t(&buffers[i][0]), uintptr_t(desc.data())); } } // From 80d5776c409b416377269d543bd539bdad83dc86 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Tue, 24 Nov 2020 17:32:27 +0000 Subject: [PATCH 06/19] Refactor buffer_descriptors test --- test/test_buffer_descriptors.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_buffer_descriptors.cpp b/test/test_buffer_descriptors.cpp index 70db8519..2e7e2ab1 100644 --- a/test/test_buffer_descriptors.cpp +++ b/test/test_buffer_descriptors.cpp @@ -126,7 +126,7 @@ namespace BD::descriptor desc = bd.allocate(); //CHECK_EQUAL(BUFFER_SIZE, desc.max_size()); - //CHECK_EQUAL(uintptr_t(&buffers[i][0]), uintptr_t(desc.data())); + CHECK_EQUAL(uintptr_t(&buffers[i][0]), uintptr_t(desc.data())); } } // From 4b2dd2fce22cd0a4846b95695fbfd812e0823540 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Tue, 24 Nov 2020 17:47:43 +0000 Subject: [PATCH 07/19] Refactor buffer_descriptors test --- test/test_buffer_descriptors.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_buffer_descriptors.cpp b/test/test_buffer_descriptors.cpp index 2e7e2ab1..1fb1a23a 100644 --- a/test/test_buffer_descriptors.cpp +++ b/test/test_buffer_descriptors.cpp @@ -126,7 +126,7 @@ namespace BD::descriptor desc = bd.allocate(); //CHECK_EQUAL(BUFFER_SIZE, desc.max_size()); - CHECK_EQUAL(uintptr_t(&buffers[i][0]), uintptr_t(desc.data())); + CHECK_EQUAL(&buffers[i][0], desc.data()); } } // From 0c721c0466733751708fcbd995ce0bc1d7c0a932 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Tue, 24 Nov 2020 17:58:22 +0000 Subject: [PATCH 08/19] Refactor buffer_descriptors test --- test/test_buffer_descriptors.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/test_buffer_descriptors.cpp b/test/test_buffer_descriptors.cpp index 1fb1a23a..b4418567 100644 --- a/test/test_buffer_descriptors.cpp +++ b/test/test_buffer_descriptors.cpp @@ -126,7 +126,11 @@ namespace BD::descriptor desc = bd.allocate(); //CHECK_EQUAL(BUFFER_SIZE, desc.max_size()); - CHECK_EQUAL(&buffers[i][0], desc.data()); + + char* a = &buffers[i][0]; + char* b = desc.data(); + + CHECK_EQUAL(a, b); } } // From a9b25ac67d175f58751a2eb819f0e5822e8f0cf9 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Tue, 24 Nov 2020 18:08:21 +0000 Subject: [PATCH 09/19] Refactor buffer_descriptors test --- test/test_buffer_descriptors.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_buffer_descriptors.cpp b/test/test_buffer_descriptors.cpp index b4418567..60d3eae7 100644 --- a/test/test_buffer_descriptors.cpp +++ b/test/test_buffer_descriptors.cpp @@ -130,7 +130,7 @@ namespace char* a = &buffers[i][0]; char* b = desc.data(); - CHECK_EQUAL(a, b); + //CHECK_EQUAL(a, b); } } // From 7a68c932a7df05f66690fa63e67365cf4b0619e8 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Tue, 24 Nov 2020 18:14:30 +0000 Subject: [PATCH 10/19] Refactor buffer_descriptors test --- test/test_buffer_descriptors.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_buffer_descriptors.cpp b/test/test_buffer_descriptors.cpp index 60d3eae7..c2b612f5 100644 --- a/test/test_buffer_descriptors.cpp +++ b/test/test_buffer_descriptors.cpp @@ -128,7 +128,7 @@ namespace //CHECK_EQUAL(BUFFER_SIZE, desc.max_size()); char* a = &buffers[i][0]; - char* b = desc.data(); + //char* b = desc.data(); //CHECK_EQUAL(a, b); } From 7bda7678311bf2eb497483f3ef27c3af9211680b Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Tue, 24 Nov 2020 18:29:02 +0000 Subject: [PATCH 11/19] Refactor buffer_descriptors test --- test/test_buffer_descriptors.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/test_buffer_descriptors.cpp b/test/test_buffer_descriptors.cpp index c2b612f5..4baf8358 100644 --- a/test/test_buffer_descriptors.cpp +++ b/test/test_buffer_descriptors.cpp @@ -125,10 +125,12 @@ namespace { BD::descriptor desc = bd.allocate(); + CHECK(desc.is_valid()); + //CHECK_EQUAL(BUFFER_SIZE, desc.max_size()); char* a = &buffers[i][0]; - //char* b = desc.data(); + char* b = desc.data(); //CHECK_EQUAL(a, b); } From 49c60add63153bf53f400a891d8c4fb880cacda8 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Tue, 24 Nov 2020 18:44:42 +0000 Subject: [PATCH 12/19] Refactor buffer_descriptors test --- test/test_buffer_descriptors.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/test_buffer_descriptors.cpp b/test/test_buffer_descriptors.cpp index 4baf8358..73d1215d 100644 --- a/test/test_buffer_descriptors.cpp +++ b/test/test_buffer_descriptors.cpp @@ -126,6 +126,10 @@ namespace BD::descriptor desc = bd.allocate(); CHECK(desc.is_valid()); + if (!desc.is_valid()) + { + CHECK_EQUAL(100000, i); + } //CHECK_EQUAL(BUFFER_SIZE, desc.max_size()); From 36cbf21cd1b67a28255582cfb4a188a601631ab2 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Tue, 24 Nov 2020 18:52:53 +0000 Subject: [PATCH 13/19] Refactor buffer_descriptors test --- include/etl/buffer_descriptors.h | 14 ++++++++++++++ test/test_buffer_descriptors.cpp | 13 +------------ 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/include/etl/buffer_descriptors.h b/include/etl/buffer_descriptors.h index d9c03e11..d3c94789 100644 --- a/include/etl/buffer_descriptors.h +++ b/include/etl/buffer_descriptors.h @@ -96,6 +96,7 @@ namespace etl //********************************* pointer data() const { + assert(pdesc_item != nullptr); return pdesc_item->pbuffer; } @@ -201,6 +202,7 @@ namespace etl for (size_t i = 0U; i < N_BUFFERS; ++i) { descriptor_items[i].pbuffer = pbuffers_ + (i * BUFFER_SIZE); + descriptor_items[i].in_use = false; } } @@ -211,6 +213,7 @@ namespace etl for (size_t i = 0U; i < N_BUFFERS; ++i) { descriptor_items[i].pbuffer = pbuffers_ + (i * BUFFER_SIZE); + descriptor_items[i].in_use = false; } } @@ -220,6 +223,17 @@ namespace etl callback = callback_; } + //********************************* + void clear() + { + for (size_t i = 0U; i < N_BUFFERS; ++i) + { + descriptor_items[i].in_use = false; + } + + next.to_first(); + } + //********************************* ETL_NODISCARD bool is_valid() const diff --git a/test/test_buffer_descriptors.cpp b/test/test_buffer_descriptors.cpp index 73d1215d..7ed1e645 100644 --- a/test/test_buffer_descriptors.cpp +++ b/test/test_buffer_descriptors.cpp @@ -125,18 +125,7 @@ namespace { BD::descriptor desc = bd.allocate(); - CHECK(desc.is_valid()); - if (!desc.is_valid()) - { - CHECK_EQUAL(100000, i); - } - - //CHECK_EQUAL(BUFFER_SIZE, desc.max_size()); - - char* a = &buffers[i][0]; - char* b = desc.data(); - - //CHECK_EQUAL(a, b); + CHECK_EQUAL(BUFFER_SIZE, desc.max_size()); } } // From c7ee1d6574ca5d95869152c5f8e4e6d02a7fa6bc Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Tue, 24 Nov 2020 19:20:24 +0000 Subject: [PATCH 14/19] Fixed non-initialisation of in_use flag. --- .github/workflows/clang.yml | 62 +++- include/etl/buffer_descriptors.h | 12 +- test/test_buffer_descriptors.cpp | 572 ++++++++++++++++--------------- 3 files changed, 350 insertions(+), 296 deletions(-) diff --git a/.github/workflows/clang.yml b/.github/workflows/clang.yml index ea88089a..35b012c1 100644 --- a/.github/workflows/clang.yml +++ b/.github/workflows/clang.yml @@ -1,11 +1,50 @@ name: clang on: push: - branches: [ hotfix/clang-ci-unit-test-crash ] + branches: [ master ] pull_request: branches: [ master ] jobs: + build-clang-9-linux: + name: Clang-9 Linux + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-20.04] + + steps: + - uses: actions/checkout@v2 + + - name: Build + run: | + export CC=clang-9 + export CXX=clang++-9 + cmake -D BUILD_TESTS=ON ./ + clang --version + make + + - name: Run tests + run: ./test/etl_tests + + build-clang-9-linux-no-stl: + name: Clang-9 Linux - No STL + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-20.04] + + steps: + - uses: actions/checkout@v2 + + - name: Build + run: | + cmake -DBUILD_TESTS=ON -DNO_STL=ON ./ + gcc --version + make + + - name: Run tests + run: ./test/etl_tests build-clang-10-osx: name: Clang-10 OSX @@ -27,3 +66,24 @@ jobs: - name: Run tests run: ./test/etl_tests + + build-clang-10-osx-no-stl: + name: Clang-10 OSX - No STL + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [macos-10.15] + + steps: + - uses: actions/checkout@v2 + + - name: Build + run: | + export CC=clang + export CXX=clang++ + cmake -D BUILD_TESTS=ON -DNO_STL=ON ./ + clang --version + make + + - name: Run tests + run: ./test/etl_tests diff --git a/include/etl/buffer_descriptors.h b/include/etl/buffer_descriptors.h index d3c94789..78076442 100644 --- a/include/etl/buffer_descriptors.h +++ b/include/etl/buffer_descriptors.h @@ -197,17 +197,7 @@ namespace etl typedef etl::delegate callback_type; //********************************* - buffer_descriptors(TBuffer* pbuffers_) - { - for (size_t i = 0U; i < N_BUFFERS; ++i) - { - descriptor_items[i].pbuffer = pbuffers_ + (i * BUFFER_SIZE); - descriptor_items[i].in_use = false; - } - } - - //********************************* - buffer_descriptors(TBuffer* pbuffers_, const callback_type& callback_) + buffer_descriptors(TBuffer* pbuffers_, callback_type callback_ = callback_type()) : callback(callback_) { for (size_t i = 0U; i < N_BUFFERS; ++i) diff --git a/test/test_buffer_descriptors.cpp b/test/test_buffer_descriptors.cpp index 7ed1e645..cb82c6e3 100644 --- a/test/test_buffer_descriptors.cpp +++ b/test/test_buffer_descriptors.cpp @@ -41,7 +41,7 @@ SOFTWARE. #include "etl/buffer_descriptors.h" #if defined(ETL_TARGET_OS_WINDOWS) -#include + #include #endif #define REALTIME_TEST 0 @@ -49,8 +49,8 @@ SOFTWARE. namespace { constexpr size_t BUFFER_SIZE = 16U; - constexpr size_t N_BUFFERS = 4U; - constexpr size_t DATA_COUNT = BUFFER_SIZE / 2; + constexpr size_t N_BUFFERS = 4U; + constexpr size_t DATA_COUNT = BUFFER_SIZE / 2; using BD = etl::buffer_descriptors; @@ -62,13 +62,13 @@ namespace void receive(BD::notification n) { pbuffer = n.get_descriptor().data(); - count = n.get_count(); + count = n.get_count(); } void clear() { pbuffer = nullptr; - count = 0U; + count = 0U; } BD::pointer pbuffer; @@ -79,42 +79,42 @@ namespace SUITE(test_buffer_descriptors) { - ////************************************************************************* - //TEST(test_constructor_plus_buffer) - //{ - // BD bd(&buffers[0][0]); + //************************************************************************* + TEST(test_constructor_plus_buffer) + { + BD bd(&buffers[0][0]); - // CHECK_EQUAL(N_BUFFERS, bd.N_BUFFERS); - // CHECK_EQUAL(BUFFER_SIZE, bd.BUFFER_SIZE); - // CHECK(!bd.is_valid()); - //} + CHECK_EQUAL(N_BUFFERS, bd.N_BUFFERS); + CHECK_EQUAL(BUFFER_SIZE, bd.BUFFER_SIZE); + CHECK(!bd.is_valid()); + } - ////************************************************************************* - //TEST(test_constructor_plus_buffer_and_callback) - //{ - // receiver.clear(); - // BD::callback_type callback = BD::callback_type::create(receiver); + //************************************************************************* + TEST(test_constructor_plus_buffer_and_callback) + { + receiver.clear(); + BD::callback_type callback = BD::callback_type::create(receiver); - // BD bd(&buffers[0][0], callback); + BD bd(&buffers[0][0], callback); - // CHECK_EQUAL(N_BUFFERS, bd.N_BUFFERS); - // CHECK_EQUAL(BUFFER_SIZE, bd.BUFFER_SIZE); - // CHECK(bd.is_valid()); - //} + CHECK_EQUAL(N_BUFFERS, bd.N_BUFFERS); + CHECK_EQUAL(BUFFER_SIZE, bd.BUFFER_SIZE); + CHECK(bd.is_valid()); + } - ////************************************************************************* - //TEST(test_constructor_plus_buffer_set_callback) - //{ - // receiver.clear(); - // BD::callback_type callback = BD::callback_type::create(receiver); + //************************************************************************* + TEST(test_constructor_plus_buffer_set_callback) + { + receiver.clear(); + BD::callback_type callback = BD::callback_type::create(receiver); - // BD bd(&buffers[0][0]); - // bd.set_callback(callback); + BD bd(&buffers[0][0]); + bd.set_callback(callback); - // CHECK_EQUAL(N_BUFFERS, bd.N_BUFFERS); - // CHECK_EQUAL(BUFFER_SIZE, bd.BUFFER_SIZE); - // CHECK(bd.is_valid()); - //} + CHECK_EQUAL(N_BUFFERS, bd.N_BUFFERS); + CHECK_EQUAL(BUFFER_SIZE, bd.BUFFER_SIZE); + CHECK(bd.is_valid()); + } //************************************************************************* TEST(test_buffers) @@ -125,258 +125,262 @@ namespace { BD::descriptor desc = bd.allocate(); + CHECK(desc.is_valid()); + CHECK(desc.is_allocated()); + CHECK(!desc.is_released()); CHECK_EQUAL(BUFFER_SIZE, desc.max_size()); + CHECK_EQUAL(uintptr_t(&buffers[i][0]), uintptr_t(desc.data())); } } - // - // //************************************************************************* - // TEST(test_buffers_with_allocate_fill) - // { - // std::array test = - // { - // char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF), - // char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF) - // }; - // - // BD bd(&buffers[0][0]); - // - // for (size_t i = 0U; i < N_BUFFERS; ++i) - // { - // BD::descriptor desc = bd.allocate(char(0xFF)); - // - // CHECK_EQUAL(BUFFER_SIZE, desc.max_size()); - // CHECK_EQUAL(uintptr_t(&buffers[i][0]), uintptr_t(desc.data())); - // CHECK_ARRAY_EQUAL(test.data(), desc.data(), BUFFER_SIZE); - // } - // } - // - // //************************************************************************* - // TEST(test_notifications) - // { - // std::array test = { 0, 1, 2, 3, 4, 5, 6, 7, 0, 0, 0, 0, 0, 0, 0, 0 }; - // - // std::fill(&buffers[0][0], &buffers[N_BUFFERS - 1][0] + BUFFER_SIZE , 0U); - // - // receiver.clear(); - // BD::callback_type callback = BD::callback_type::create(receiver); - // - // BD bd(&buffers[0][0], callback); - // - // for (size_t i = 0U; i < N_BUFFERS; ++i) - // { - // BD::descriptor desc = bd.allocate(); - // - // CHECK(desc.is_valid()); - // - // std::copy(test.begin(), test.begin() + DATA_COUNT, desc.data()); - // bd.notify(BD::notification(desc, DATA_COUNT)); - // desc.release(); - // - // CHECK_EQUAL(DATA_COUNT, receiver.count); - // CHECK_EQUAL(uintptr_t(&buffers[i][0]), uintptr_t(receiver.pbuffer)); - // CHECK_ARRAY_EQUAL(test.data(), desc.data(), BUFFER_SIZE); - // } - // } - // - // //************************************************************************* - // TEST(test_allocate_overflow) - // { - // BD bd(&buffers[0][0]); - // - // // Use up all of the descriptors. - // for (size_t i = 0U; i < N_BUFFERS; ++i) - // { - // BD::descriptor desc = bd.allocate(); - // CHECK(desc.is_valid()); - // } - // - // BD::descriptor desc = bd.allocate(); - // CHECK(!desc.is_valid()); - // } - // - // //************************************************************************* - // TEST(test_allocate_release_rollover) - // { - // std::queue desc_queue; - // - // BD bd(&buffers[0][0]); - // - // // Use up all of the descriptors, then release/allocate for the rest. - // for (size_t i = 0U; i < (N_BUFFERS * 2); ++i) - // { - // BD::descriptor desc = bd.allocate(); - // desc_queue.push(desc); - // - // CHECK(desc.is_valid()); - // - // if (i >= (N_BUFFERS - 1)) - // { - // desc_queue.front().release(); - // desc_queue.pop(); - // } - // } - // } - // - // //************************************************************************* - // TEST(test_descriptors) - // { - // BD bd(&buffers[0][0]); - // - // BD::descriptor desc1 = bd.allocate(); - // BD::descriptor desc2 = bd.allocate(); - // BD::descriptor desc3 = bd.allocate(); - // BD::descriptor desc4 = bd.allocate(); - // - // CHECK(desc1.is_allocated()); - // CHECK(desc2.is_allocated()); - // CHECK(desc3.is_allocated()); - // CHECK(desc4.is_allocated()); - // - // CHECK(desc1.data() == &buffers[0][0]); - // CHECK(desc2.data() == &buffers[1][0]); - // CHECK(desc3.data() == &buffers[2][0]); - // CHECK(desc4.data() == &buffers[3][0]); - // - // CHECK(desc1.max_size() == BUFFER_SIZE); - // CHECK(desc2.max_size() == BUFFER_SIZE); - // CHECK(desc3.max_size() == BUFFER_SIZE); - // CHECK(desc4.max_size() == BUFFER_SIZE); - // - // CHECK(desc1.MAX_SIZE == BUFFER_SIZE); - // CHECK(desc2.MAX_SIZE == BUFFER_SIZE); - // CHECK(desc3.MAX_SIZE == BUFFER_SIZE); - // CHECK(desc4.MAX_SIZE == BUFFER_SIZE); - // - // CHECK(desc1.is_valid()); - // CHECK(desc2.is_valid()); - // CHECK(desc3.is_valid()); - // CHECK(desc4.is_valid()); - // - // desc1.release(); - // desc2.release(); - // desc3.release(); - // desc4.release(); - // - // CHECK(desc1.is_released()); - // CHECK(desc2.is_released()); - // CHECK(desc3.is_released()); - // CHECK(desc4.is_released()); - // } - // - // //************************************************************************* - //#if REALTIME_TEST - // - //#if defined(ETL_TARGET_OS_WINDOWS) // Only Windows priority is currently supported - //#define RAISE_THREAD_PRIORITY SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST) - //#define FIX_PROCESSOR_AFFINITY1 SetThreadAffinityMask(GetCurrentThread(), 1) - //#define FIX_PROCESSOR_AFFINITY2 SetThreadAffinityMask(GetCurrentThread(), 2) - //#else - //#define RAISE_THREAD_PRIORITY - //#define FIX_PROCESSOR_AFFINITY1 - //#define FIX_PROCESSOR_AFFINITY2 - //#endif - // - // std::atomic_bool start = false; - // - // //********************************* - // struct Notification - // { - // BD::descriptor desc; - // BD::size_type count; - // }; - // - // constexpr int N_ITERATIONS = 1000000; - // - // etl::queue_spsc_atomic desc_queue; - // - // //********************************* - // void Callback(BD::notification n) - // { - // desc_queue.push(n); - // } - // - // //********************************* - // void Producer() - // { - // static char buffers[N_BUFFERS][BUFFER_SIZE]; - // - // BD bd(&buffers[0][0], BD::callback_type::create()); - // - // RAISE_THREAD_PRIORITY; - // FIX_PROCESSOR_AFFINITY1; - // - // // Wait for the start flag. - // while (!start); - // - // int errors = 0; - // - // for (int i = 0; i < N_ITERATIONS; ++i) - // { - // BD::descriptor desc; - // - // // Wait until we can allocate a descriptor. - // do - // { - // desc = bd.allocate(); - // } while (desc.is_valid() == false); - // - // if (!desc.is_allocated()) - // { - // ++errors; - // } - // - // // Send a notification to the callback function. - // bd.notify(BD::notification(desc, BUFFER_SIZE)); - // } - // - // CHECK_EQUAL(0, errors); - // } - // - // //********************************* - // void Consumer() - // { - // RAISE_THREAD_PRIORITY; - // FIX_PROCESSOR_AFFINITY2; - // - // // Wait for the start flag. - // while (!start); - // - // int errors = 0; - // - // for (int i = 0; i < N_ITERATIONS;) - // { - // BD::notification notification; - // - // // Try to get a notification from the queue. - // if (desc_queue.pop(notification)) - // { - // CHECK_EQUAL(BUFFER_SIZE, notification.get_count()); - // CHECK(notification.get_descriptor().is_allocated()); - // - // if (!notification.get_descriptor().is_allocated()) - // { - // ++errors; - // } - // - // notification.get_descriptor().release(); - // ++i; - // } - // - // CHECK_EQUAL(0, errors); - // } - // } - // - // //********************************* - // TEST(test_multi_thread) - // { - // std::thread t1(Producer); - // std::thread t2(Consumer); - // - // start = true; - // - // t1.join(); - // t2.join(); - // } - //#endif + + //************************************************************************* + TEST(test_buffers_with_allocate_fill) + { + std::array test = + { + char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF), + char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF) + }; + + BD bd(&buffers[0][0]); + + for (size_t i = 0U; i < N_BUFFERS; ++i) + { + BD::descriptor desc = bd.allocate(char(0xFF)); + + CHECK_EQUAL(BUFFER_SIZE, desc.max_size()); + CHECK_EQUAL(uintptr_t(&buffers[i][0]), uintptr_t(desc.data())); + CHECK_ARRAY_EQUAL(test.data(), desc.data(), BUFFER_SIZE); + } + } + + //************************************************************************* + TEST(test_notifications) + { + std::array test = { 0, 1, 2, 3, 4, 5, 6, 7, 0, 0, 0, 0, 0, 0, 0, 0 }; + + std::fill(&buffers[0][0], &buffers[N_BUFFERS - 1][0] + BUFFER_SIZE , 0U); + + receiver.clear(); + BD::callback_type callback = BD::callback_type::create(receiver); + + BD bd(&buffers[0][0], callback); + + for (size_t i = 0U; i < N_BUFFERS; ++i) + { + BD::descriptor desc = bd.allocate(); + + CHECK(desc.is_valid()); + + std::copy(test.begin(), test.begin() + DATA_COUNT, desc.data()); + bd.notify(BD::notification(desc, DATA_COUNT)); + desc.release(); + + CHECK_EQUAL(DATA_COUNT, receiver.count); + CHECK_EQUAL(uintptr_t(&buffers[i][0]), uintptr_t(receiver.pbuffer)); + CHECK_ARRAY_EQUAL(test.data(), desc.data(), BUFFER_SIZE); + } + } + + //************************************************************************* + TEST(test_allocate_overflow) + { + BD bd(&buffers[0][0]); + + // Use up all of the descriptors. + for (size_t i = 0U; i < N_BUFFERS; ++i) + { + BD::descriptor desc = bd.allocate(); + CHECK(desc.is_valid()); + } + + BD::descriptor desc = bd.allocate(); + CHECK(!desc.is_valid()); + } + + //************************************************************************* + TEST(test_allocate_release_rollover) + { + std::queue desc_queue; + + BD bd(&buffers[0][0]); + + // Use up all of the descriptors, then release/allocate for the rest. + for (size_t i = 0U; i < (N_BUFFERS * 2); ++i) + { + BD::descriptor desc = bd.allocate(); + desc_queue.push(desc); + + CHECK(desc.is_valid()); + + if (i >= (N_BUFFERS - 1)) + { + desc_queue.front().release(); + desc_queue.pop(); + } + } + } + + //************************************************************************* + TEST(test_descriptors) + { + BD bd(&buffers[0][0]); + + BD::descriptor desc1 = bd.allocate(); + BD::descriptor desc2 = bd.allocate(); + BD::descriptor desc3 = bd.allocate(); + BD::descriptor desc4 = bd.allocate(); + + CHECK(desc1.is_allocated()); + CHECK(desc2.is_allocated()); + CHECK(desc3.is_allocated()); + CHECK(desc4.is_allocated()); + + CHECK(desc1.data() == &buffers[0][0]); + CHECK(desc2.data() == &buffers[1][0]); + CHECK(desc3.data() == &buffers[2][0]); + CHECK(desc4.data() == &buffers[3][0]); + + CHECK(desc1.max_size() == BUFFER_SIZE); + CHECK(desc2.max_size() == BUFFER_SIZE); + CHECK(desc3.max_size() == BUFFER_SIZE); + CHECK(desc4.max_size() == BUFFER_SIZE); + + CHECK(desc1.MAX_SIZE == BUFFER_SIZE); + CHECK(desc2.MAX_SIZE == BUFFER_SIZE); + CHECK(desc3.MAX_SIZE == BUFFER_SIZE); + CHECK(desc4.MAX_SIZE == BUFFER_SIZE); + + CHECK(desc1.is_valid()); + CHECK(desc2.is_valid()); + CHECK(desc3.is_valid()); + CHECK(desc4.is_valid()); + + desc1.release(); + desc2.release(); + desc3.release(); + desc4.release(); + + CHECK(desc1.is_released()); + CHECK(desc2.is_released()); + CHECK(desc3.is_released()); + CHECK(desc4.is_released()); + } + + //************************************************************************* +#if REALTIME_TEST + +#if defined(ETL_TARGET_OS_WINDOWS) // Only Windows priority is currently supported +#define RAISE_THREAD_PRIORITY SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST) +#define FIX_PROCESSOR_AFFINITY1 SetThreadAffinityMask(GetCurrentThread(), 1) +#define FIX_PROCESSOR_AFFINITY2 SetThreadAffinityMask(GetCurrentThread(), 2) +#else +#define RAISE_THREAD_PRIORITY +#define FIX_PROCESSOR_AFFINITY1 +#define FIX_PROCESSOR_AFFINITY2 +#endif + + std::atomic_bool start = false; + + //********************************* + struct Notification + { + BD::descriptor desc; + BD::size_type count; + }; + + constexpr int N_ITERATIONS = 1000000; + + etl::queue_spsc_atomic desc_queue; + + //********************************* + void Callback(BD::notification n) + { + desc_queue.push(n); + } + + //********************************* + void Producer() + { + static char buffers[N_BUFFERS][BUFFER_SIZE]; + + BD bd(&buffers[0][0], BD::callback_type::create()); + + RAISE_THREAD_PRIORITY; + FIX_PROCESSOR_AFFINITY1; + + // Wait for the start flag. + while (!start); + + int errors = 0; + + for (int i = 0; i < N_ITERATIONS; ++i) + { + BD::descriptor desc; + + // Wait until we can allocate a descriptor. + do + { + desc = bd.allocate(); + } while (desc.is_valid() == false); + + if (!desc.is_allocated()) + { + ++errors; + } + + // Send a notification to the callback function. + bd.notify(BD::notification(desc, BUFFER_SIZE)); + } + + CHECK_EQUAL(0, errors); + } + + //********************************* + void Consumer() + { + RAISE_THREAD_PRIORITY; + FIX_PROCESSOR_AFFINITY2; + + // Wait for the start flag. + while (!start); + + int errors = 0; + + for (int i = 0; i < N_ITERATIONS;) + { + BD::notification notification; + + // Try to get a notification from the queue. + if (desc_queue.pop(notification)) + { + CHECK_EQUAL(BUFFER_SIZE, notification.get_count()); + CHECK(notification.get_descriptor().is_allocated()); + + if (!notification.get_descriptor().is_allocated()) + { + ++errors; + } + + notification.get_descriptor().release(); + ++i; + } + + CHECK_EQUAL(0, errors); + } + } + + //********************************* + TEST(test_multi_thread) + { + std::thread t1(Producer); + std::thread t2(Consumer); + + start = true; + + t1.join(); + t2.join(); + } +#endif }; } From dceb56dd1a19be6fe9b991bb50e08902eefe36a8 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Tue, 24 Nov 2020 19:27:18 +0000 Subject: [PATCH 15/19] Fixed non-initialisation of in_use flag. --- test/test_buffer_descriptors.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test/test_buffer_descriptors.cpp b/test/test_buffer_descriptors.cpp index cb82c6e3..8ca32ae1 100644 --- a/test/test_buffer_descriptors.cpp +++ b/test/test_buffer_descriptors.cpp @@ -133,6 +133,27 @@ namespace } } + //************************************************************************* + TEST(test_clear) + { + BD bd(&buffers[0][0]); + BD::descriptor desc[4]; + + for (size_t i = 0U; i < N_BUFFERS; ++i) + { + desc[i] = bd.allocate(); + } + + bd.clear(); + + for (size_t i = 0U; i < N_BUFFERS; ++i) + { + CHECK(desc[i].is_valid()); + CHECK(!desc[i].is_allocated()); + CHECK(desc[i].is_released()); + } + } + //************************************************************************* TEST(test_buffers_with_allocate_fill) { From 809ccafbafaee110139357339b686338c62ec769 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Thu, 26 Nov 2020 19:29:51 +0000 Subject: [PATCH 16/19] Squashed commit of the following: commit fa9d9592aa7cb686ae1e8c6eeedfcbfda7a59835 Author: John Wellbelove Date: Thu Nov 26 19:26:11 2020 +0000 format_spec may be constexpr --- include/etl/basic_format_spec.h | 61 +++++++++++-------- include/etl/math_constants.h | 20 +++--- test/test_format_spec.cpp | 105 ++++++++++++++++++++++++++++++++ test/vs2019/etl.vcxproj | 1 + test/vs2019/etl.vcxproj.filters | 3 + 5 files changed, 153 insertions(+), 37 deletions(-) create mode 100644 test/test_format_spec.cpp diff --git a/include/etl/basic_format_spec.h b/include/etl/basic_format_spec.h index d5a885ff..80e9870e 100644 --- a/include/etl/basic_format_spec.h +++ b/include/etl/basic_format_spec.h @@ -211,15 +211,22 @@ namespace etl /// Upper case (for hex) = true /// Left Justified = false //*************************************************************************** - basic_format_spec() + ETL_CONSTEXPR basic_format_spec() + : base_(10U) + , width_(0U) + , precision_(0U) + , upper_case_(false) + , left_justified_(false) + , boolalpha_(false) + , show_base_(false) + , fill_(typename TString::value_type(' ')) { - clear(); } //*************************************************************************** /// Clears the format spec back to default. //*************************************************************************** - void clear() + ETL_CONSTEXPR void clear() { base_ = 10U; width_ = 0U; @@ -235,7 +242,7 @@ namespace etl /// Sets the base. /// \return A reference to the basic_format_spec. //*************************************************************************** - basic_format_spec& base(uint32_t b) + ETL_CONSTEXPR basic_format_spec& base(uint32_t b) { base_ = static_cast(b); return *this; @@ -245,7 +252,7 @@ namespace etl /// Sets the base to binary. /// \return A reference to the basic_format_spec. //*************************************************************************** - basic_format_spec& binary() + ETL_CONSTEXPR basic_format_spec& binary() { base(2); return *this; @@ -255,7 +262,7 @@ namespace etl /// Sets the base to octal. /// \return A reference to the basic_format_spec. //*************************************************************************** - basic_format_spec& octal() + ETL_CONSTEXPR basic_format_spec& octal() { base(8); return *this; @@ -265,7 +272,7 @@ namespace etl /// Sets the base to decimal. /// \return A reference to the basic_format_spec. //*************************************************************************** - basic_format_spec& decimal() + ETL_CONSTEXPR basic_format_spec& decimal() { base(10); return *this; @@ -275,7 +282,7 @@ namespace etl /// Sets the base to hex. /// \return A reference to the basic_format_spec. //*************************************************************************** - basic_format_spec& hex() + ETL_CONSTEXPR basic_format_spec& hex() { base(16); return *this; @@ -284,7 +291,7 @@ namespace etl //*************************************************************************** /// Gets the base. //*************************************************************************** - uint32_t get_base() const + ETL_CONSTEXPR uint32_t get_base() const { return base_; } @@ -293,7 +300,7 @@ namespace etl /// Sets the show base flag. /// \return A reference to the basic_format_spec. //*************************************************************************** - basic_format_spec& show_base(bool b) + ETL_CONSTEXPR basic_format_spec& show_base(bool b) { show_base_ = b; return *this; @@ -302,7 +309,7 @@ namespace etl //*************************************************************************** /// Gets the show base flag. //*************************************************************************** - bool is_show_base() const + ETL_CONSTEXPR bool is_show_base() const { return show_base_; } @@ -311,7 +318,7 @@ namespace etl /// Sets the width. /// \return A reference to the basic_format_spec. //*************************************************************************** - basic_format_spec& width(uint32_t w) + ETL_CONSTEXPR basic_format_spec& width(uint32_t w) { width_ = static_cast(w); return *this; @@ -320,7 +327,7 @@ namespace etl //*************************************************************************** /// Gets the width. //*************************************************************************** - uint32_t get_width() const + ETL_CONSTEXPR uint32_t get_width() const { return width_; } @@ -329,7 +336,7 @@ namespace etl /// Sets the precision. /// \return A reference to the basic_format_spec. //*************************************************************************** - basic_format_spec& precision(uint32_t p) + ETL_CONSTEXPR basic_format_spec& precision(uint32_t p) { precision_ = static_cast(p); return *this; @@ -338,7 +345,7 @@ namespace etl //*************************************************************************** /// Gets the precision. //*************************************************************************** - uint32_t get_precision() const + ETL_CONSTEXPR uint32_t get_precision() const { return precision_; } @@ -347,7 +354,7 @@ namespace etl /// Sets the upper case flag. /// \return A reference to the basic_format_spec. //*************************************************************************** - basic_format_spec& upper_case(bool u) + ETL_CONSTEXPR basic_format_spec& upper_case(bool u) { upper_case_ = u; return *this; @@ -356,7 +363,7 @@ namespace etl //*************************************************************************** /// Gets the upper case flag. //*************************************************************************** - bool is_upper_case() const + ETL_CONSTEXPR bool is_upper_case() const { return upper_case_; } @@ -365,7 +372,7 @@ namespace etl /// Sets the fill character. /// \return A reference to the basic_format_spec. //*************************************************************************** - basic_format_spec& fill(typename TString::value_type c) + ETL_CONSTEXPR basic_format_spec& fill(typename TString::value_type c) { fill_ = c; return *this; @@ -374,7 +381,7 @@ namespace etl //*************************************************************************** /// Gets the fill character. //*************************************************************************** - typename TString::value_type get_fill() const + ETL_CONSTEXPR typename TString::value_type get_fill() const { return fill_; } @@ -383,7 +390,7 @@ namespace etl /// Sets the left justify flag. /// \return A reference to the basic_format_spec. //*************************************************************************** - basic_format_spec& left() + ETL_CONSTEXPR basic_format_spec& left() { left_justified_ = true; return *this; @@ -392,7 +399,7 @@ namespace etl //*************************************************************************** /// Gets the left justify flag. //*************************************************************************** - bool is_left() const + ETL_CONSTEXPR bool is_left() const { return left_justified_; } @@ -401,7 +408,7 @@ namespace etl /// Sets the right justify flag. /// \return A reference to the basic_format_spec. //*************************************************************************** - basic_format_spec& right() + ETL_CONSTEXPR basic_format_spec& right() { left_justified_ = false; return *this; @@ -410,7 +417,7 @@ namespace etl //*************************************************************************** /// Gets the right justify flag. //*************************************************************************** - bool is_right() const + ETL_CONSTEXPR bool is_right() const { return !left_justified_; } @@ -419,7 +426,7 @@ namespace etl /// Sets the bool alpha flag. /// \return A reference to the basic_format_spec. //*************************************************************************** - basic_format_spec& boolalpha(bool b) + ETL_CONSTEXPR basic_format_spec& boolalpha(bool b) { boolalpha_ = b; return *this; @@ -428,7 +435,7 @@ namespace etl //*************************************************************************** /// Gets the boolalpha flag. //*************************************************************************** - bool is_boolalpha() const + ETL_CONSTEXPR bool is_boolalpha() const { return boolalpha_; } @@ -436,7 +443,7 @@ namespace etl //*************************************************************************** /// Equality operator. //*************************************************************************** - friend bool operator ==(const basic_format_spec& lhs, const basic_format_spec& rhs) + ETL_CONSTEXPR friend bool operator ==(const basic_format_spec& lhs, const basic_format_spec& rhs) { return (lhs.base_ == rhs.base_) && (lhs.width_ == rhs.width_) && @@ -451,7 +458,7 @@ namespace etl //*************************************************************************** /// Inequality operator. //*************************************************************************** - friend bool operator !=(const basic_format_spec& lhs, const basic_format_spec& rhs) + ETL_CONSTEXPR friend bool operator !=(const basic_format_spec& lhs, const basic_format_spec& rhs) { return !(lhs == rhs); } diff --git a/include/etl/math_constants.h b/include/etl/math_constants.h index bc76cfcd..29595399 100644 --- a/include/etl/math_constants.h +++ b/include/etl/math_constants.h @@ -35,16 +35,16 @@ namespace etl { namespace math { - const double pi = 3.14159265358979; - const double pi_reciprocal = 0.31830988618379; - const double pi_squared = 9.86960440108936; - const double e = 2.71828182845905; - const double e_reciprocal = 0.36787944117144; - const double e_squared = 7.38905609893065; - const double root2 = 1.41421356237310; - const double root2_reciprocal = 0.70710678118655; - const double euler = 0.57721566490153; - const double golden_ratio = 1.61803398874989; + ETL_CONSTANT double pi = 3.14159265358979; + ETL_CONSTANT double pi_reciprocal = 0.31830988618379; + ETL_CONSTANT double pi_squared = 9.86960440108936; + ETL_CONSTANT double e = 2.71828182845905; + ETL_CONSTANT double e_reciprocal = 0.36787944117144; + ETL_CONSTANT double e_squared = 7.38905609893065; + ETL_CONSTANT double root2 = 1.41421356237310; + ETL_CONSTANT double root2_reciprocal = 0.70710678118655; + ETL_CONSTANT double euler = 0.57721566490153; + ETL_CONSTANT double golden_ratio = 1.61803398874989; } } diff --git a/test/test_format_spec.cpp b/test/test_format_spec.cpp new file mode 100644 index 00000000..471ab91b --- /dev/null +++ b/test/test_format_spec.cpp @@ -0,0 +1,105 @@ +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2019 jwellbelove + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files(the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions : + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +******************************************************************************/ + +#include "UnitTest++/UnitTest++.h" + +#include +#include +#include + +#include "etl/format_spec.h" +#include "etl/wformat_spec.h" +#include "etl/u16format_spec.h" +#include "etl/u32format_spec.h" + +namespace +{ + SUITE(test_format_spec) + { + //************************************************************************* + TEST(test_default_format) + { + etl::format_spec format; + + CHECK_EQUAL(10, format.get_base()); + CHECK_EQUAL(' ', format.get_fill()); + CHECK_EQUAL(0, format.get_precision()); + CHECK_EQUAL(0, format.get_width()); + CHECK_EQUAL(false, format.is_boolalpha()); + CHECK_EQUAL(false, format.is_left()); + CHECK_EQUAL(true, format.is_right()); + CHECK_EQUAL(false, format.is_show_base()); + CHECK_EQUAL(false, format.is_upper_case()); + } + + //************************************************************************* + TEST(test_format) + { + etl::format_spec format; + + format.base(16).boolalpha(true).fill('?').left().precision(6).show_base(true).upper_case(true).width(10); + + CHECK_EQUAL(16, format.get_base()); + CHECK_EQUAL('?', format.get_fill()); + CHECK_EQUAL(6, format.get_precision()); + CHECK_EQUAL(10, format.get_width()); + CHECK_EQUAL(true, format.is_boolalpha()); + CHECK_EQUAL(true, format.is_left()); + CHECK_EQUAL(false, format.is_right()); + CHECK_EQUAL(true, format.is_show_base()); + CHECK_EQUAL(true, format.is_upper_case()); + } + + //************************************************************************* + TEST(test_format_constexpr) + { + constexpr etl::format_spec format = etl::format_spec().base(16).boolalpha(true).fill('?').left().precision(6).show_base(true).upper_case(true).width(10); + + constexpr int base = format.get_base(); + constexpr char fill = format.get_fill(); + constexpr int precision = format.get_precision(); + constexpr int width = format.get_width(); + constexpr bool boolalpha = format.is_boolalpha(); + constexpr bool left = format.is_left(); + constexpr bool right = format.is_right(); + constexpr bool show_base = format.is_show_base(); + constexpr bool upper_case = format.is_upper_case(); + + CHECK_EQUAL(16, base); + CHECK_EQUAL('?', fill); + CHECK_EQUAL(6, precision); + CHECK_EQUAL(10, width); + CHECK_EQUAL(true, boolalpha); + CHECK_EQUAL(true, left); + CHECK_EQUAL(false, right); + CHECK_EQUAL(true, show_base); + CHECK_EQUAL(true, upper_case); + } + }; +} + diff --git a/test/vs2019/etl.vcxproj b/test/vs2019/etl.vcxproj index 4323d358..2c947ac9 100644 --- a/test/vs2019/etl.vcxproj +++ b/test/vs2019/etl.vcxproj @@ -1515,6 +1515,7 @@ + diff --git a/test/vs2019/etl.vcxproj.filters b/test/vs2019/etl.vcxproj.filters index 198c3ed2..36af486d 100644 --- a/test/vs2019/etl.vcxproj.filters +++ b/test/vs2019/etl.vcxproj.filters @@ -1424,6 +1424,9 @@ Source Files + + Source Files + From a5ca678b77db8000279e9620dfa79e27ab77d15a Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Thu, 26 Nov 2020 19:33:12 +0000 Subject: [PATCH 17/19] Squashed commit of the following: commit 638cceaf9c4a6964e58894adb36d633b01a1d5ac Author: John Wellbelove Date: Wed Nov 25 17:57:06 2020 +0000 Strings inherit secure status on copy. commit 5f1ab55c61ed62b5c234b5e1d6ac3ef362b78851 Author: John Wellbelove Date: Tue Nov 24 22:33:08 2020 +0000 Squashed commit of the following: commit dceb56dd1a19be6fe9b991bb50e08902eefe36a8 Author: John Wellbelove Date: Tue Nov 24 19:27:18 2020 +0000 Fixed non-initialisation of in_use flag. commit c7ee1d6574ca5d95869152c5f8e4e6d02a7fa6bc Author: John Wellbelove Date: Tue Nov 24 19:20:24 2020 +0000 Fixed non-initialisation of in_use flag. commit 36cbf21cd1b67a28255582cfb4a188a601631ab2 Author: John Wellbelove Date: Tue Nov 24 18:52:53 2020 +0000 Refactor buffer_descriptors test commit 49c60add63153bf53f400a891d8c4fb880cacda8 Author: John Wellbelove Date: Tue Nov 24 18:44:42 2020 +0000 Refactor buffer_descriptors test commit 7bda7678311bf2eb497483f3ef27c3af9211680b Author: John Wellbelove Date: Tue Nov 24 18:29:02 2020 +0000 Refactor buffer_descriptors test commit 7a68c932a7df05f66690fa63e67365cf4b0619e8 Author: John Wellbelove Date: Tue Nov 24 18:14:30 2020 +0000 Refactor buffer_descriptors test commit a9b25ac67d175f58751a2eb819f0e5822e8f0cf9 Author: John Wellbelove Date: Tue Nov 24 18:08:21 2020 +0000 Refactor buffer_descriptors test commit 0c721c0466733751708fcbd995ce0bc1d7c0a932 Author: John Wellbelove Date: Tue Nov 24 17:58:22 2020 +0000 Refactor buffer_descriptors test commit 4b2dd2fce22cd0a4846b95695fbfd812e0823540 Author: John Wellbelove Date: Tue Nov 24 17:47:43 2020 +0000 Refactor buffer_descriptors test commit 80d5776c409b416377269d543bd539bdad83dc86 Author: John Wellbelove Date: Tue Nov 24 17:32:27 2020 +0000 Refactor buffer_descriptors test commit 3564ac5b7ef89c41b240d9f54fce36042408daa0 Author: John Wellbelove Date: Tue Nov 24 17:17:50 2020 +0000 Refactor buffer_descriptors test commit 297ef42c60e4228bfbcb2adcddeb6b8a617c4113 Author: John Wellbelove Date: Tue Nov 24 17:08:45 2020 +0000 Refactor buffer_descriptors test commit 658d592c96eb7eaf1afb5d09fef38e293ea6f79b Author: John Wellbelove Date: Tue Nov 24 16:58:52 2020 +0000 Refactor buffer_descriptors test commit e97d8f90d5527349324ea84fd578c1d879d7a5a4 Author: John Wellbelove Date: Tue Nov 24 16:48:52 2020 +0000 Refactor buffer_descriptors test commit ed783a8ccccc8673c0f55eb1780c08668880a745 Author: John Wellbelove Date: Tue Nov 24 16:43:52 2020 +0000 clang.yml hack for testing commit c26e42253f4502c3afb943a7ff1f7ef0f79c475b Author: John Wellbelove Date: Tue Nov 24 19:32:48 2020 +0000 Squashed commit of the following: commit dceb56dd1a19be6fe9b991bb50e08902eefe36a8 Author: John Wellbelove Date: Tue Nov 24 19:27:18 2020 +0000 Fixed non-initialisation of in_use flag. commit c7ee1d6574ca5d95869152c5f8e4e6d02a7fa6bc Author: John Wellbelove Date: Tue Nov 24 19:20:24 2020 +0000 Fixed non-initialisation of in_use flag. commit 36cbf21cd1b67a28255582cfb4a188a601631ab2 Author: John Wellbelove Date: Tue Nov 24 18:52:53 2020 +0000 Refactor buffer_descriptors test commit 49c60add63153bf53f400a891d8c4fb880cacda8 Author: John Wellbelove Date: Tue Nov 24 18:44:42 2020 +0000 Refactor buffer_descriptors test commit 7bda7678311bf2eb497483f3ef27c3af9211680b Author: John Wellbelove Date: Tue Nov 24 18:29:02 2020 +0000 Refactor buffer_descriptors test commit 7a68c932a7df05f66690fa63e67365cf4b0619e8 Author: John Wellbelove Date: Tue Nov 24 18:14:30 2020 +0000 Refactor buffer_descriptors test commit a9b25ac67d175f58751a2eb819f0e5822e8f0cf9 Author: John Wellbelove Date: Tue Nov 24 18:08:21 2020 +0000 Refactor buffer_descriptors test commit 0c721c0466733751708fcbd995ce0bc1d7c0a932 Author: John Wellbelove Date: Tue Nov 24 17:58:22 2020 +0000 Refactor buffer_descriptors test commit 4b2dd2fce22cd0a4846b95695fbfd812e0823540 Author: John Wellbelove Date: Tue Nov 24 17:47:43 2020 +0000 Refactor buffer_descriptors test commit 80d5776c409b416377269d543bd539bdad83dc86 Author: John Wellbelove Date: Tue Nov 24 17:32:27 2020 +0000 Refactor buffer_descriptors test commit 3564ac5b7ef89c41b240d9f54fce36042408daa0 Author: John Wellbelove Date: Tue Nov 24 17:17:50 2020 +0000 Refactor buffer_descriptors test commit 297ef42c60e4228bfbcb2adcddeb6b8a617c4113 Author: John Wellbelove Date: Tue Nov 24 17:08:45 2020 +0000 Refactor buffer_descriptors test commit 658d592c96eb7eaf1afb5d09fef38e293ea6f79b Author: John Wellbelove Date: Tue Nov 24 16:58:52 2020 +0000 Refactor buffer_descriptors test commit e97d8f90d5527349324ea84fd578c1d879d7a5a4 Author: John Wellbelove Date: Tue Nov 24 16:48:52 2020 +0000 Refactor buffer_descriptors test commit ed783a8ccccc8673c0f55eb1780c08668880a745 Author: John Wellbelove Date: Tue Nov 24 16:43:52 2020 +0000 clang.yml hack for testing commit 3cbe1a80030263aac53616391fa434d0501f4f26 Author: John Wellbelove Date: Tue Nov 24 19:31:03 2020 +0000 Squashed commit of the following: commit dceb56dd1a19be6fe9b991bb50e08902eefe36a8 Author: John Wellbelove Date: Tue Nov 24 19:27:18 2020 +0000 Fixed non-initialisation of in_use flag. commit c7ee1d6574ca5d95869152c5f8e4e6d02a7fa6bc Author: John Wellbelove Date: Tue Nov 24 19:20:24 2020 +0000 Fixed non-initialisation of in_use flag. commit 36cbf21cd1b67a28255582cfb4a188a601631ab2 Author: John Wellbelove Date: Tue Nov 24 18:52:53 2020 +0000 Refactor buffer_descriptors test commit 49c60add63153bf53f400a891d8c4fb880cacda8 Author: John Wellbelove Date: Tue Nov 24 18:44:42 2020 +0000 Refactor buffer_descriptors test commit 7bda7678311bf2eb497483f3ef27c3af9211680b Author: John Wellbelove Date: Tue Nov 24 18:29:02 2020 +0000 Refactor buffer_descriptors test commit 7a68c932a7df05f66690fa63e67365cf4b0619e8 Author: John Wellbelove Date: Tue Nov 24 18:14:30 2020 +0000 Refactor buffer_descriptors test commit a9b25ac67d175f58751a2eb819f0e5822e8f0cf9 Author: John Wellbelove Date: Tue Nov 24 18:08:21 2020 +0000 Refactor buffer_descriptors test commit 0c721c0466733751708fcbd995ce0bc1d7c0a932 Author: John Wellbelove Date: Tue Nov 24 17:58:22 2020 +0000 Refactor buffer_descriptors test commit 4b2dd2fce22cd0a4846b95695fbfd812e0823540 Author: John Wellbelove Date: Tue Nov 24 17:47:43 2020 +0000 Refactor buffer_descriptors test commit 80d5776c409b416377269d543bd539bdad83dc86 Author: John Wellbelove Date: Tue Nov 24 17:32:27 2020 +0000 Refactor buffer_descriptors test commit 3564ac5b7ef89c41b240d9f54fce36042408daa0 Author: John Wellbelove Date: Tue Nov 24 17:17:50 2020 +0000 Refactor buffer_descriptors test commit 297ef42c60e4228bfbcb2adcddeb6b8a617c4113 Author: John Wellbelove Date: Tue Nov 24 17:08:45 2020 +0000 Refactor buffer_descriptors test commit 658d592c96eb7eaf1afb5d09fef38e293ea6f79b Author: John Wellbelove Date: Tue Nov 24 16:58:52 2020 +0000 Refactor buffer_descriptors test commit e97d8f90d5527349324ea84fd578c1d879d7a5a4 Author: John Wellbelove Date: Tue Nov 24 16:48:52 2020 +0000 Refactor buffer_descriptors test commit ed783a8ccccc8673c0f55eb1780c08668880a745 Author: John Wellbelove Date: Tue Nov 24 16:43:52 2020 +0000 clang.yml hack for testing commit e939e6b15557544bd0bb88d9862b5d5711170859 Author: John Wellbelove Date: Tue Nov 24 16:47:40 2020 +0000 Refactor buffer_descriptors test commit 4c4149abf6221f245aa4d73eb85e50319e7bd32c Author: John Wellbelove Date: Tue Nov 24 16:45:53 2020 +0000 clang hack for testing --- .gitignore | 2 ++ include/etl/basic_string.h | 25 ++++++++++++++++ include/etl/string.h | 30 +++----------------- include/etl/u16string.h | 30 +++----------------- include/etl/u32string.h | 30 +++----------------- include/etl/wstring.h | 30 +++----------------- test/test_string_char.cpp | 19 +++++++++++++ test/test_string_char_external_buffer.cpp | 22 ++++++++++++++ test/test_string_u16.cpp | 18 ++++++++++++ test/test_string_u16_external_buffer.cpp | 22 ++++++++++++++ test/test_string_u32.cpp | 18 ++++++++++++ test/test_string_u32_external_buffer.cpp | 25 +++++++++------- test/test_string_wchar_t.cpp | 18 ++++++++++++ test/test_string_wchar_t_external_buffer.cpp | 25 +++++++++------- test/vs2019/.leu | 1 - 15 files changed, 190 insertions(+), 125 deletions(-) delete mode 100644 test/vs2019/.leu diff --git a/.gitignore b/.gitignore index 6a8c9f5c..806bcd81 100644 --- a/.gitignore +++ b/.gitignore @@ -275,3 +275,5 @@ test/random_xorshift.csv test/cmake_install.cmake test/Makefile test/vs2019/enc_temp_folder +test/vs2019/.leu +test/etl_test_log.txt diff --git a/include/etl/basic_string.h b/include/etl/basic_string.h index 4f4df6d2..17023675 100644 --- a/include/etl/basic_string.h +++ b/include/etl/basic_string.h @@ -602,6 +602,13 @@ namespace etl } #endif +#if ETL_STRING_CLEAR_AFTER_USE_ENABLED + if (other.is_secure()) + { + set_secure(); + } +#endif + cleanup(); } @@ -622,6 +629,24 @@ namespace etl ETL_ASSERT(subposition <= other.size(), ETL_ERROR(string_out_of_bounds)); assign(other.begin() + subposition, sublength); + +#if ETL_STRING_TRUNCATION_CHECKS_ENABLED + if (other.is_truncated()) + { + this->set_truncated(true); + +#if defined(ETL_STRING_TRUNCATION_IS_ERROR) + ETL_ALWAYS_ASSERT(ETL_ERROR(string_truncation)); +#endif + } +#endif + +#if ETL_STRING_CLEAR_AFTER_USE_ENABLED + if (other.is_secure()) + { + set_secure(); + } +#endif } //********************************************************************* diff --git a/include/etl/string.h b/include/etl/string.h index e7924371..361c2024 100644 --- a/include/etl/string.h +++ b/include/etl/string.h @@ -100,23 +100,12 @@ namespace etl ///\param position The position of the first character. ///\param length The number of characters. Default = npos. //************************************************************************* - string(const etl::istring& other, size_t position, size_t length_ = npos) + string(const etl::istring& other, size_t position, size_t length = npos) : istring(reinterpret_cast(&buffer), MAX_SIZE) { ETL_ASSERT(position < other.size(), ETL_ERROR(string_out_of_bounds)); - this->assign(other.begin() + position, other.begin() + position + length_); - -#if ETL_STRING_TRUNCATION_CHECKS_ENABLED - if (other.is_truncated()) - { - this->set_truncated(true); - -#if defined(ETL_STRING_TRUNCATION_IS_ERROR) - ETL_ALWAYS_ASSERT(ETL_ERROR(string_truncation)); -#endif - } -#endif + this->assign(other, position, length); } //************************************************************************* @@ -309,23 +298,12 @@ namespace etl ///\param position The position of the first character. ///\param length The number of characters. Default = npos. //************************************************************************* - string_ext(const etl::istring& other, value_type* buffer, size_type buffer_size, size_type position, size_type length_ = npos) + string_ext(const etl::istring& other, value_type* buffer, size_type buffer_size, size_type position, size_type length = npos) : istring(buffer, buffer_size - 1U) { ETL_ASSERT(position < other.size(), ETL_ERROR(string_out_of_bounds)); - this->assign(other.begin() + position, other.begin() + position + length_); - -#if ETL_STRING_TRUNCATION_CHECKS_ENABLED - if (other.is_truncated()) - { - this->set_truncated(true); - -#if defined(ETL_STRING_TRUNCATION_IS_ERROR) - ETL_ALWAYS_ASSERT(ETL_ERROR(string_truncation)); -#endif - } -#endif + this->assign(other, position, length); } //************************************************************************* diff --git a/include/etl/u16string.h b/include/etl/u16string.h index d3351a9d..e79d9219 100644 --- a/include/etl/u16string.h +++ b/include/etl/u16string.h @@ -98,23 +98,12 @@ namespace etl ///\param position The position of the first character. ///\param length The number of characters. Default = npos. //************************************************************************* - u16string(const etl::iu16string& other, size_type position, size_type length_ = npos) + u16string(const etl::iu16string& other, size_type position, size_type length = npos) : iu16string(reinterpret_cast(&buffer), MAX_SIZE) { ETL_ASSERT(position < other.size(), ETL_ERROR(string_out_of_bounds)); - this->assign(other.begin() + position, other.begin() + position + length_); - -#if ETL_STRING_TRUNCATION_CHECKS_ENABLED - if (other.is_truncated()) - { - this->set_truncated(true); - -#if defined(ETL_STRING_TRUNCATION_IS_ERROR) - ETL_ALWAYS_ASSERT(ETL_ERROR(string_truncation)); -#endif - } -#endif + this->assign(other, position, length); } //************************************************************************* @@ -292,23 +281,12 @@ namespace etl ///\param position The position of the first character. ///\param length The number of characters. Default = npos. //************************************************************************* - u16string_ext(const etl::iu16string& other, value_type* buffer, size_type buffer_size, size_type position, size_type length_ = npos) + u16string_ext(const etl::iu16string& other, value_type* buffer, size_type buffer_size, size_type position, size_type length = npos) : iu16string(buffer, buffer_size - 1U) { ETL_ASSERT(position < other.size(), ETL_ERROR(string_out_of_bounds)); - this->assign(other.begin() + position, other.begin() + position + length_); - -#if ETL_STRING_TRUNCATION_CHECKS_ENABLED - if (other.is_truncated()) - { - this->set_truncated(true); - -#if defined(ETL_STRING_TRUNCATION_IS_ERROR) - ETL_ALWAYS_ASSERT(ETL_ERROR(u16string_truncation)); -#endif - } -#endif + this->assign(other, position, length); } //************************************************************************* diff --git a/include/etl/u32string.h b/include/etl/u32string.h index 7a0ad002..40ab1ca1 100644 --- a/include/etl/u32string.h +++ b/include/etl/u32string.h @@ -98,23 +98,12 @@ namespace etl ///\param position The position of the first character. ///\param length The number of characters. Default = npos. //************************************************************************* - u32string(const etl::iu32string& other, size_type position, size_type length_ = npos) + u32string(const etl::iu32string& other, size_type position, size_type length = npos) : iu32string(reinterpret_cast(&buffer), MAX_SIZE) { ETL_ASSERT(position < other.size(), ETL_ERROR(string_out_of_bounds)); - this->assign(other.begin() + position, other.begin() + position + length_); - -#if ETL_STRING_TRUNCATION_CHECKS_ENABLED - if (other.is_truncated()) - { - this->set_truncated(true); - -#if defined(ETL_STRING_TRUNCATION_IS_ERROR) - ETL_ALWAYS_ASSERT(ETL_ERROR(string_truncation)); -#endif - } -#endif + this->assign(other, position, length); } //************************************************************************* @@ -292,23 +281,12 @@ namespace etl ///\param position The position of the first character. ///\param length The number of characters. Default = npos. //************************************************************************* - u32string_ext(const etl::iu32string& other, value_type* buffer, size_type buffer_size, size_type position, size_type length_ = npos) + u32string_ext(const etl::iu32string& other, value_type* buffer, size_type buffer_size, size_type position, size_type length = npos) : iu32string(buffer, buffer_size - 1U) { ETL_ASSERT(position < other.size(), ETL_ERROR(string_out_of_bounds)); - this->assign(other.begin() + position, other.begin() + position + length_); - -#if ETL_STRING_TRUNCATION_CHECKS_ENABLED - if (other.is_truncated()) - { - this->set_truncated(true); - -#if defined(ETL_STRING_TRUNCATION_IS_ERROR) - ETL_ALWAYS_ASSERT(ETL_ERROR(u32string_truncation)); -#endif - } -#endif + this->assign(other, position, length); } //************************************************************************* diff --git a/include/etl/wstring.h b/include/etl/wstring.h index a86b24b5..802e6dfb 100644 --- a/include/etl/wstring.h +++ b/include/etl/wstring.h @@ -98,23 +98,12 @@ namespace etl ///\param position The position of the first character. ///\param length The number of characters. Default = npos. //************************************************************************* - wstring(const etl::iwstring& other, size_type position, size_type length_ = npos) + wstring(const etl::iwstring& other, size_type position, size_type length = npos) : iwstring(reinterpret_cast(&buffer), MAX_SIZE) { ETL_ASSERT(position < other.size(), ETL_ERROR(string_out_of_bounds)); - this->assign(other.begin() + position, other.begin() + position + length_); - -#if ETL_STRING_TRUNCATION_CHECKS_ENABLED - if (other.is_truncated()) - { - this->set_truncated(true); - -#if defined(ETL_STRING_TRUNCATION_IS_ERROR) - ETL_ALWAYS_ASSERT(ETL_ERROR(string_truncation)); -#endif - } -#endif + this->assign(other, position, length); } //************************************************************************* @@ -292,23 +281,12 @@ namespace etl ///\param position The position of the first character. ///\param length The number of characters. Default = npos. //************************************************************************* - wstring_ext(const etl::iwstring& other, value_type* buffer, size_type buffer_size, size_type position, size_type length_ = npos) + wstring_ext(const etl::iwstring& other, value_type* buffer, size_type buffer_size, size_type position, size_type length = npos) : iwstring(buffer, buffer_size - 1U) { ETL_ASSERT(position < other.size(), ETL_ERROR(string_out_of_bounds)); - this->assign(other.begin() + position, other.begin() + position + length_); - -#if ETL_STRING_TRUNCATION_CHECKS_ENABLED - if (other.is_truncated()) - { - this->set_truncated(true); - -#if defined(ETL_STRING_TRUNCATION_IS_ERROR) - ETL_ALWAYS_ASSERT(ETL_ERROR(wstring_truncation)); -#endif - } -#endif + this->assign(other, position, length); } //************************************************************************* diff --git a/test/test_string_char.cpp b/test/test_string_char.cpp index 786cb44b..01e1a32f 100644 --- a/test/test_string_char.cpp +++ b/test/test_string_char.cpp @@ -4138,6 +4138,25 @@ namespace // Check there no non-zero values in the remainder of the string. CHECK(std::find_if(pb, pe, [](Text::value_type x) { return x != 0; }) == pe); } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_secure_flag_after_copy) + { + Text text1 = STR("Hello World"); + text1.set_secure(); + + Text text2(text1); + + Text text3; + text3 = text1; + + Text text4(text1, 6U, 3U); + + CHECK(text2.is_secure()); + CHECK(text3.is_secure()); + CHECK(text4.is_secure()); + } + #endif }; } diff --git a/test/test_string_char_external_buffer.cpp b/test/test_string_char_external_buffer.cpp index 69bd1674..3a3d35d4 100644 --- a/test/test_string_char_external_buffer.cpp +++ b/test/test_string_char_external_buffer.cpp @@ -4496,6 +4496,28 @@ namespace // Check there no non-zero values in the remainder of the string. CHECK(std::find_if(pb, pe, [](Text::value_type x) { return x != 0; }) == pe); } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_secure_flag_after_copy) + { + TextBuffer buffer1; + Text text1(STR("Hello World"), buffer1.data(), buffer1.size()); + text1.set_secure(); + + TextBuffer buffer2; + Text text2(text1, buffer2.data(), buffer2.size()); + + TextBuffer buffer3; + Text text3(buffer3.data(), buffer3.size()); + text3 = text1; + + TextBuffer buffer4; + Text text4(text1, buffer4.data(), buffer4.size(), 6U, 2U); + + CHECK(text2.is_secure()); + CHECK(text3.is_secure()); + CHECK(text4.is_secure()); + } #endif }; } diff --git a/test/test_string_u16.cpp b/test/test_string_u16.cpp index ea4031ff..379d18bf 100644 --- a/test/test_string_u16.cpp +++ b/test/test_string_u16.cpp @@ -4138,6 +4138,24 @@ namespace // Check there no non-zero values in the remainder of the string. CHECK(std::find_if(pb, pe, [](Text::value_type x) { return x != 0; }) == pe); } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_secure_flag_after_copy) + { + Text text1 = STR("Hello World"); + text1.set_secure(); + + Text text2(text1); + + Text text3; + text3 = text1; + + Text text4(text1, 6U, 3U); + + CHECK(text2.is_secure()); + CHECK(text3.is_secure()); + CHECK(text4.is_secure()); + } #endif }; } diff --git a/test/test_string_u16_external_buffer.cpp b/test/test_string_u16_external_buffer.cpp index d3339e61..4673ab2c 100644 --- a/test/test_string_u16_external_buffer.cpp +++ b/test/test_string_u16_external_buffer.cpp @@ -4496,6 +4496,28 @@ namespace // Check there no non-zero values in the remainder of the string. CHECK(std::find_if(pb, pe, [](Text::value_type x) { return x != 0; }) == pe); } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_secure_flag_after_copy) + { + TextBuffer buffer1; + Text text1(STR("Hello World"), buffer1.data(), buffer1.size()); + text1.set_secure(); + + TextBuffer buffer2; + Text text2(text1, buffer2.data(), buffer2.size()); + + TextBuffer buffer3; + Text text3(buffer3.data(), buffer3.size()); + text3 = text1; + + TextBuffer buffer4; + Text text4(text1, buffer4.data(), buffer4.size(), 6U, 2U); + + CHECK(text2.is_secure()); + CHECK(text3.is_secure()); + CHECK(text4.is_secure()); + } #endif }; } diff --git a/test/test_string_u32.cpp b/test/test_string_u32.cpp index ab3e7775..4e011676 100644 --- a/test/test_string_u32.cpp +++ b/test/test_string_u32.cpp @@ -4138,6 +4138,24 @@ namespace // Check there no non-zero values in the remainder of the string. CHECK(std::find_if(pb, pe, [](Text::value_type x) { return x != 0; }) == pe); } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_secure_flag_after_copy) + { + Text text1 = STR("Hello World"); + text1.set_secure(); + + Text text2(text1); + + Text text3; + text3 = text1; + + Text text4(text1, 6U, 3U); + + CHECK(text2.is_secure()); + CHECK(text3.is_secure()); + CHECK(text4.is_secure()); + } #endif }; } diff --git a/test/test_string_u32_external_buffer.cpp b/test/test_string_u32_external_buffer.cpp index e4343826..859dbfcf 100644 --- a/test/test_string_u32_external_buffer.cpp +++ b/test/test_string_u32_external_buffer.cpp @@ -4481,20 +4481,25 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_secure_after_clear) + TEST_FIXTURE(SetupFixture, test_secure_flag_after_copy) { - TextBuffer buffer; - Text text(buffer.data(), buffer.size()); - text.set_secure(); - text.assign(STR("ABCDEF")); + TextBuffer buffer1; + Text text1(STR("Hello World"), buffer1.data(), buffer1.size()); + text1.set_secure(); - Text::pointer pb = text.begin(); - Text::pointer pe = text.end(); + TextBuffer buffer2; + Text text2(text1, buffer2.data(), buffer2.size()); - text.clear(); + TextBuffer buffer3; + Text text3(buffer3.data(), buffer3.size()); + text3 = text1; - // Check there no non-zero values in the remainder of the string. - CHECK(std::find_if(pb, pe, [](Text::value_type x) { return x != 0; }) == pe); + TextBuffer buffer4; + Text text4(text1, buffer4.data(), buffer4.size(), 6U, 2U); + + CHECK(text2.is_secure()); + CHECK(text3.is_secure()); + CHECK(text4.is_secure()); } #endif }; diff --git a/test/test_string_wchar_t.cpp b/test/test_string_wchar_t.cpp index 7b4d096b..26cbde56 100644 --- a/test/test_string_wchar_t.cpp +++ b/test/test_string_wchar_t.cpp @@ -4138,6 +4138,24 @@ namespace // Check there no non-zero values in the remainder of the string. CHECK(std::find_if(pb, pe, [](Text::value_type x) { return x != 0; }) == pe); } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_secure_flag_after_copy) + { + Text text1 = STR("Hello World"); + text1.set_secure(); + + Text text2(text1); + + Text text3; + text3 = text1; + + Text text4(text1, 6U, 3U); + + CHECK(text2.is_secure()); + CHECK(text3.is_secure()); + CHECK(text4.is_secure()); + } #endif }; } diff --git a/test/test_string_wchar_t_external_buffer.cpp b/test/test_string_wchar_t_external_buffer.cpp index ed1bceb9..009a48bf 100644 --- a/test/test_string_wchar_t_external_buffer.cpp +++ b/test/test_string_wchar_t_external_buffer.cpp @@ -4481,20 +4481,25 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_secure_after_clear) + TEST_FIXTURE(SetupFixture, test_secure_flag_after_copy) { - TextBuffer buffer; - Text text(buffer.data(), buffer.size()); - text.set_secure(); - text.assign(STR("ABCDEF")); + TextBuffer buffer1; + Text text1(STR("Hello World"), buffer1.data(), buffer1.size()); + text1.set_secure(); - Text::pointer pb = text.begin(); - Text::pointer pe = text.end(); + TextBuffer buffer2; + Text text2(text1, buffer2.data(), buffer2.size()); - text.clear(); + TextBuffer buffer3; + Text text3(buffer3.data(), buffer3.size()); + text3 = text1; - // Check there no non-zero values in the remainder of the string. - CHECK(std::find_if(pb, pe, [](Text::value_type x) { return x != 0; }) == pe); + TextBuffer buffer4; + Text text4(text1, buffer4.data(), buffer4.size(), 6U, 2U); + + CHECK(text2.is_secure()); + CHECK(text3.is_secure()); + CHECK(text4.is_secure()); } #endif }; diff --git a/test/vs2019/.leu b/test/vs2019/.leu deleted file mode 100644 index 2c966fa9..00000000 --- a/test/vs2019/.leu +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file From 26a797381c34721d3fee16571b7206a71c65e25b Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Fri, 27 Nov 2020 08:59:28 +0000 Subject: [PATCH 18/19] Added AVR compile time switch --- include/etl/nullptr.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/etl/nullptr.h b/include/etl/nullptr.h index a661288f..2e200787 100644 --- a/include/etl/nullptr.h +++ b/include/etl/nullptr.h @@ -33,7 +33,7 @@ SOFTWARE. #include "platform.h" -#if defined(ARDUINO) +#if defined(ARDUINO) || defined(AVR) #include #else #include From 4e4aed118a5d802df7a9bd4baf28adba62c2b2d6 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Fri, 27 Nov 2020 09:13:49 +0000 Subject: [PATCH 19/19] Updated version numbers --- include/etl/version.h | 2 +- library.json | 2 +- library.properties | 2 +- support/Release notes.txt | 6 ++++++ 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/include/etl/version.h b/include/etl/version.h index 64d6a44a..bce0a92e 100644 --- a/include/etl/version.h +++ b/include/etl/version.h @@ -38,7 +38,7 @@ SOFTWARE. ///\ingroup utilities #define ETL_VERSION_MAJOR 19 -#define ETL_VERSION_MINOR 1 +#define ETL_VERSION_MINOR 2 #define ETL_VERSION_PATCH 0 #define ETL_VERSION ETL_STRINGIFY(ETL_VERSION_MAJOR) "." ETL_STRINGIFY(ETL_VERSION_MINOR) "." ETL_STRINGIFY(ETL_VERSION_PATCH) #define ETL_VERSION_W ETL_STRINGIFY(ETL_VERSION_MAJOR) L"." ETL_STRINGIFY(ETL_VERSION_MINOR) L"." ETL_STRINGIFY(ETL_VERSION_PATCH) diff --git a/library.json b/library.json index 32bead34..28ed610d 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "Embedded Template Library", - "version": "19.1.0", + "version": "19.2.0", "author s": { "name": "John Wellbelove", "email": "john.wellbelove@etlcpp.com" diff --git a/library.properties b/library.properties index d91061e6..3625eedf 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Embedded Template Library -version=19.1.0 +version=19.2.0 author= John Wellbelove maintainer=John Wellbelove license=MIT diff --git a/support/Release notes.txt b/support/Release notes.txt index c0f99551..7b0bb26e 100644 --- a/support/Release notes.txt +++ b/support/Release notes.txt @@ -1,3 +1,9 @@ +=============================================================================== +19.2.0 +Security flag for a string is copied on assignment or copy constructor. +etl::format_spec may now be a constexpr. +Added AVR check to nullptr.h + =============================================================================== 19.1.0 Refactor of etl::buffer_descriptors interface.