From 80acad3e4fa8c18522b10ab277b42bf2fe72e677 Mon Sep 17 00:00:00 2001 From: Maryla Date: Thu, 22 Aug 2024 15:58:42 +0200 Subject: [PATCH 1/3] Add fuzztest --- .github/actions/setup-common/action.yml | 5 +- .../ci-linux-shared-local-fuzztest.yml | 68 +++++++++++++++++++ tests/CMakeLists.txt | 6 ++ tests/CTestCustom.cmake | 4 ++ 4 files changed, 81 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/ci-linux-shared-local-fuzztest.yml create mode 100644 tests/CTestCustom.cmake diff --git a/.github/actions/setup-common/action.yml b/.github/actions/setup-common/action.yml index c19b571c8b..94b708ad12 100644 --- a/.github/actions/setup-common/action.yml +++ b/.github/actions/setup-common/action.yml @@ -26,12 +26,13 @@ runs: with: # Use the minimum required version of cmake. cmake-version: '3.13.x' - - name: Set up CMake >= 3.21 + - name: Set up CMake >= 3.25 if: ${{ runner.os == 'Linux' && inputs.recent-cmake == 'true' }} uses: jwlawson/actions-setup-cmake@802fa1a2c4e212495c05bf94dba2704a92a472be # v2.0.2 with: # Need cmake 3.21 to set CMAKE_C_STANDARD to 23 for [[nodiscard]]. - cmake-version: '3.21.x' + # Need cmake 3.25 for fuzztest + cmake-version: '3.25.x' - name: Print CMake version run: cmake --version shell: bash diff --git a/.github/workflows/ci-linux-shared-local-fuzztest.yml b/.github/workflows/ci-linux-shared-local-fuzztest.yml new file mode 100644 index 0000000000..2f97ca777c --- /dev/null +++ b/.github/workflows/ci-linux-shared-local-fuzztest.yml @@ -0,0 +1,68 @@ +# Builds libavif with local aom and dav1d and runs tests including fuzztest. +# Runs on ubuntu only. libavif is built with clang. + +name: CI Unix Shared Local Fuzztest +on: [push, pull_request] + +permissions: + contents: read + +# Cancel the workflow if a new one is triggered from the same PR, branch, or tag, except on main. +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + +jobs: + build-shared-local: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-24.04] + libyuv: [OFF] + include: + - runs-on: ubuntu-24.04 + compiler: gcc + gcc: 14 + + name: build-shared-local-fuzztest + + steps: + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + - uses: ./.github/actions/setup-linux + id: setup + with: + codec-aom: 'LOCAL' + codec-dav1d: 'LOCAL' + gcc-version: ${{ matrix.gcc }} + libxml2: 'LOCAL' + libyuv: 'LOCAL' + recent-cmake: 'true' + - name: Build fuzztest + if: steps.setup.outputs.ext-cache-hit != 'true' + working-directory: ./ext + run: bash -e fuzztest.cmd + + - name: Prepare libavif (cmake) + run: > + cmake -G Ninja -S . -B build + -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON + -DAVIF_CODEC_AOM=LOCAL -DAVIF_CODEC_DAV1D=LOCAL + -DAVIF_LIBSHARPYUV=LOCAL -DAVIF_LIBXML2=LOCAL + -DAVIF_LIBYUV=${{ matrix.libyuv }} + -DAVIF_BUILD_EXAMPLES=ON -DAVIF_BUILD_APPS=ON + -DAVIF_BUILD_TESTS=ON -DAVIF_ENABLE_GTEST=ON -DAVIF_GTEST=LOCAL + -DAVIF_ENABLE_EXPERIMENTAL_YCGCO_R=ON + -DAVIF_ENABLE_EXPERIMENTAL_GAIN_MAP=ON + -DAVIF_ENABLE_EXPERIMENTAL_MINI=ON + -DAVIF_ENABLE_EXPERIMENTAL_SAMPLE_TRANSFORM=ON + -DAVIF_ENABLE_FUZZTEST=ON + -DAVIF_LOCAL_FUZZTEST=ON + -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ + -DAVIF_ENABLE_WERROR=ON + - name: Build libavif (ninja) + working-directory: ./build + run: ninja + - name: Run AVIF Tests + working-directory: ./build + run: ctest -j $(getconf _NPROCESSORS_ONLN) --output-on-failure diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index da71adb1bb..90c9aacf55 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -9,6 +9,9 @@ enable_testing() # C tests and tools set(COVERAGE_TARGETS) + +configure_file(${AVIF_SOURCE_DIR}/tests/CTestCustom.cmake ${CMAKE_BINARY_DIR}) + # Macro to register a test for coverage. The first argument is the target name. # Other arguments, like data path, can be added. macro(register_test_for_coverage TEST_NAME) @@ -205,6 +208,9 @@ if(AVIF_ENABLE_FUZZTEST) if(CMAKE_VERSION VERSION_LESS 3.25.0) message(FATAL_ERROR "CMake must be at least 3.25 to pass the SYSTEM argument to add_subdirectory(), bailing out") endif() + # Add the fuzztest project. Note this may add some tests which may not be built because of EXCLUDE_FROM_ALL and will + # therefore fail. They can be ignored by adding them to CTestCustom.cmake + # See https://gitlab.kitware.com/cmake/cmake/-/issues/20212 add_subdirectory(${AVIF_SOURCE_DIR}/ext/fuzztest ${AVIF_SOURCE_DIR}/ext/fuzztest/build.libavif EXCLUDE_FROM_ALL SYSTEM) else() message( diff --git a/tests/CTestCustom.cmake b/tests/CTestCustom.cmake new file mode 100644 index 0000000000..287348132f --- /dev/null +++ b/tests/CTestCustom.cmake @@ -0,0 +1,4 @@ +set(CTEST_CUSTOM_TESTS_IGNORE + # Ignore failing tests brought by `add_subdirectory(${AVIF_SOURCE_DIR}/ext/fuzztest)` when AVIF_ENABLE_FUZZTEST is ON + antlr4_tests_NOT_BUILT +) From e85a59bfe5d0d6fdcf05494f24fb714ab67d2c78 Mon Sep 17 00:00:00 2001 From: Maryla Date: Fri, 23 Aug 2024 16:56:05 +0200 Subject: [PATCH 2/3] Run only fuzztest tests in fuzztest workflow --- .github/workflows/ci-linux-shared-local-fuzztest.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci-linux-shared-local-fuzztest.yml b/.github/workflows/ci-linux-shared-local-fuzztest.yml index 2f97ca777c..d6d3d7e94b 100644 --- a/.github/workflows/ci-linux-shared-local-fuzztest.yml +++ b/.github/workflows/ci-linux-shared-local-fuzztest.yml @@ -1,4 +1,7 @@ -# Builds libavif with local aom and dav1d and runs tests including fuzztest. +# Builds libavif with local aom and dav1d and runs fuzztest tests +# (tests that have 'fuzztest' in their name). +# They are run in "unit test mode" (run with random inputs for a short period of time) +# see https://github.com/google/fuzztest/blob/main/doc/quickstart-cmake.md # Runs on ubuntu only. libavif is built with clang. name: CI Unix Shared Local Fuzztest @@ -63,6 +66,6 @@ jobs: - name: Build libavif (ninja) working-directory: ./build run: ninja - - name: Run AVIF Tests + - name: Run fuzztest AVIF Tests working-directory: ./build - run: ctest -j $(getconf _NPROCESSORS_ONLN) --output-on-failure + run: ctest -j $(getconf _NPROCESSORS_ONLN) --output-on-failure -R fuzztest From 1bc2a95e2d3a5b4f7194cc1722ab9504fa115090 Mon Sep 17 00:00:00 2001 From: Maryla Date: Tue, 27 Aug 2024 13:12:50 +0200 Subject: [PATCH 3/3] Rename workflow and remove unneeded config, add local libyuv --- ...inux-shared-local-fuzztest.yml => ci-fuzztest.yml} | 11 +++-------- ext/libargparse.cmd | 4 ++-- 2 files changed, 5 insertions(+), 10 deletions(-) rename .github/workflows/{ci-linux-shared-local-fuzztest.yml => ci-fuzztest.yml} (91%) diff --git a/.github/workflows/ci-linux-shared-local-fuzztest.yml b/.github/workflows/ci-fuzztest.yml similarity index 91% rename from .github/workflows/ci-linux-shared-local-fuzztest.yml rename to .github/workflows/ci-fuzztest.yml index d6d3d7e94b..2e620dd540 100644 --- a/.github/workflows/ci-linux-shared-local-fuzztest.yml +++ b/.github/workflows/ci-fuzztest.yml @@ -4,7 +4,7 @@ # see https://github.com/google/fuzztest/blob/main/doc/quickstart-cmake.md # Runs on ubuntu only. libavif is built with clang. -name: CI Unix Shared Local Fuzztest +name: CI Fuzztest on: [push, pull_request] permissions: @@ -22,11 +22,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-24.04] - libyuv: [OFF] - include: - - runs-on: ubuntu-24.04 - compiler: gcc - gcc: 14 + libyuv: [OFF, LOCAL] name: build-shared-local-fuzztest @@ -37,9 +33,8 @@ jobs: with: codec-aom: 'LOCAL' codec-dav1d: 'LOCAL' - gcc-version: ${{ matrix.gcc }} libxml2: 'LOCAL' - libyuv: 'LOCAL' + libyuv: ${{ matrix.libyuv }} recent-cmake: 'true' - name: Build fuzztest if: steps.setup.outputs.ext-cache-hit != 'true' diff --git a/ext/libargparse.cmd b/ext/libargparse.cmd index 509c7b0cdf..d04045cfe9 100755 --- a/ext/libargparse.cmd +++ b/ext/libargparse.cmd @@ -8,10 +8,10 @@ : # If you're running this on Windows, be sure you've already run this (from your VC2019 install dir): : # "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Auxiliary\Build\vcvars64.bat" -git clone --single-branch https://github.com/kmurray/libargparse.git +git clone https://github.com/maryla-uc/libargparse.git cd libargparse -git checkout ee74d1b53bd680748af14e737378de57e2a0a954 +git checkout 81998ffafb9c2ac8cf488d31e536a2e6fd6b3fdf mkdir build cd build