From 5fe14ae8ae54a1740f8f1aef853aae8ee9af5790 Mon Sep 17 00:00:00 2001 From: Romain Thomas Date: Thu, 9 Nov 2023 13:19:34 +0100 Subject: [PATCH] Split test step --- .github/workflows/linux-x86-64.yml | 67 ++++++++++++++++++++++-------- .github/workflows/osx.yml | 7 ++++ scripts/docker/test-linux-x64 | 8 +--- 3 files changed, 59 insertions(+), 23 deletions(-) diff --git a/.github/workflows/linux-x86-64.yml b/.github/workflows/linux-x86-64.yml index 0a8cc9102f..4dec18a3ac 100644 --- a/.github/workflows/linux-x86-64.yml +++ b/.github/workflows/linux-x86-64.yml @@ -51,6 +51,14 @@ jobs: testing: if: "!contains(github.event.commits[0].message, '[skip-test]')" runs-on: ubuntu-latest + container: + image: liefproject/manylinux_2_28_x86_64 + env: + PYTHON_BINARY: "/opt/python/cp38-cp38/bin/python3.8" + LIEF_SAMPLES_DIR: "/tmp/samples" + LIEF_BUILD_DIR: "/tmp/lief-build" + LIEF_VENV: "/tmp/venv" + options: --user 1001:1001 steps: - uses: actions/checkout@v3 with: @@ -67,26 +75,51 @@ jobs: key: linux-x86-64-${{ runner.os }}-test-${{ steps.get-date.outputs.date }} restore-keys: | linux-x86-64-${{ runner.os }}-test - - name: Python 3.8 -- Wheel & Test + - name: Prepare Python virtual env shell: bash - env: - PYTHON_VERSION: 38 - PYTHON_BINARY: "/opt/python/cp38-cp38/bin/python3.8" run: | - mkdir -p $HOME/.ccache - chmod -R 777 $HOME/.ccache + $PYTHON_BINARY -m venv ${LIEF_VENV} + source ${LIEF_VENV}/bin/activate + python -m pip install \ + -r tests/requirements.txt \ + -r api/python/build-requirements.txt + - name: Prepare test samples + shell: bash + run: | + source ${LIEF_VENV}/tmp/lief_venv/bin/activate + mkdir -p ${LIEF_SAMPLES_DIR} + python tests/dl_samples.py ${LIEF_SAMPLES_DIR} + - name: Build & install LIEF + shell: bash + run: | + source ${LIEF_VENV}/bin/activate + export PYLIEF_CONF="${GITHUB_WORKSPACE}/scripts/docker/config/pylinux-test-x64.toml" + python -m pip -vvv install api/python + - name: Run tests + timeout-minutes: 5 + shell: bash + run: | + source ${LIEF_VENV}/bin/activate + python tests/run_pytest.py + python tests/run_tools_check.py ${LIEF_BUILD_DIR}/ + ctest --output-on-failure --test-dir ${LIEF_BUILD_DIR}/ + - name: Run fuzzing tests + shell: bash + timeout-minutes: 10 + run: | + source ${LIEF_VENV}/bin/activate + export PYTHONPATH="${GITHUB_WORKSPACE}/tests:$PYTHONPATH" + python tests/elf/fuzzing.py \ + ${LIEF_BUILD_DIR}/tests/Melkor/src/MELKOR/melkor \ + --input-seed ${LIEF_SAMPLES_DIR}/ELF/ELF64_x86-64_binary_ls.bin -n 100 + + python tests/elf/fuzzing.py \ + ${LIEF_BUILD_DIR}/tests/Melkor/src/MELKOR/melkor \ + --input-seed ${LIEF_SAMPLES_DIR}/ELF/ELF64_x86-64_binary_openssl.bin -n 100 - docker run --rm -u 1001:1001 \ - -e CCACHE_COMPRESS=1 \ - -e CCACHE_MAXSIZE=10.0G \ - -e CCACHE_CPP2=1 \ - -e CCACHE_DIR=/ccache \ - -e PYTHON_VERSION=$PYTHON_VERSION \ - -e PYTHON_BINARY=$PYTHON_BINARY \ - -v $GITHUB_WORKSPACE:/src \ - -v $HOME/.ccache:/ccache \ - liefproject/manylinux_2_28_x86_64 \ - bash /src/scripts/docker/test-linux-x64 + python tests/elf/fuzzing.py \ + ${LIEF_BUILD_DIR}/tests/Melkor/src/MELKOR/melkor \ + --input-seed ${LIEF_SAMPLES_DIR}/ELF/ELF64_x86-64_binary_nm.bin -n 100 pywheels: runs-on: ubuntu-latest needs: linux-sdk diff --git a/.github/workflows/osx.yml b/.github/workflows/osx.yml index 35e81253eb..f145beb783 100644 --- a/.github/workflows/osx.yml +++ b/.github/workflows/osx.yml @@ -108,6 +108,13 @@ jobs: python -m pip install -r tests/requirements.txt python -m pip -vvv install api/python python tests/dl_samples.py ${LIEF_SAMPLES_DIR} + - name: Run tests + shell: bash + timeout-minutes: 20 + env: + LIEF_SAMPLES_DIR: "/tmp/samples" + LIEF_BUILD_DIR: "/tmp/lief-build" + run: | python tests/run_pytest.py python tests/run_tools_check.py ${LIEF_BUILD_DIR}/ ctest --output-on-failure --test-dir ${LIEF_BUILD_DIR}/ diff --git a/scripts/docker/test-linux-x64 b/scripts/docker/test-linux-x64 index 39195a4559..f80e3be67b 100755 --- a/scripts/docker/test-linux-x64 +++ b/scripts/docker/test-linux-x64 @@ -1,5 +1,5 @@ #!/usr/bin/sh -set -ex +set -e export LIEF_SAMPLES_DIR=/tmp/samples export CXXFLAGS='-ffunction-sections -fdata-sections -fvisibility-inlines-hidden -static-libgcc' export CFLAGS='-ffunction-sections -fdata-sections -static-libgcc' @@ -18,11 +18,7 @@ python -m pip install \ mkdir -p ${LIEF_SAMPLES_DIR} python tests/dl_samples.py ${LIEF_SAMPLES_DIR} - -pushd /src/api/python -python -m pip -vvv wheel --no-build-isolation --wheel-dir=/src/wheel_stage . -python -m pip -vvv install . -popd +python -m pip -vvv install /src/api/python # Run the Python test suite python tests/run_pytest.py