From b59d4727927e73ae121ace5d91889503bcd92b6b Mon Sep 17 00:00:00 2001 From: ckormanyos Date: Sun, 29 Sep 2024 09:44:59 +0200 Subject: [PATCH 1/4] Clean up and add more fuzzing --- .github/workflows/wide_integer_fuzzing.yml | 4 +- test/fuzzing/test_fuzzing_add.cpp | 6 +- test/fuzzing/test_fuzzing_div.cpp | 6 +- test/fuzzing/test_fuzzing_mul.cpp | 6 +- test/fuzzing/test_fuzzing_powm.cpp | 148 +++++++++++++++++++++ test/fuzzing/test_fuzzing_prime.cpp | 6 +- test/fuzzing/test_fuzzing_sdiv.cpp | 4 +- test/fuzzing/test_fuzzing_sqrt.cpp | 4 +- test/fuzzing/test_fuzzing_sub.cpp | 6 +- wide_integer_vs2022.vcxproj | 8 +- wide_integer_vs2022.vcxproj.filters | 5 +- 11 files changed, 180 insertions(+), 23 deletions(-) create mode 100644 test/fuzzing/test_fuzzing_powm.cpp diff --git a/.github/workflows/wide_integer_fuzzing.yml b/.github/workflows/wide_integer_fuzzing.yml index bf983b4..8bd448d 100644 --- a/.github/workflows/wide_integer_fuzzing.yml +++ b/.github/workflows/wide_integer_fuzzing.yml @@ -22,7 +22,7 @@ jobs: strategy: fail-fast: false matrix: - tcase: [ add, sub, mul, div, prime, sdiv, sqrt ] + tcase: [ add, sub, mul, div, powm, prime, sdiv, sqrt ] steps: - uses: actions/checkout@v4 with: @@ -43,7 +43,7 @@ jobs: grep BOOST_VERSION ../boost-root/boost/version.hpp echo "compile and instrument fuzzing test" clang++ -v - clang++ -std=c++20 -g -O2 -fsanitize=fuzzer -I. -I../boost-root test/fuzzing/test_fuzzing_${{ matrix.tcase }}.cpp -o test_fuzzing_${{ matrix.tcase }} + clang++ -std=c++20 -g -O2 -Wall -Wextra -fsanitize=fuzzer -I. -I../boost-root test/fuzzing/test_fuzzing_${{ matrix.tcase }}.cpp -o test_fuzzing_${{ matrix.tcase }} echo "ls test_fuzzing_${{ matrix.tcase }}" ls -la test_fuzzing_${{ matrix.tcase }} ./test_fuzzing_${{ matrix.tcase }} -max_total_time=360 diff --git a/test/fuzzing/test_fuzzing_add.cpp b/test/fuzzing/test_fuzzing_add.cpp index a597d37..33fa29a 100644 --- a/test/fuzzing/test_fuzzing_add.cpp +++ b/test/fuzzing/test_fuzzing_add.cpp @@ -6,7 +6,7 @@ // // cd /mnt/c/Users/ckorm/Documents/Ks/PC_Software/NumericalPrograms/ExtendedNumberTypes/wide_integer -// clang++ -std=c++20 -g -O2 -fsanitize=fuzzer -I. -I/mnt/c/boost/boost_1_85_0 test/fuzzing/test_fuzzing_add.cpp -o test_fuzzing_add +// clang++ -std=c++20 -g -O2 -Wall -Wextra -fsanitize=fuzzer -I. -I/mnt/c/boost/boost_1_85_0 test/fuzzing/test_fuzzing_add.cpp -o test_fuzzing_add // ./test_fuzzing_add -max_total_time=300 #include @@ -55,7 +55,7 @@ auto fuzzing::eval_op(const std::uint8_t* data, std::size_t size) -> bool boost_uint_type a_boost { 0U }; boost_uint_type b_boost { 0U }; - // Import data into their respective uintwide_t a and b values. + // Import data into the uintwide_t values. import_bits ( a_local, @@ -72,7 +72,7 @@ auto fuzzing::eval_op(const std::uint8_t* data, std::size_t size) -> bool 8U ); - // Import data into their respective boost-based a and b values. + // Import data into the boost values. import_bits ( a_boost, diff --git a/test/fuzzing/test_fuzzing_div.cpp b/test/fuzzing/test_fuzzing_div.cpp index b261324..ba6bafb 100644 --- a/test/fuzzing/test_fuzzing_div.cpp +++ b/test/fuzzing/test_fuzzing_div.cpp @@ -6,7 +6,7 @@ // // cd /mnt/c/Users/ckorm/Documents/Ks/PC_Software/NumericalPrograms/ExtendedNumberTypes/wide_integer -// clang++ -std=c++20 -g -O2 -fsanitize=fuzzer -I. -I/mnt/c/boost/boost_1_85_0 test/fuzzing/test_fuzzing_div.cpp -o test_fuzzing_div +// clang++ -std=c++20 -g -O2 -Wall -Wextra -fsanitize=fuzzer -I. -I/mnt/c/boost/boost_1_85_0 test/fuzzing/test_fuzzing_div.cpp -o test_fuzzing_div // ./test_fuzzing_div -max_total_time=300 #include @@ -55,7 +55,7 @@ auto fuzzing::eval_op(const std::uint8_t* data, std::size_t size) -> bool boost_uint_type a_boost { 0U }; boost_uint_type b_boost { 0U }; - // Import data into their respective uintwide_t a and b values. + // Import data into the uintwide_t values. import_bits ( a_local, @@ -72,7 +72,7 @@ auto fuzzing::eval_op(const std::uint8_t* data, std::size_t size) -> bool 8U ); - // Import data into their respective boost-based a and b values. + // Import data into the boost values. import_bits ( a_boost, diff --git a/test/fuzzing/test_fuzzing_mul.cpp b/test/fuzzing/test_fuzzing_mul.cpp index e826b81..a1e601d 100644 --- a/test/fuzzing/test_fuzzing_mul.cpp +++ b/test/fuzzing/test_fuzzing_mul.cpp @@ -6,7 +6,7 @@ // // cd /mnt/c/Users/ckorm/Documents/Ks/PC_Software/NumericalPrograms/ExtendedNumberTypes/wide_integer -// clang++ -std=c++20 -g -O2 -fsanitize=fuzzer -I. -I/mnt/c/boost/boost_1_85_0 test/fuzzing/test_fuzzing_mul.cpp -o test_fuzzing_mul +// clang++ -std=c++20 -g -O2 -Wall -Wextra -fsanitize=fuzzer -I. -I/mnt/c/boost/boost_1_85_0 test/fuzzing/test_fuzzing_mul.cpp -o test_fuzzing_mul // ./test_fuzzing_mul -max_total_time=300 #include @@ -55,7 +55,7 @@ auto fuzzing::eval_op(const std::uint8_t* data, std::size_t size) -> bool boost_uint_type a_boost { 0U }; boost_uint_type b_boost { 0U }; - // Import data into their respective uintwide_t a and b values. + // Import data into the uintwide_t values. import_bits ( a_local, @@ -72,7 +72,7 @@ auto fuzzing::eval_op(const std::uint8_t* data, std::size_t size) -> bool 8U ); - // Import data into their respective boost-based a and b values. + // Import data into the boost values. import_bits ( a_boost, diff --git a/test/fuzzing/test_fuzzing_powm.cpp b/test/fuzzing/test_fuzzing_powm.cpp new file mode 100644 index 0000000..6bf275e --- /dev/null +++ b/test/fuzzing/test_fuzzing_powm.cpp @@ -0,0 +1,148 @@ +/////////////////////////////////////////////////////////////////////////////// +// Copyright Christopher Kormanyos 2024. +// 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) +// + +// cd /mnt/c/Users/ckorm/Documents/Ks/PC_Software/NumericalPrograms/ExtendedNumberTypes/wide_integer +// clang++ -std=c++20 -g -O2 -Wall -Wextra -fsanitize=fuzzer -I. -I/mnt/c/boost/boost_1_85_0 test/fuzzing/test_fuzzing_powm.cpp -o test_fuzzing_powm +// ./test_fuzzing_powm -max_total_time=300 + +#include + +#include + +#include +#include +#include +#include +#include + +namespace fuzzing +{ + using boost_uint_backend_type = + boost::multiprecision::cpp_int_backend(UINT32_C(256)), + static_cast(UINT32_C(256)), + boost::multiprecision::unsigned_magnitude>; + + using boost_uint_type = boost::multiprecision::number; + + using local_uint_type = ::math::wide_integer::uint256_t; + + auto eval_op(const std::uint8_t* data, std::size_t size) -> bool; +} + +auto fuzzing::eval_op(const std::uint8_t* data, std::size_t size) -> bool +{ + const std::size_t + max_size + { + static_cast + ( + std::numeric_limits::digits / 8 + ) + }; + + bool result_is_ok { true }; + + if((size > std::size_t { UINT8_C(6) }) && (size <= std::size_t { max_size * 3U })) + { + local_uint_type b_local { 0U }; + local_uint_type p_local { 0U }; + local_uint_type m_local { 0U }; + + boost_uint_type b_boost { 0U }; + boost_uint_type p_boost { 0U }; + boost_uint_type m_boost { 0U }; + + // Import data into the uintwide_t values. + import_bits + ( + b_local, + data, + data + std::size_t { size / 3U }, + 8U + ); + + import_bits + ( + p_local, + data + std::size_t { size / 3U }, + data + std::size_t { std::size_t { size * 2U } / 3U }, + 8U + ); + + import_bits + ( + m_local, + data + std::size_t { std::size_t { size * 2U } / 3U }, + data + size, + 8U + ); + + // Import data into the boost values. + import_bits + ( + b_boost, + data, + data + std::size_t { size / 3U }, + 8U + ); + + import_bits + ( + p_boost, + data + std::size_t { size / 3U }, + data + std::size_t { std::size_t { size * 2U } / 3U }, + 8U + ); + + import_bits + ( + m_boost, + data + std::size_t { std::size_t { size * 2U } / 3U }, + data + size, + 8U + ); + + if(m_local != 0U) + { + local_uint_type result_local { powm(b_local, p_local, m_local) }; + boost_uint_type result_boost { powm(b_boost, p_boost, m_boost) }; + + std::vector result_data_local(max_size, UINT8_C(0)); + std::vector result_data_boost(result_data_local.size(), UINT8_C(0)); + + export_bits(result_local, result_data_local.data(), 8U); + export_bits(result_boost, result_data_boost.data(), 8U); + + // Verify that both uintwide_t as well as boost obtain the same result. + const bool result_op_is_ok = + std::equal + ( + result_data_local.cbegin(), + result_data_local.cend(), + result_data_boost.cbegin(), + result_data_boost.cend() + ); + + result_is_ok = (result_op_is_ok && result_is_ok); + } + } + + // Assert the correct result. + assert(result_is_ok); + + return result_is_ok; +} + +// The fuzzing entry point. +extern "C" +int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + const bool result_one_div_is_ok { fuzzing::eval_op(data, size) }; + + return (result_one_div_is_ok ? 0 : -1); +} diff --git a/test/fuzzing/test_fuzzing_prime.cpp b/test/fuzzing/test_fuzzing_prime.cpp index dcf6c65..6376cd9 100644 --- a/test/fuzzing/test_fuzzing_prime.cpp +++ b/test/fuzzing/test_fuzzing_prime.cpp @@ -6,7 +6,7 @@ // // cd /mnt/c/Users/ckorm/Documents/Ks/PC_Software/NumericalPrograms/ExtendedNumberTypes/wide_integer -// clang++ -std=c++20 -g -O2 -fsanitize=fuzzer -I. -I/mnt/c/boost/boost_1_85_0 test/fuzzing/test_fuzzing_prime.cpp -o test_fuzzing_prime +// clang++ -std=c++20 -g -O2 -Wall -Wextra -fsanitize=fuzzer -I. -I/mnt/c/boost/boost_1_85_0 test/fuzzing/test_fuzzing_prime.cpp -o test_fuzzing_prime // ./test_fuzzing_prime -max_total_time=300 #include @@ -64,7 +64,7 @@ auto fuzzing::eval_op(const std::uint8_t* data, std::size_t size) -> bool local_uint_type p0 { 0U }; boost_uint_type pb { 0U }; - // Import the random data into the prime candidate. + // Import the data into the uintwide_t prime candidate. import_bits ( p0, @@ -73,7 +73,7 @@ auto fuzzing::eval_op(const std::uint8_t* data, std::size_t size) -> bool 8U ); - // Import the random data into the boost control prime candidate. + // Import the data into the boost prime candidate. import_bits ( pb, diff --git a/test/fuzzing/test_fuzzing_sdiv.cpp b/test/fuzzing/test_fuzzing_sdiv.cpp index f752e6e..981d2a0 100644 --- a/test/fuzzing/test_fuzzing_sdiv.cpp +++ b/test/fuzzing/test_fuzzing_sdiv.cpp @@ -6,7 +6,7 @@ // // cd /mnt/c/Users/ckorm/Documents/Ks/PC_Software/NumericalPrograms/ExtendedNumberTypes/wide_integer -// clang++ -std=c++20 -g -O2 -fsanitize=fuzzer -I. -I/mnt/c/boost/boost_1_85_0 test/fuzzing/test_fuzzing_sdiv.cpp -o test_fuzzing_sdiv +// clang++ -std=c++20 -g -O2 -Wall -Wextra -fsanitize=fuzzer -I. -I/mnt/c/boost/boost_1_85_0 test/fuzzing/test_fuzzing_sdiv.cpp -o test_fuzzing_sdiv // ./test_fuzzing_sdiv -max_total_time=300 #include @@ -84,7 +84,7 @@ auto fuzzing::eval_op(const std::uint8_t* data, std::size_t size) -> bool local_uint_type a_local { 0U }; local_uint_type b_local { 0U }; - // Import data into the uintwide_t a and b values. + // Import data into the uintwide_t values. import_bits ( a_local, diff --git a/test/fuzzing/test_fuzzing_sqrt.cpp b/test/fuzzing/test_fuzzing_sqrt.cpp index d4ea59d..9932c46 100644 --- a/test/fuzzing/test_fuzzing_sqrt.cpp +++ b/test/fuzzing/test_fuzzing_sqrt.cpp @@ -6,7 +6,7 @@ // // cd /mnt/c/Users/ckorm/Documents/Ks/PC_Software/NumericalPrograms/ExtendedNumberTypes/wide_integer -// clang++ -std=c++20 -g -O2 -fsanitize=fuzzer -I. -I/mnt/c/boost/boost_1_85_0 test/fuzzing/test_fuzzing_sqrt.cpp -o test_fuzzing_sqrt +// clang++ -std=c++20 -g -O2 -Wall -Wextra -fsanitize=fuzzer -I. -I/mnt/c/boost/boost_1_85_0 test/fuzzing/test_fuzzing_sqrt.cpp -o test_fuzzing_sqrt // ./test_fuzzing_sqrt -max_total_time=300 #include @@ -53,7 +53,7 @@ auto fuzzing::eval_op(const std::uint8_t* data, std::size_t size) -> bool { local_uint_type a_local { 0U }; - // Import data into the uintwide_t a and b values. + // Import data into the uintwide_t values. import_bits ( a_local, diff --git a/test/fuzzing/test_fuzzing_sub.cpp b/test/fuzzing/test_fuzzing_sub.cpp index 191b164..1a3518b 100644 --- a/test/fuzzing/test_fuzzing_sub.cpp +++ b/test/fuzzing/test_fuzzing_sub.cpp @@ -6,7 +6,7 @@ // // cd /mnt/c/Users/ckorm/Documents/Ks/PC_Software/NumericalPrograms/ExtendedNumberTypes/wide_integer -// clang++ -std=c++20 -g -O2 -fsanitize=fuzzer -I. -I/mnt/c/boost/boost_1_85_0 test/fuzzing/test_fuzzing_sub.cpp -o test_fuzzing_sub +// clang++ -std=c++20 -g -O2 -Wall -Wextra -fsanitize=fuzzer -I. -I/mnt/c/boost/boost_1_85_0 test/fuzzing/test_fuzzing_sub.cpp -o test_fuzzing_sub // ./test_fuzzing_sub -max_total_time=300 #include @@ -55,7 +55,7 @@ auto fuzzing::eval_op(const std::uint8_t* data, std::size_t size) -> bool boost_uint_type a_boost { 0U }; boost_uint_type b_boost { 0U }; - // Import data into their respective uintwide_t a and b values. + // Import data into the uintwide_t values. import_bits ( a_local, @@ -72,7 +72,7 @@ auto fuzzing::eval_op(const std::uint8_t* data, std::size_t size) -> bool 8U ); - // Import data into their respective boost-based a and b values. + // Import data into the boost values. import_bits ( a_boost, diff --git a/wide_integer_vs2022.vcxproj b/wide_integer_vs2022.vcxproj index fc344b1..138c9d1 100644 --- a/wide_integer_vs2022.vcxproj +++ b/wide_integer_vs2022.vcxproj @@ -238,7 +238,13 @@ true true - + + true + true + true + true + + true true true diff --git a/wide_integer_vs2022.vcxproj.filters b/wide_integer_vs2022.vcxproj.filters index 79ce63a..7a6680b 100644 --- a/wide_integer_vs2022.vcxproj.filters +++ b/wide_integer_vs2022.vcxproj.filters @@ -243,7 +243,10 @@ Source Files\test\fuzzing - + + Source Files\test\fuzzing + + Source Files\test\fuzzing From bcfdc8fce2f70596d7a05aed10a3f5d53f6add9f Mon Sep 17 00:00:00 2001 From: ckormanyos Date: Sun, 29 Sep 2024 11:32:50 +0200 Subject: [PATCH 2/4] Combine fuzzing runs in a parallel bash --- .github/workflows/wide_integer.yml | 2 +- .github/workflows/wide_integer_fuzzing.yml | 11 +-- run_fuzzing.sh | 86 ++++++++++++++++++++++ wide_integer_vs2022.vcxproj | 1 + wide_integer_vs2022.vcxproj.filters | 1 + 5 files changed, 93 insertions(+), 8 deletions(-) create mode 100755 run_fuzzing.sh diff --git a/.github/workflows/wide_integer.yml b/.github/workflows/wide_integer.yml index dd1d387..24bf33c 100644 --- a/.github/workflows/wide_integer.yml +++ b/.github/workflows/wide_integer.yml @@ -66,7 +66,7 @@ jobs: git submodule update --init libs/multiprecision - uses: ilammy/msvc-dev-cmd@v1 with: - toolset: 14.2 + toolset: 14.4 - name: bootstrap-boost working-directory: ${{runner.workspace}}/boost-root run: | diff --git a/.github/workflows/wide_integer_fuzzing.yml b/.github/workflows/wide_integer_fuzzing.yml index 8bd448d..bb2c20e 100644 --- a/.github/workflows/wide_integer_fuzzing.yml +++ b/.github/workflows/wide_integer_fuzzing.yml @@ -22,7 +22,7 @@ jobs: strategy: fail-fast: false matrix: - tcase: [ add, sub, mul, div, powm, prime, sdiv, sqrt ] + compiler: [ clang++ ] steps: - uses: actions/checkout@v4 with: @@ -41,9 +41,6 @@ jobs: - name: clang-fuzzing run: | grep BOOST_VERSION ../boost-root/boost/version.hpp - echo "compile and instrument fuzzing test" - clang++ -v - clang++ -std=c++20 -g -O2 -Wall -Wextra -fsanitize=fuzzer -I. -I../boost-root test/fuzzing/test_fuzzing_${{ matrix.tcase }}.cpp -o test_fuzzing_${{ matrix.tcase }} - echo "ls test_fuzzing_${{ matrix.tcase }}" - ls -la test_fuzzing_${{ matrix.tcase }} - ./test_fuzzing_${{ matrix.tcase }} -max_total_time=360 + ${{ matrix.compiler }} -v + echo "run fuzzing test" + bash ./run_fuzzing.sh diff --git a/run_fuzzing.sh b/run_fuzzing.sh new file mode 100755 index 0000000..ed15eca --- /dev/null +++ b/run_fuzzing.sh @@ -0,0 +1,86 @@ +#!/bin/bash + +if [[ "$1" != "" ]]; then + MY_BOOST="$1" +else + MY_BOOST=../boost-root +fi + +echo compiling... + + +clang++ -std=c++20 -g -O2 -Wall -Wextra -fsanitize=fuzzer -I. -I$MY_BOOST test/fuzzing/test_fuzzing_add.cpp -o test_fuzzing_add +clang++ -std=c++20 -g -O2 -Wall -Wextra -fsanitize=fuzzer -I. -I$MY_BOOST test/fuzzing/test_fuzzing_sub.cpp -o test_fuzzing_sub +clang++ -std=c++20 -g -O2 -Wall -Wextra -fsanitize=fuzzer -I. -I$MY_BOOST test/fuzzing/test_fuzzing_mul.cpp -o test_fuzzing_mul +clang++ -std=c++20 -g -O2 -Wall -Wextra -fsanitize=fuzzer -I. -I$MY_BOOST test/fuzzing/test_fuzzing_div.cpp -o test_fuzzing_div +clang++ -std=c++20 -g -O2 -Wall -Wextra -fsanitize=fuzzer -I. -I$MY_BOOST test/fuzzing/test_fuzzing_sdiv.cpp -o test_fuzzing_sdiv +clang++ -std=c++20 -g -O2 -Wall -Wextra -fsanitize=fuzzer -I. -I$MY_BOOST test/fuzzing/test_fuzzing_sqrt.cpp -o test_fuzzing_sqrt +clang++ -std=c++20 -g -O2 -Wall -Wextra -fsanitize=fuzzer -I. -I$MY_BOOST test/fuzzing/test_fuzzing_powm.cpp -o test_fuzzing_powm +clang++ -std=c++20 -g -O2 -Wall -Wextra -fsanitize=fuzzer -I. -I$MY_BOOST test/fuzzing/test_fuzzing_prime.cpp -o test_fuzzing_prime + + +ls -la test_fuzzing_add test_fuzzing_sub test_fuzzing_mul test_fuzzing_div test_fuzzing_sdiv test_fuzzing_sqrt test_fuzzing_powm test_fuzzing_prime +exit_compile=$? + + +# Start each executable in the background and save their process IDs +./test_fuzzing_add -max_total_time=600 -max_len=34 -verbosity=0 -close_fd_mask=3 & +pid_add=$! + +./test_fuzzing_sub -max_total_time=600 -max_len=34 -verbosity=0 -close_fd_mask=3 & +pid_sub=$! + +./test_fuzzing_mul -max_total_time=600 -max_len=34 -verbosity=0 -close_fd_mask=3 & +pid_mul=$! + +./test_fuzzing_div -max_total_time=600 -max_len=34 -verbosity=0 -close_fd_mask=3 & +pid_div=$! + +./test_fuzzing_sdiv -max_total_time=600 -max_len=34 -verbosity=0 -close_fd_mask=3 & +pid_sdiv=$! + +./test_fuzzing_sqrt -max_total_time=600 -max_len=34 -verbosity=0 -close_fd_mask=3 & +pid_sqrt=$! + +./test_fuzzing_powm -max_total_time=600 -max_len=34 -verbosity=0 -close_fd_mask=3 & +pid_powm=$! + +./test_fuzzing_prime -max_total_time=600 -max_len=34 -verbosity=0 -close_fd_mask=3 & +pid_prime=$! + + +# Wait for each job and capture its exit status +wait $pid_add +exit_add=$? +wait $pid_sub +exit_sub=$? +wait $pid_mul +exit_mul=$? +wait $pid_div +exit_div=$? +wait $pid_sdiv +exit_sdiv=$? +wait $pid_sqrt +exit_sqrt=$? +wait $pid_powm +exit_powm=$? +wait $pid_prime +exit_prime=$? + +# Check the status of compilation and of each executable + +echo "exit_compile : " "$exit_compile" +echo "exit_add : " "$exit_add" +echo "exit_sub : " "$exit_sub" +echo "exit_mul : " "$exit_mul" +echo "exit_div : " "$exit_div" +echo "exit_sdiv : " "$exit_sdiv" +echo "exit_sqrt : " "$exit_sqrt" +echo "exit_powm : " "$exit_powm" +echo "exit_prime : " "$exit_prime" + +result_total=$((exit_compile+exit_add+exit_sub+exit_mul+exit_div+exit_sdiv+exit_sqrt+exit_powm+exit_prime)) + +echo "result_total : " "$result_total" + +exit $result_total diff --git a/wide_integer_vs2022.vcxproj b/wide_integer_vs2022.vcxproj index 138c9d1..03ef37a 100644 --- a/wide_integer_vs2022.vcxproj +++ b/wide_integer_vs2022.vcxproj @@ -317,6 +317,7 @@ + true diff --git a/wide_integer_vs2022.vcxproj.filters b/wide_integer_vs2022.vcxproj.filters index 7a6680b..f5b4591 100644 --- a/wide_integer_vs2022.vcxproj.filters +++ b/wide_integer_vs2022.vcxproj.filters @@ -296,6 +296,7 @@ .github\workflows + From b67d7bc2d9d1d9987affa0aa48a9624b828f2e58 Mon Sep 17 00:00:00 2001 From: ckormanyos Date: Sun, 29 Sep 2024 12:55:14 +0200 Subject: [PATCH 3/4] Clean up fuzzing tests --- .github/workflows/wide_integer_fuzzing.yml | 2 +- run_fuzzing.sh | 18 ++++++++---------- test/fuzzing/test_fuzzing_prime.cpp | 18 ++++++++++-------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/.github/workflows/wide_integer_fuzzing.yml b/.github/workflows/wide_integer_fuzzing.yml index bb2c20e..4f78162 100644 --- a/.github/workflows/wide_integer_fuzzing.yml +++ b/.github/workflows/wide_integer_fuzzing.yml @@ -43,4 +43,4 @@ jobs: grep BOOST_VERSION ../boost-root/boost/version.hpp ${{ matrix.compiler }} -v echo "run fuzzing test" - bash ./run_fuzzing.sh + ./run_fuzzing.sh diff --git a/run_fuzzing.sh b/run_fuzzing.sh index ed15eca..d0ad0e7 100755 --- a/run_fuzzing.sh +++ b/run_fuzzing.sh @@ -6,17 +6,15 @@ else MY_BOOST=../boost-root fi -echo compiling... - -clang++ -std=c++20 -g -O2 -Wall -Wextra -fsanitize=fuzzer -I. -I$MY_BOOST test/fuzzing/test_fuzzing_add.cpp -o test_fuzzing_add -clang++ -std=c++20 -g -O2 -Wall -Wextra -fsanitize=fuzzer -I. -I$MY_BOOST test/fuzzing/test_fuzzing_sub.cpp -o test_fuzzing_sub -clang++ -std=c++20 -g -O2 -Wall -Wextra -fsanitize=fuzzer -I. -I$MY_BOOST test/fuzzing/test_fuzzing_mul.cpp -o test_fuzzing_mul -clang++ -std=c++20 -g -O2 -Wall -Wextra -fsanitize=fuzzer -I. -I$MY_BOOST test/fuzzing/test_fuzzing_div.cpp -o test_fuzzing_div -clang++ -std=c++20 -g -O2 -Wall -Wextra -fsanitize=fuzzer -I. -I$MY_BOOST test/fuzzing/test_fuzzing_sdiv.cpp -o test_fuzzing_sdiv -clang++ -std=c++20 -g -O2 -Wall -Wextra -fsanitize=fuzzer -I. -I$MY_BOOST test/fuzzing/test_fuzzing_sqrt.cpp -o test_fuzzing_sqrt -clang++ -std=c++20 -g -O2 -Wall -Wextra -fsanitize=fuzzer -I. -I$MY_BOOST test/fuzzing/test_fuzzing_powm.cpp -o test_fuzzing_powm -clang++ -std=c++20 -g -O2 -Wall -Wextra -fsanitize=fuzzer -I. -I$MY_BOOST test/fuzzing/test_fuzzing_prime.cpp -o test_fuzzing_prime +echo 'compiling test/fuzzing/test_fuzzing_add.cpp' && clang++ -std=c++20 -g -O2 -Wall -Wextra -fsanitize=fuzzer -I. -I$MY_BOOST test/fuzzing/test_fuzzing_add.cpp -o test_fuzzing_add +echo 'compiling test/fuzzing/test_fuzzing_sub.cpp' && clang++ -std=c++20 -g -O2 -Wall -Wextra -fsanitize=fuzzer -I. -I$MY_BOOST test/fuzzing/test_fuzzing_sub.cpp -o test_fuzzing_sub +echo 'compiling test/fuzzing/test_fuzzing_mul.cpp' && clang++ -std=c++20 -g -O2 -Wall -Wextra -fsanitize=fuzzer -I. -I$MY_BOOST test/fuzzing/test_fuzzing_mul.cpp -o test_fuzzing_mul +echo 'compiling test/fuzzing/test_fuzzing_div.cpp' && clang++ -std=c++20 -g -O2 -Wall -Wextra -fsanitize=fuzzer -I. -I$MY_BOOST test/fuzzing/test_fuzzing_div.cpp -o test_fuzzing_div +echo 'compiling test/fuzzing/test_fuzzing_sdiv.cpp' && clang++ -std=c++20 -g -O2 -Wall -Wextra -fsanitize=fuzzer -I. -I$MY_BOOST test/fuzzing/test_fuzzing_sdiv.cpp -o test_fuzzing_sdiv +echo 'compiling test/fuzzing/test_fuzzing_sqrt.cpp' && clang++ -std=c++20 -g -O2 -Wall -Wextra -fsanitize=fuzzer -I. -I$MY_BOOST test/fuzzing/test_fuzzing_sqrt.cpp -o test_fuzzing_sqrt +echo 'compiling test/fuzzing/test_fuzzing_powm.cpp' && clang++ -std=c++20 -g -O2 -Wall -Wextra -fsanitize=fuzzer -I. -I$MY_BOOST test/fuzzing/test_fuzzing_powm.cpp -o test_fuzzing_powm +echo 'compiling test/fuzzing/test_fuzzing_prime.cpp' && clang++ -std=c++20 -g -O2 -Wall -Wextra -fsanitize=fuzzer -I. -I$MY_BOOST test/fuzzing/test_fuzzing_prime.cpp -o test_fuzzing_prime ls -la test_fuzzing_add test_fuzzing_sub test_fuzzing_mul test_fuzzing_div test_fuzzing_sdiv test_fuzzing_sqrt test_fuzzing_powm test_fuzzing_prime diff --git a/test/fuzzing/test_fuzzing_prime.cpp b/test/fuzzing/test_fuzzing_prime.cpp index 6376cd9..e8c1e23 100644 --- a/test/fuzzing/test_fuzzing_prime.cpp +++ b/test/fuzzing/test_fuzzing_prime.cpp @@ -50,16 +50,18 @@ auto fuzzing::eval_op(const std::uint8_t* data, std::size_t size) -> bool if((size > std::size_t { max_size / 2U }) && (size <= max_size)) { - using random_engine1_type = std::linear_congruential_engine; - using random_engine2_type = std::mt19937; + using random_engine_type = std::mt19937_64; using distribution_type = ::math::wide_integer::uniform_int_distribution; - random_engine1_type generator1(util::util_pseudorandom_time_point_seed::value()); - random_engine2_type generator2(util::util_pseudorandom_time_point_seed::value()); + //random_engine1_type generator1(util::util_pseudorandom_time_point_seed::value()); + random_engine_type + generator + { + util::util_pseudorandom_time_point_seed::value() + }; - distribution_type distribution1; - distribution_type distribution2; + distribution_type distribution { }; local_uint_type p0 { 0U }; boost_uint_type pb { 0U }; @@ -85,8 +87,8 @@ auto fuzzing::eval_op(const std::uint8_t* data, std::size_t size) -> bool // Ensure that both uintwide_t as well as boost obtain // the same prime (or non-prime) result. - const bool miller_rabin_result_local { miller_rabin(p0, 25U, distribution2, generator2) }; - const bool miller_rabin_result_boost { boost::multiprecision::miller_rabin_test(pb, 25U, generator2) }; + const bool miller_rabin_result_local { miller_rabin(p0, 25U, distribution, generator) }; + const bool miller_rabin_result_boost { boost::multiprecision::miller_rabin_test(pb, 25U, generator) }; const bool result_op_is_ok From ea6326dc0e9fff21ec9f66412ffb31aa2eba64c8 Mon Sep 17 00:00:00 2001 From: ckormanyos Date: Sun, 29 Sep 2024 13:02:21 +0200 Subject: [PATCH 4/4] Add even more fuzzing time --- .github/workflows/wide_integer.yml | 2 +- .github/workflows/wide_integer_fuzzing.yml | 2 +- run_fuzzing.sh | 16 ++++++++-------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/wide_integer.yml b/.github/workflows/wide_integer.yml index 24bf33c..a669934 100644 --- a/.github/workflows/wide_integer.yml +++ b/.github/workflows/wide_integer.yml @@ -12,7 +12,7 @@ on: - '**' pull_request: schedule: - - cron: '0 2 * * *' # run at 2 AM UTC + - cron: '5 2 * * *' # run at 2:05 AM UTC jobs: cmake-linux: runs-on: ubuntu-latest diff --git a/.github/workflows/wide_integer_fuzzing.yml b/.github/workflows/wide_integer_fuzzing.yml index 4f78162..11fd28b 100644 --- a/.github/workflows/wide_integer_fuzzing.yml +++ b/.github/workflows/wide_integer_fuzzing.yml @@ -12,7 +12,7 @@ on: - '**' pull_request: schedule: - - cron: '15 2 * * *' # run at 2:15 AM UTC + - cron: '0 2 * * *' # run at 2:00 AM UTC jobs: clang-fuzzing: runs-on: ubuntu-latest diff --git a/run_fuzzing.sh b/run_fuzzing.sh index d0ad0e7..0e1285c 100755 --- a/run_fuzzing.sh +++ b/run_fuzzing.sh @@ -22,28 +22,28 @@ exit_compile=$? # Start each executable in the background and save their process IDs -./test_fuzzing_add -max_total_time=600 -max_len=34 -verbosity=0 -close_fd_mask=3 & +./test_fuzzing_add -max_total_time=900 -max_len=34 -verbosity=0 -close_fd_mask=3 & pid_add=$! -./test_fuzzing_sub -max_total_time=600 -max_len=34 -verbosity=0 -close_fd_mask=3 & +./test_fuzzing_sub -max_total_time=900 -max_len=34 -verbosity=0 -close_fd_mask=3 & pid_sub=$! -./test_fuzzing_mul -max_total_time=600 -max_len=34 -verbosity=0 -close_fd_mask=3 & +./test_fuzzing_mul -max_total_time=900 -max_len=34 -verbosity=0 -close_fd_mask=3 & pid_mul=$! -./test_fuzzing_div -max_total_time=600 -max_len=34 -verbosity=0 -close_fd_mask=3 & +./test_fuzzing_div -max_total_time=900 -max_len=34 -verbosity=0 -close_fd_mask=3 & pid_div=$! -./test_fuzzing_sdiv -max_total_time=600 -max_len=34 -verbosity=0 -close_fd_mask=3 & +./test_fuzzing_sdiv -max_total_time=900 -max_len=34 -verbosity=0 -close_fd_mask=3 & pid_sdiv=$! -./test_fuzzing_sqrt -max_total_time=600 -max_len=34 -verbosity=0 -close_fd_mask=3 & +./test_fuzzing_sqrt -max_total_time=900 -max_len=34 -verbosity=0 -close_fd_mask=3 & pid_sqrt=$! -./test_fuzzing_powm -max_total_time=600 -max_len=34 -verbosity=0 -close_fd_mask=3 & +./test_fuzzing_powm -max_total_time=900 -max_len=34 -verbosity=0 -close_fd_mask=3 & pid_powm=$! -./test_fuzzing_prime -max_total_time=600 -max_len=34 -verbosity=0 -close_fd_mask=3 & +./test_fuzzing_prime -max_total_time=900 -max_len=34 -verbosity=0 -close_fd_mask=3 & pid_prime=$!