diff --git a/.github/setenv.sh b/.github/setenv.sh index 3eb65a108..3ba6c611d 100644 --- a/.github/setenv.sh +++ b/.github/setenv.sh @@ -13,6 +13,8 @@ function c4_show_info() echo "PROJ_PFX_TARGET=$PROJ_PFX_TARGET" echo "PROJ_PFX_CMAKE=$PROJ_PFX_CMAKE" echo "CMAKE_FLAGS=$CMAKE_FLAGS" + echo "CMAKE_C_FLAGS=$CMAKE_C_FLAGS" + echo "CMAKE_CXX_FLAGS=$CMAKE_CXX_FLAGS" echo "NUM_JOBS_BUILD=$NUM_JOBS_BUILD" echo "GITHUB_WORKSPACE=$GITHUB_WORKSPACE" pwd @@ -304,7 +306,7 @@ function c4_cfg_test() -G 'Visual Studio 17 2022' -A $(_c4vsarchtype $id) \ $(_c4_add_ehsc_to_vs_arm32 $id) \ -DCMAKE_BUILD_TYPE=$BT $CMFLAGS \ - -DCMAKE_C_FLAGS=" $CFLAGS" -DCMAKE_CXX_FLAGS=" $CXXFLAGS" + -DCMAKE_C_FLAGS=" $CFLAGS $CMAKE_C_FLAGS" -DCMAKE_CXX_FLAGS=" $CXXFLAGS $CMAKE_CXX_FLAGS" ;; vs2019) cmake -S $PROJ_DIR -B $build_dir -DCMAKE_INSTALL_PREFIX="$install_dir" \ diff --git a/.github/workflows/clang.yml b/.github/workflows/clang.yml index 911163d65..bc3f19f5e 100644 --- a/.github/workflows/clang.yml +++ b/.github/workflows/clang.yml @@ -192,7 +192,58 @@ jobs: - {std: 11, cxx: "4.0", bt: Release, vg: on, img: ubuntu18.04} - {std: 11, cxx: "3.9", bt: Debug , vg: on, img: ubuntu18.04} - {std: 11, cxx: "3.9", bt: Release, vg: on, img: ubuntu18.04} - env: {STD: "${{matrix.std}}", CXX_: "clang++-${{matrix.cxx}}", BT: "${{matrix.bt}}", BITLINKS: "${{matrix.bitlinks}}", VG: "${{matrix.vg}}", SAN: "${{matrix.san}}", LINT: "${{matrix.lint}}", OS: "${{matrix.os}}"} + env: { + STD: "${{matrix.std}}", CXX_: "clang++-${{matrix.cxx}}", BT: "${{matrix.bt}}", + BITLINKS: "${{matrix.bitlinks}}", VG: "${{matrix.vg}}", + SAN: "${{matrix.san}}", LINT: "${{matrix.lint}}", OS: "${{matrix.os}}" + } + steps: + - {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive}} + - run: git config --system --add safe.directory '*' # needed for running in the docker image. see https://github.com/actions/checkout/issues/1169 + - run: c4core-install $CXX_ + - {name: show info, run: source .github/setenv.sh && c4_show_info} + - name: shared64-configure--------------------------------------------------- + run: source .github/setenv.sh && c4_cfg_test shared64 + - {name: shared64-build, run: source .github/setenv.sh && c4_build_test shared64} + - {name: shared64-run, run: source .github/setenv.sh && c4_run_test shared64} + - {name: shared64-pack, run: source .github/setenv.sh && c4_package shared64} + - name: static64-configure--------------------------------------------------- + run: source .github/setenv.sh && c4_cfg_test static64 + - {name: static64-build, run: source .github/setenv.sh && c4_build_test static64} + - {name: static64-run, run: source .github/setenv.sh && c4_run_test static64} + - {name: static64-pack, run: source .github/setenv.sh && c4_package static64} + - name: static32-configure--------------------------------------------------- + run: source .github/setenv.sh && c4_cfg_test static32 + - {name: static32-build, run: source .github/setenv.sh && c4_build_test static32} + - {name: static32-run, run: source .github/setenv.sh && c4_run_test static32} + - {name: static32-pack, run: source .github/setenv.sh && c4_package static32} + - name: shared32-configure--------------------------------------------------- + run: source .github/setenv.sh && c4_cfg_test shared32 + - {name: shared32-build, run: source .github/setenv.sh && c4_build_test shared32} + - {name: shared32-run, run: source .github/setenv.sh && c4_run_test shared32} + - {name: shared32-pack, run: source .github/setenv.sh && c4_package shared32} + + #---------------------------------------------------------------------------- + clang_fuzz: + name: clang_fuzz/${{matrix.cxx}}/c++${{matrix.std}}/${{matrix.bt}}/vg${{matrix.vg}} + continue-on-error: true + if: always() # https://stackoverflow.com/questions/62045967/github-actions-is-there-a-way-to-continue-on-error-while-still-getting-correct + runs-on: ubuntu-latest + container: ghcr.io/biojppm/c4core/${{matrix.img}}:latest # use the docker image + strategy: + fail-fast: false + matrix: + include: + - {std: 11, cxx: "16" , bt: fuzz , vg: on, img: ubuntu18.04} + - {std: 11, cxx: "16" , bt: Debug , vg: on, img: ubuntu18.04} + - {std: 11, cxx: "16" , bt: Release, vg: on, img: ubuntu18.04} + env: { + CMAKE_CXX_FLAGS: "-g -O0 -fsanitize=address,undefined", + CMAKE_FLAGS: "-DRYML_TEST_FUZZ=ON -DRYML_FUZZ_LIBFUZZER_MERGE=ON", + STD: "${{matrix.std}}", CXX_: "clang++-${{matrix.cxx}}", BT: "${{matrix.bt}}", + BITLINKS: "${{matrix.bitlinks}}", VG: "${{matrix.vg}}",xs SAN: "${{matrix.san}}", + LINT: "${{matrix.lint}}", OS: "${{matrix.os}}" + } steps: - {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive}} - run: git config --system --add safe.directory '*' # needed for running in the docker image. see https://github.com/actions/checkout/issues/1169 diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index d2e7872c3..f233d2824 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -46,7 +46,7 @@ jobs: env: {STD: "${{matrix.std}}", CXX_: "${{matrix.cxx}}", BT: "${{matrix.bt}}", BITLINKS: "${{matrix.bitlinks}}", VG: "${{matrix.vg}}", SAN: "${{matrix.san}}", LINT: "${{matrix.lint}}", OS: "${{matrix.os}}", - CMAKE_FLAGS: "${{matrix.cmk}}", + CMAKE_FLAGS: "${{matrix.cmk}} -DRYML_TEST_FUZZ=ON", CODECOV_TOKEN: "${{secrets.CODECOV_TOKEN}}", COVERALLS_REPO_TOKEN: "${{secrets.COVERALLS_REPO_TOKEN}}", # coveralls disabled: https://github.com/lemurheavy/coveralls-public/issues/1665 diff --git a/.github/workflows/gcc.yml b/.github/workflows/gcc.yml index 2a16edb27..d92b80a18 100644 --- a/.github/workflows/gcc.yml +++ b/.github/workflows/gcc.yml @@ -44,7 +44,10 @@ jobs: - {std: 11, cxx: g++-5 , bt: Release, bitlinks: shared64 static32} - {std: 11, cxx: g++-4.8, bt: Debug , bitlinks: shared64 static32} - {std: 11, cxx: g++-4.8, bt: Release, bitlinks: shared64 static32} - env: {STD: "${{matrix.std}}", CXX_: "${{matrix.cxx}}", BT: "${{matrix.bt}}", BITLINKS: "${{matrix.bitlinks}}", VG: "${{matrix.vg}}", SAN: "${{matrix.san}}", LINT: "${{matrix.lint}}", OS: "${{matrix.os}}"} + env: { + STD: "${{matrix.std}}", CXX_: "${{matrix.cxx}}", BT: "${{matrix.bt}}", + BITLINKS: "${{matrix.bitlinks}}", VG: "${{matrix.vg}}", SAN: "${{matrix.san}}", LINT: "${{matrix.lint}}", OS: "${{matrix.os}}" + } steps: - {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive}} - run: git config --system --add safe.directory '*' # needed for running in the docker image. see https://github.com/actions/checkout/issues/1169 @@ -134,7 +137,13 @@ jobs: - {std: 11, cxx: g++-7 , bt: Release, bitlinks: shared64 static32} - {std: 20, cxx: g++-10 , bt: Debug , bitlinks: shared64 static32} - {std: 20, cxx: g++-10 , bt: Release, bitlinks: shared64 static32} - env: {CXXFLAGS: "-fno-exceptions -fno-rtti", STD: "${{matrix.std}}", CXX_: "${{matrix.cxx}}", BT: "${{matrix.bt}}", BITLINKS: "${{matrix.bitlinks}}", VG: "${{matrix.vg}}", SAN: "${{matrix.san}}", LINT: "${{matrix.lint}}", OS: "${{matrix.os}}"} + env: { + CXXFLAGS: "-fno-exceptions -fno-rtti", + CMAKE_FLAGS: "-DRYML_TEST_FUZZ=ON", + STD: "${{matrix.std}}", CXX_: "${{matrix.cxx}}", BT: "${{matrix.bt}}", + BITLINKS: "${{matrix.bitlinks}}", VG: "${{matrix.vg}}", + SAN: "${{matrix.san}}", LINT: "${{matrix.lint}}", OS: "${{matrix.os}}" + } steps: - {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive}} - run: git config --system --add safe.directory '*' # needed for running in the docker image. see https://github.com/actions/checkout/issues/1169 @@ -200,7 +209,12 @@ jobs: - {std: 11, cxx: g++-4.9, bt: Release, img: ubuntu18.04} - {std: 11, cxx: g++-4.8, bt: Debug , img: ubuntu18.04} - {std: 11, cxx: g++-4.8, bt: Release, img: ubuntu18.04} - env: {STD: "${{matrix.std}}", CXX_: "${{matrix.cxx}}", BT: "${{matrix.bt}}", BITLINKS: "${{matrix.bitlinks}}", VG: "${{matrix.vg}}", SAN: "${{matrix.san}}", LINT: "${{matrix.lint}}", OS: "${{matrix.os}}"} + env: { + CMAKE_FLAGS: "-DRYML_TEST_FUZZ=ON", + STD: "${{matrix.std}}", CXX_: "${{matrix.cxx}}", BT: "${{matrix.bt}}", + BITLINKS: "${{matrix.bitlinks}}", VG: "${{matrix.vg}}", + SAN: "${{matrix.san}}", LINT: "${{matrix.lint}}", OS: "${{matrix.os}}" + } steps: - {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive}} - run: git config --system --add safe.directory '*' # needed for running in the docker image. see https://github.com/actions/checkout/issues/1169 diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 7f8d4f0b5..1b5d870b5 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -269,7 +269,13 @@ endif(RYML_TEST_SUITE) #------------------------------------------------------------------------------ string(TOUPPER "${CMAKE_BUILD_TYPE}" upper_build_type) -if((upper_build_type STREQUAL FUZZ) OR (upper_build_type STREQUAL COVERAGE)) +if(upper_build_type STREQUAL FUZZ) + option(RYML_TEST_FUZZ "Enable fuzz tests" ON) +else() + option(RYML_TEST_FUZZ "Enable fuzz tests" OFF) +endif() + +if(RYML_TEST_FUZZ) c4_download_remote_proj(rapidyaml-data rapidyaml_data_dir GIT_REPOSITORY https://github.com/biojppm/rapidyaml-data GIT_TAG master) @@ -288,24 +294,21 @@ if((upper_build_type STREQUAL FUZZ) OR (upper_build_type STREQUAL COVERAGE)) function(ryml_add_fuzz_test name) c4_add_executable(ryml-test-fuzz-${name} SOURCES - test_fuzz/test_fuzz_common.hpp - test_fuzz/test_fuzz_${name}.cpp - test_fuzz/test_fuzz_main.cpp + test_fuzz/test_fuzz_common.hpp + test_fuzz/test_fuzz_${name}.cpp + test_fuzz/test_fuzz_main.cpp ${ARGN} INC_DIRS ${CMAKE_CURRENT_LIST_DIR} LIBS ryml c4fs FOLDER test/fuzz) function(ryml_add_fuzz_test_file name_ dir file) string(REPLACE "/" "_" fuzz_name "${file}") - #add_test(NAME ryml-test-fuzz-${name_}-${fuzz_name} - # COMMAND $ ${dir}/${file}) + add_test(NAME ryml-test-fuzz-${name_}-${fuzz_name} + COMMAND $ ${dir}/${file}) endfunction() foreach(fuzz_file ${fuzz_files}) ryml_add_fuzz_test_file(${name} ${corpus_artifacts_dir} ${fuzz_file}) endforeach() - foreach(fuzz_file ${suite_files}) - ryml_add_fuzz_test_file(${name} ${corpus_suite_dir} ${fuzz_file}) - endforeach() if(RYML_DBG) target_compile_definitions(ryml-test-fuzz-${name} PUBLIC RYML_DBG) endif() @@ -329,7 +332,7 @@ if((upper_build_type STREQUAL FUZZ) OR (upper_build_type STREQUAL COVERAGE)) # # # libfuzzer: https://llvm.org/docs/LibFuzzer.html - if((upper_build_type STREQUAL FUZZ) AND ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")) + if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") option(RYML_FUZZ_LIBFUZZER_MERGE OFF "merge fuzz corpus") option(RYML_FUZZ_LIBFUZZER_MERGE_RESUME ON "resume merge") option(RYML_FUZZ_LIBFUZZER_DICT ON "use a yaml dict") diff --git a/test/test_fuzz/test_fuzz_common.hpp b/test/test_fuzz/test_fuzz_common.hpp index f2c45462f..d098003da 100644 --- a/test/test_fuzz/test_fuzz_common.hpp +++ b/test/test_fuzz/test_fuzz_common.hpp @@ -60,7 +60,7 @@ inline C4_NORETURN void errcallback(const char *msg, size_t msg_len, c4::yml::Lo jmp_msg.assign(msg, msg_len); std::longjmp(jmp_env, 1); ); -}; +} inline c4::yml::Callbacks create_custom_callbacks() { diff --git a/test/test_fuzz/test_fuzz_events.cpp b/test/test_fuzz/test_fuzz_events.cpp index 20c668273..a857a2fe6 100644 --- a/test/test_fuzz/test_fuzz_events.cpp +++ b/test/test_fuzz/test_fuzz_events.cpp @@ -3,7 +3,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *str, size_t len) { - static std::atomic_uint32_t case_number{0}; + static std::atomic case_number{0}; c4::csubstr src = {reinterpret_cast(str), len}; return c4::yml::fuzztest_yaml_events(case_number++, src); } diff --git a/test/test_fuzz/test_fuzz_parse_emit.cpp b/test/test_fuzz/test_fuzz_parse_emit.cpp index 08f62cad5..dc4c08057 100644 --- a/test/test_fuzz/test_fuzz_parse_emit.cpp +++ b/test/test_fuzz/test_fuzz_parse_emit.cpp @@ -3,7 +3,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *str, size_t len) { - static std::atomic_uint32_t case_number{0}; + static std::atomic case_number{0}; c4::csubstr src = {reinterpret_cast(str), len}; return c4::yml::fuzztest_parse_emit(case_number++, src); }