From 774abd443e088217eceb9fc0cf2b7d017aa05d41 Mon Sep 17 00:00:00 2001 From: Kevin Phoenix Date: Thu, 17 Aug 2023 16:13:39 -0700 Subject: [PATCH 1/6] Add multiplatform CI --- .github/workflows/ci.yml | 4 ++++ .github/workflows/macos.yml | 37 ++++++++++++++++++++++++++++++ .github/workflows/windows.yml | 42 +++++++++++++++++++++++++++++++++++ setup.cfg | 2 ++ 4 files changed, 85 insertions(+) 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..a5746f2a --- /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 ./pyvex[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..ba3d6b12 --- /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 ./pyvex[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..a4a13754 100644 --- a/setup.cfg +++ b/setup.cfg @@ -43,6 +43,8 @@ pcode = pypcode>=1.1 testing = cffi + pytest + pytest-xdist uefi = uefi-firmware>=1.10 xbe = From 1d946543894e58c77b6687925f73ab72b158f78e Mon Sep 17 00:00:00 2001 From: Kevin Phoenix Date: Thu, 17 Aug 2023 16:17:07 -0700 Subject: [PATCH 2/6] Fix install paths --- .github/workflows/macos.yml | 2 +- .github/workflows/windows.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index a5746f2a..0b00a9e0 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -29,7 +29,7 @@ jobs: name: Install dependencies - run: | source $HOME/venv/bin/activate - pip install ./pyvex[testing] + pip install ./cle[testing] name: Install - run: | source $HOME/venv/bin/activate diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index ba3d6b12..1c5aeca5 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -32,7 +32,7 @@ jobs: - run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" call %USERPROFILE%\venv\Scripts\activate - pip install ./pyvex[testing] + pip install ./cle[testing] name: Install shell: cmd - run: | From 193bd52742328cfe45db972706340baffb6c6865 Mon Sep 17 00:00:00 2001 From: Kevin Phoenix Date: Thu, 17 Aug 2023 16:33:03 -0700 Subject: [PATCH 3/6] Skip tests missing dependencies --- tests/test_macho_bindinghelper.py | 4 +--- tests/test_minidump.py | 5 ++--- tests/test_xbe.py | 4 ++-- 3 files changed, 5 insertions(+), 8 deletions(-) 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..07fc1e82 100644 --- a/tests/test_minidump.py +++ b/tests/test_minidump.py @@ -1,7 +1,6 @@ -#!/usr/bin/env python - import logging import os +import unittest import archinfo @@ -10,6 +9,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 +44,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) From 5faa5797388c10d792bca098adc1cdec058648b3 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 17 Aug 2023 23:33:23 +0000 Subject: [PATCH 4/6] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_minidump.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_minidump.py b/tests/test_minidump.py index 07fc1e82..18abb240 100644 --- a/tests/test_minidump.py +++ b/tests/test_minidump.py @@ -1,4 +1,3 @@ -import logging import os import unittest From 1b1f07f8515995f360767efb15773c76b289b5d7 Mon Sep 17 00:00:00 2001 From: Kevin Phoenix Date: Thu, 17 Aug 2023 17:08:04 -0700 Subject: [PATCH 5/6] Install optional test dependencies --- setup.cfg | 3 +++ 1 file changed, 3 insertions(+) diff --git a/setup.cfg b/setup.cfg index a4a13754..749f7a0b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -43,8 +43,11 @@ pcode = pypcode>=1.1 testing = cffi + minidump>=0.0.10 pytest pytest-xdist + pypcode>=1.1 + pyxbe==0.0.4 uefi = uefi-firmware>=1.10 xbe = From 1e9dbf0b749df83e30c5a462689cc0a26303f83c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 18 Aug 2023 00:08:35 +0000 Subject: [PATCH 6/6] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 749f7a0b..162f9868 100644 --- a/setup.cfg +++ b/setup.cfg @@ -44,9 +44,9 @@ pcode = testing = cffi minidump>=0.0.10 + pypcode>=1.1 pytest pytest-xdist - pypcode>=1.1 pyxbe==0.0.4 uefi = uefi-firmware>=1.10