From aa90fb6282f813b4227cd27850c1c32ef761f0b2 Mon Sep 17 00:00:00 2001 From: Anichitei Ionel-Cristinel <49393881+ianichitei@users.noreply.github.com> Date: Tue, 17 Sep 2024 11:08:03 +0300 Subject: [PATCH 01/13] ci: Run tests on Linux builds with sanitizers --- .github/workflows/ci.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f8e91d9..dd11233 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,6 +35,17 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Build with sanitizers + run: | + mkdir build_sanitizers + cd build_sanitizers + cmke .. -DCMAKE_BUILD_TYPE=Debug -DBDD_ASAN=ON -DBDD_UBSAN=ON + make -j$(nproc) + cd - + - name: Test disasm + run: python3 ./tests/main.py --disasm ./build_sanitizers/disasmtool/disasmtool --conf ./bddisasm_test/conf-x86.json + - name: Test shemu + run: python3 ./tests/main.py --disasm ./build_sanitizers/disasmtool/disasmtool --conf ./bdshemu_test/conf-x86.json - name: Build all run: | mkdir build From ddbba4d6b4bbdc89807595a467811fffe5fe2f7e Mon Sep 17 00:00:00 2001 From: Anichitei Ionel-Cristinel <49393881+ianichitei@users.noreply.github.com> Date: Tue, 17 Sep 2024 11:09:00 +0300 Subject: [PATCH 02/13] ci: Fix a typo --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dd11233..21d1330 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,7 +39,7 @@ jobs: run: | mkdir build_sanitizers cd build_sanitizers - cmke .. -DCMAKE_BUILD_TYPE=Debug -DBDD_ASAN=ON -DBDD_UBSAN=ON + camke .. -DCMAKE_BUILD_TYPE=Debug -DBDD_ASAN=ON -DBDD_UBSAN=ON make -j$(nproc) cd - - name: Test disasm From 13a33e40a39bb05353b4d447b49b1635a39a746e Mon Sep 17 00:00:00 2001 From: Anichitei Ionel-Cristinel <49393881+ianichitei@users.noreply.github.com> Date: Tue, 17 Sep 2024 11:57:30 +0300 Subject: [PATCH 03/13] ci: Fix a typo --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 21d1330..e4b9b73 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,7 +39,7 @@ jobs: run: | mkdir build_sanitizers cd build_sanitizers - camke .. -DCMAKE_BUILD_TYPE=Debug -DBDD_ASAN=ON -DBDD_UBSAN=ON + cmake .. -DCMAKE_BUILD_TYPE=Debug -DBDD_ASAN=ON -DBDD_UBSAN=ON make -j$(nproc) cd - - name: Test disasm From 584332ab98ce9f2e13dcf22b656afc782f4a6a08 Mon Sep 17 00:00:00 2001 From: Anichitei Ionel-Cristinel <49393881+ianichitei@users.noreply.github.com> Date: Tue, 17 Sep 2024 12:10:27 +0300 Subject: [PATCH 04/13] ci: Run tests on Windows and Mac --- .github/workflows/ci.yml | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e4b9b73..7f5027d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,9 +42,9 @@ jobs: cmake .. -DCMAKE_BUILD_TYPE=Debug -DBDD_ASAN=ON -DBDD_UBSAN=ON make -j$(nproc) cd - - - name: Test disasm + - name: Test bddisasm run: python3 ./tests/main.py --disasm ./build_sanitizers/disasmtool/disasmtool --conf ./bddisasm_test/conf-x86.json - - name: Test shemu + - name: Test bdshemu run: python3 ./tests/main.py --disasm ./build_sanitizers/disasmtool/disasmtool --conf ./bdshemu_test/conf-x86.json - name: Build all run: | @@ -99,6 +99,7 @@ jobs: steps: - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 - name: Add msbuild to PATH uses: microsoft/setup-msbuild@v2 - name: Setup Windows SDK @@ -109,6 +110,14 @@ jobs: run: MSBuild /t:Rebuild /p:Configuration=Release /p:Platform=x64 bddisasm.sln - name: Build bddisasm and bdshemu for Win32 run: MSBuild /t:Rebuild /p:Configuration=Release /p:Platform=Win32 bddisasm.sln + - name: Test bddisasm Win32 + - run: python3 tests\main.py --disasm bin\Win32\Release\disasmtool.exe --conf bddisasm_test\conf-x86.json + - name: Test bdshemu Win32 + - run: python3 tests\main.py --disasm bin\Win32\Release\disasmtool.exe --conf bdshemu_test\conf-x86.json + - name: Test bddisasm x64 + - run: python3 tests\main.py --disasm bin\x64\Release\disasmtool.exe --conf bddisasm_test\conf-x86.json + - name: Test bdshemu x64 + - run: python3 tests\main.py --disasm bin\x64\Release\disasmtool.exe --conf bdshemu_test\conf-x86.json - name: Zip binaries if: ${{ github.event_name == 'release' }} run: | @@ -159,6 +168,7 @@ jobs: steps: - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 - name: Build all run: | mkdir build @@ -166,6 +176,10 @@ jobs: cmake .. -DCMAKE_BUILD_TYPE=Release make -j$(nproc) cd - + - name: Test bddisasm + run: python3 ./tests/main.py --disasm ./build_sanitizers/disasmtool/disasmtool --conf ./bddisasm_test/conf-x86.json + - name: Test bdshemu + run: python3 ./tests/main.py --disasm ./build_sanitizers/disasmtool/disasmtool --conf ./bdshemu_test/conf-x86.json Code-checks: From e921cfaab4e77d610d5c8eebefb52e5979b02ad6 Mon Sep 17 00:00:00 2001 From: Anichitei Ionel-Cristinel <49393881+ianichitei@users.noreply.github.com> Date: Tue, 17 Sep 2024 12:12:55 +0300 Subject: [PATCH 05/13] ci: Fix workflow file --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7f5027d..b0a9a21 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -111,13 +111,13 @@ jobs: - name: Build bddisasm and bdshemu for Win32 run: MSBuild /t:Rebuild /p:Configuration=Release /p:Platform=Win32 bddisasm.sln - name: Test bddisasm Win32 - - run: python3 tests\main.py --disasm bin\Win32\Release\disasmtool.exe --conf bddisasm_test\conf-x86.json + run: python3 tests\main.py --disasm bin\Win32\Release\disasmtool.exe --conf bddisasm_test\conf-x86.json - name: Test bdshemu Win32 - - run: python3 tests\main.py --disasm bin\Win32\Release\disasmtool.exe --conf bdshemu_test\conf-x86.json + run: python3 tests\main.py --disasm bin\Win32\Release\disasmtool.exe --conf bdshemu_test\conf-x86.json - name: Test bddisasm x64 - - run: python3 tests\main.py --disasm bin\x64\Release\disasmtool.exe --conf bddisasm_test\conf-x86.json + run: python3 tests\main.py --disasm bin\x64\Release\disasmtool.exe --conf bddisasm_test\conf-x86.json - name: Test bdshemu x64 - - run: python3 tests\main.py --disasm bin\x64\Release\disasmtool.exe --conf bdshemu_test\conf-x86.json + run: python3 tests\main.py --disasm bin\x64\Release\disasmtool.exe --conf bdshemu_test\conf-x86.json - name: Zip binaries if: ${{ github.event_name == 'release' }} run: | From 4b98f1b9e42952976b007aaabc21768818865524 Mon Sep 17 00:00:00 2001 From: Anichitei Ionel-Cristinel <49393881+ianichitei@users.noreply.github.com> Date: Tue, 17 Sep 2024 12:17:54 +0300 Subject: [PATCH 06/13] ci: Fix `disasmtool` path --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b0a9a21..cca8e56 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -173,13 +173,13 @@ jobs: run: | mkdir build cd build - cmake .. -DCMAKE_BUILD_TYPE=Release + cmake .. -DCMAKE_BUILD_TYPE=Release -DBDD_ASAN=ON -DBDD_UBSAN=ON make -j$(nproc) cd - - name: Test bddisasm - run: python3 ./tests/main.py --disasm ./build_sanitizers/disasmtool/disasmtool --conf ./bddisasm_test/conf-x86.json + run: python3 ./tests/main.py --disasm ./build/disasmtool/disasmtool --conf ./bddisasm_test/conf-x86.json - name: Test bdshemu - run: python3 ./tests/main.py --disasm ./build_sanitizers/disasmtool/disasmtool --conf ./bdshemu_test/conf-x86.json + run: python3 ./tests/main.py --disasm ./build/disasmtool/disasmtool --conf ./bdshemu_test/conf-x86.json Code-checks: From ea78026087a155ab34c9037f747ff627dac62fbd Mon Sep 17 00:00:00 2001 From: Anichitei Ionel-Cristinel <49393881+ianichitei@users.noreply.github.com> Date: Tue, 17 Sep 2024 14:22:08 +0300 Subject: [PATCH 07/13] Add `CMakePresets.json` It defines only configure presets to be used mostly by our CI. --- CMakePresets.json | 82 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 CMakePresets.json diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 0000000..fa94d58 --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,82 @@ +{ + "version": 3, + "cmakeMinimumRequired": { + "major": 3, + "minor": 20, + "patch": 0 + }, + "configurePresets": [ + { + "name": "common-options", + "hidden": true, + "description": "Common options shared by all configurations", + "binaryDir": "${sourceDir}/build/${presetName}" + }, + { + "name": "asan", + "inherits": "common-options", + "description": "Enables ASAN", + "cacheVariables": { + "BDD_ASAN": { + "type": "BOOL", + "value": "ON" + } + } + }, + { + "name": "ubsan", + "inherits": "common-options", + "description": "Enables UBSAN", + "cacheVariables": { + "BDD_UBSAN": { + "type": "BOOL", + "value": "ON" + } + } + }, + { + "name": "debug-sanitizers", + "inherits": ["asan", "ubsan"], + "description": "Debug build with ASAN and UBSAN", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug" + } + }, + { + "name": "no-mnemonic", + "inherits": "common-options", + "description": "Excludes mnemonics", + "cacheVariables": { + "BDD_NO_MNEMONIC": { + "type": "BOOL", + "value": "ON" + } + } + }, + + { + "name": "debug", + "inherits": "common-options", + "description": "Debug build", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug" + } + }, + { + "name": "release", + "inherits": "common-options", + "description": "Release build with LTO", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release", + "BDD_LTO": { + "type": "BOOL", + "value": "ON" + } + } + } + ], + "buildPresets": [ + ], + "testPresets": [ + ] +} From 8c1bc973d3a2de6a46644dadc0eee92e3a653b7a Mon Sep 17 00:00:00 2001 From: Anichitei Ionel-Cristinel <49393881+ianichitei@users.noreply.github.com> Date: Tue, 17 Sep 2024 14:41:45 +0300 Subject: [PATCH 08/13] ci: Use a matrix for all the CMake configs --- .github/workflows/ci.yml | 60 +++++++++++++++------------------------- 1 file changed, 22 insertions(+), 38 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cca8e56..75ccd55 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,8 +7,6 @@ on: - '*.md' - 'docs/**' - 'isagenerator/**' - - 'bddisasm_test/**' - - 'bdshemu_test/**' - 'LICENSE' pull_request: branches: [ master ] @@ -16,8 +14,6 @@ on: - '*.md' - 'docs/**' - 'isagenerator/**' - - 'bddisasm_test/**' - - 'bdshemu_test/**' - 'LICENSE' release: types: [published] @@ -28,6 +24,10 @@ jobs: runs-on: ubuntu-latest + strategy: + matrix: + preset: ["debug-sanitizers", "no-mnemonic", "release"] + permissions: attestations: write id-token: write @@ -35,57 +35,41 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Build with sanitizers - run: | - mkdir build_sanitizers - cd build_sanitizers - cmake .. -DCMAKE_BUILD_TYPE=Debug -DBDD_ASAN=ON -DBDD_UBSAN=ON - make -j$(nproc) - cd - + - name: Configure CMake + run: cmake --preset ${{ matrix.preset }} -DCMAKE_INSTALL_PREFIX=/usr + - name: Build + run: make -f ./build/${{ matrix.preset }} -j$(nproc) - name: Test bddisasm - run: python3 ./tests/main.py --disasm ./build_sanitizers/disasmtool/disasmtool --conf ./bddisasm_test/conf-x86.json + run: python3 ./tests/main.py --disasm ./build/${{ matrix.preset }}/disasmtool/disasmtool --conf ./bddisasm_test/conf-x86.json - name: Test bdshemu - run: python3 ./tests/main.py --disasm ./build_sanitizers/disasmtool/disasmtool --conf ./bdshemu_test/conf-x86.json - - name: Build all - run: | - mkdir build - cd build - cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr - make -j$(nproc) - cd - + run: python3 ./tests/main.py --disasm ./build/${{ matrix.preset }}/disasmtool/disasmtool --conf ./bdshemu_test/conf-x86.json - name: Install - run: | - cd build - sudo make install - cd - - - name: Install setuptools + if: ${{ matrix.preset == 'release' }} + run: make -f ./build/${{ matrix.preset }} install + - name: Build pybddisasm + if: ${{ matrix.preset == 'release' }} run: | python3 -m pip install --upgrade pip python3 -m pip install setuptools - - name: Build pybddisasm - run: | cd bindings/pybddisasm python3 setup.py build cd - - name: Create package - if: ${{ github.event_name == 'release' }} - run: | - cd build - sudo make package - cd - + if: ${{ github.event_name == 'release' && matrix.preset == 'release' }} + run: make -f ./build/${{ matrix.preset }} package - name: Attest Build Provenance - if: ${{ github.event_name == 'release' }} + if: ${{ github.event_name == 'release' && matrix.preset == 'release' }} uses: actions/attest-build-provenance@v1.1.0 with: subject-path: | - build/disasmtool/disasmtool - build/*.a - build/*.deb + build/release/disasmtool/disasmtool + build/release/*.a + build/release/*.deb - name: Release - if: ${{ github.event_name == 'release' }} + if: ${{ github.event_name == 'release' && matrix.preset == 'release' }} uses: AButler/upload-release-assets@v3.0 with: - files: 'build/*.deb' + files: 'build/release/*.deb' repo-token: ${{ secrets.GITHUB_TOKEN }} Windows-msbuild: From ca912b2819ee5b7f891c0be0e0721dd8e675bf17 Mon Sep 17 00:00:00 2001 From: Anichitei Ionel-Cristinel <49393881+ianichitei@users.noreply.github.com> Date: Tue, 17 Sep 2024 14:45:24 +0300 Subject: [PATCH 09/13] ci: Fix make paths --- .github/workflows/ci.yml | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 75ccd55..762c7ef 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,7 +38,10 @@ jobs: - name: Configure CMake run: cmake --preset ${{ matrix.preset }} -DCMAKE_INSTALL_PREFIX=/usr - name: Build - run: make -f ./build/${{ matrix.preset }} -j$(nproc) + run: | + cd ./build/${{ matrix.preset }} + make -j$(nproc) + cd - - name: Test bddisasm run: python3 ./tests/main.py --disasm ./build/${{ matrix.preset }}/disasmtool/disasmtool --conf ./bddisasm_test/conf-x86.json - name: Test bdshemu @@ -56,20 +59,23 @@ jobs: cd - - name: Create package if: ${{ github.event_name == 'release' && matrix.preset == 'release' }} - run: make -f ./build/${{ matrix.preset }} package + run: | + cd ./build/${{ matrix.preset }} + make package + cd - - name: Attest Build Provenance if: ${{ github.event_name == 'release' && matrix.preset == 'release' }} uses: actions/attest-build-provenance@v1.1.0 with: subject-path: | - build/release/disasmtool/disasmtool - build/release/*.a - build/release/*.deb + build/${{ matrix.preset }}/disasmtool/disasmtool + build/${{ matrix.preset }}/*.a + build/${{ matrix.preset }}/*.deb - name: Release if: ${{ github.event_name == 'release' && matrix.preset == 'release' }} uses: AButler/upload-release-assets@v3.0 with: - files: 'build/release/*.deb' + files: 'build/${{ matrix.preset }}/*.deb' repo-token: ${{ secrets.GITHUB_TOKEN }} Windows-msbuild: From 1b46174e001dd19b5d54088d50f995ac4590dc66 Mon Sep 17 00:00:00 2001 From: Anichitei Ionel-Cristinel <49393881+ianichitei@users.noreply.github.com> Date: Tue, 17 Sep 2024 15:18:41 +0300 Subject: [PATCH 10/13] ci: Don't run tests for `no-mnemonic` builds We can't test the output if we don't have the instruction names. --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 762c7ef..ec86c8b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,6 +25,7 @@ jobs: runs-on: ubuntu-latest strategy: + fail-fast: false matrix: preset: ["debug-sanitizers", "no-mnemonic", "release"] @@ -43,8 +44,10 @@ jobs: make -j$(nproc) cd - - name: Test bddisasm + if: ${{ matrix.preset != 'no-mnemonic' }} run: python3 ./tests/main.py --disasm ./build/${{ matrix.preset }}/disasmtool/disasmtool --conf ./bddisasm_test/conf-x86.json - name: Test bdshemu + if: ${{ matrix.preset != 'no-mnemonic' }} run: python3 ./tests/main.py --disasm ./build/${{ matrix.preset }}/disasmtool/disasmtool --conf ./bdshemu_test/conf-x86.json - name: Install if: ${{ matrix.preset == 'release' }} From 1312f0726d60f0ce4609de64d3520aae73dd1e1f Mon Sep 17 00:00:00 2001 From: Anichitei Ionel-Cristinel <49393881+ianichitei@users.noreply.github.com> Date: Tue, 17 Sep 2024 15:21:10 +0300 Subject: [PATCH 11/13] ci: Fix `make install` path --- .github/workflows/ci.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ec86c8b..8ef8b67 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -51,7 +51,10 @@ jobs: run: python3 ./tests/main.py --disasm ./build/${{ matrix.preset }}/disasmtool/disasmtool --conf ./bdshemu_test/conf-x86.json - name: Install if: ${{ matrix.preset == 'release' }} - run: make -f ./build/${{ matrix.preset }} install + run: | + cd ./build/${{ matrix.preset }} + make install + cd - - name: Build pybddisasm if: ${{ matrix.preset == 'release' }} run: | From 10224d00b149a754bf714ef8c2c77901b631d9b6 Mon Sep 17 00:00:00 2001 From: Anichitei Ionel-Cristinel <49393881+ianichitei@users.noreply.github.com> Date: Tue, 17 Sep 2024 15:23:04 +0300 Subject: [PATCH 12/13] Update ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8ef8b67..6f9a81c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -53,7 +53,7 @@ jobs: if: ${{ matrix.preset == 'release' }} run: | cd ./build/${{ matrix.preset }} - make install + sudo make install cd - - name: Build pybddisasm if: ${{ matrix.preset == 'release' }} From 7c5bddb9a4116262da1d863c33c72771149f1b4f Mon Sep 17 00:00:00 2001 From: Anichitei Ionel-Cristinel <49393881+ianichitei@users.noreply.github.com> Date: Tue, 17 Sep 2024 15:33:43 +0300 Subject: [PATCH 13/13] Update ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6f9a81c..e12cef6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -67,7 +67,7 @@ jobs: if: ${{ github.event_name == 'release' && matrix.preset == 'release' }} run: | cd ./build/${{ matrix.preset }} - make package + sudo make package cd - - name: Attest Build Provenance if: ${{ github.event_name == 'release' && matrix.preset == 'release' }}