From efb54603b9bd236ffa90ff52fd1f59b2ddc87a55 Mon Sep 17 00:00:00 2001 From: Kevin Phoenix Date: Thu, 17 Aug 2023 17:48:26 -0700 Subject: [PATCH] Add multiplatform CI (#418) * Add multiplatform CI * Fix install paths * Skip tests missing dependencies * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Install optional test dependencies * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .github/workflows/ci.yml | 4 +++ .github/workflows/macos.yml | 37 +++++++++++++++++++++++++++ .github/workflows/windows.yml | 42 +++++++++++++++++++++++++++++++ setup.cfg | 5 ++++ tests/test_macho_bindinghelper.py | 4 +-- tests/test_minidump.py | 6 ++--- tests/test_xbe.py | 4 +-- 7 files changed, 93 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/macos.yml create mode 100644 .github/workflows/windows.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 77de8d4d..eef182a3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,6 +10,10 @@ on: jobs: ci: uses: angr/ci-settings/.github/workflows/angr-ci.yml@master + windows: + uses: ./.github/workflows/windows.yml + macos: + uses: ./.github/workflows/macos.yml docs: runs-on: ubuntu-22.04 steps: diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml new file mode 100644 index 00000000..0b00a9e0 --- /dev/null +++ b/.github/workflows/macos.yml @@ -0,0 +1,37 @@ +name: Test on macOS + +on: + workflow_dispatch: + workflow_call: + +jobs: + macos: + name: Test macOS + runs-on: macos-12 + steps: + - uses: actions/checkout@v3 + with: + path: cle + - uses: actions/checkout@v3 + with: + repository: angr/binaries + path: binaries + - uses: actions/setup-python@v4 + with: + python-version: "3.8" + - run: python -m venv $HOME/venv + name: Create venv + shell: bash + - run: | + source $HOME/venv/bin/activate + pip install git+https://github.com/angr/archinfo.git + pip install git+https://github.com/angr/pyvex.git + name: Install dependencies + - run: | + source $HOME/venv/bin/activate + pip install ./cle[testing] + name: Install + - run: | + source $HOME/venv/bin/activate + pytest -n auto cle + name: Run pytest diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml new file mode 100644 index 00000000..1c5aeca5 --- /dev/null +++ b/.github/workflows/windows.yml @@ -0,0 +1,42 @@ +name: Test on Windows + +on: + workflow_dispatch: + workflow_call: + +jobs: + windows: + name: Test Windows + runs-on: windows-2022 + steps: + - uses: actions/checkout@v3 + with: + path: cle + - uses: actions/checkout@v3 + with: + repository: angr/binaries + path: binaries + - uses: actions/setup-python@v4 + with: + python-version: "3.8" + - run: python -m venv $HOME/venv + name: Create venv + shell: bash + - run: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" + call %USERPROFILE%\venv\Scripts\activate + pip install git+https://github.com/angr/archinfo.git + pip install git+https://github.com/angr/pyvex.git + name: Install dependencies + shell: cmd + - run: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" + call %USERPROFILE%\venv\Scripts\activate + pip install ./cle[testing] + name: Install + shell: cmd + - run: | + call %USERPROFILE%\venv\Scripts\activate + pytest -n auto cle + name: Run pytest + shell: cmd diff --git a/setup.cfg b/setup.cfg index 4392cb24..162f9868 100644 --- a/setup.cfg +++ b/setup.cfg @@ -43,6 +43,11 @@ pcode = pypcode>=1.1 testing = cffi + minidump>=0.0.10 + pypcode>=1.1 + pytest + pytest-xdist + pyxbe==0.0.4 uefi = uefi-firmware>=1.10 xbe = diff --git a/tests/test_macho_bindinghelper.py b/tests/test_macho_bindinghelper.py index b4e924bb..70d7647a 100644 --- a/tests/test_macho_bindinghelper.py +++ b/tests/test_macho_bindinghelper.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python # Contributed September 2019 by Fraunhofer SIT (https://www.sit.fraunhofer.de/en/). import os import unittest @@ -517,5 +516,4 @@ def test_bind_real_64(self): if __name__ == "__main__": - # TODO run the testclasses without having to run each test in case the CI needs this - raise NotImplementedError() + unittest.main() diff --git a/tests/test_minidump.py b/tests/test_minidump.py index ad710980..18abb240 100644 --- a/tests/test_minidump.py +++ b/tests/test_minidump.py @@ -1,7 +1,5 @@ -#!/usr/bin/env python - -import logging import os +import unittest import archinfo @@ -10,6 +8,7 @@ TEST_BASE = os.path.join(os.path.dirname(os.path.realpath(__file__)), os.path.join("..", "..", "binaries")) +@unittest.skipIf(cle.backends.minidump.minidumpfile is None, "minidump not available") def test_minidump(): exe = os.path.join(TEST_BASE, "tests", "x86", "windows", "jusched_x86.dmp") ld = cle.Loader(exe, auto_load_libs=False) @@ -44,5 +43,4 @@ def test_minidump(): if __name__ == "__main__": - logging.basicConfig(level=logging.INFO) test_minidump() diff --git a/tests/test_xbe.py b/tests/test_xbe.py index c4936cdb..62a1aa30 100644 --- a/tests/test_xbe.py +++ b/tests/test_xbe.py @@ -1,13 +1,13 @@ -#!/usr/bin/env python - import logging import os +import unittest import cle TEST_BASE = os.path.join(os.path.dirname(os.path.realpath(__file__)), os.path.join("..", "..", "binaries")) +@unittest.skipIf(cle.backends.xbe.Xbe is None, "pyxbe not available") def test_xbe(): xbe = os.path.join(TEST_BASE, "tests", "x86", "xbox", "triangle.xbe") ld = cle.Loader(xbe, auto_load_libs=False)