Skip to content

Commit 191db14

Browse files
authored
Modern Testing (capstone-engine#2456)
1 parent df72286 commit 191db14

1,756 files changed

Lines changed: 613663 additions & 22863 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/CITest.yml

Lines changed: 45 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
- "docs/**"
77
- "ChangeLog"
88
- "CREDITS.TXT"
9-
- "COMPILE.TXT"
9+
- "COMPILE_MAKE.TXT"
1010
- "COMPILE_MSVC.TXT"
1111
- "COMPILE_CMAKE.TXT"
1212
- "HACK.TXT"
@@ -34,41 +34,45 @@ jobs:
3434
os: ubuntu-22.04,
3535
arch: x64,
3636
build-system: 'make',
37+
diet-build: 'OFF',
3738
enable-asan: 'OFF'
3839
}
3940
- {
4041
name: 'ubuntu-22.04 x64 cmake',
4142
os: ubuntu-22.04,
4243
arch: x64,
4344
build-system: 'cmake',
45+
diet-build: 'OFF',
4446
enable-asan: 'OFF'
4547
}
4648
- {
47-
name: 'ubuntu-22.04 x64 ASAN',
48-
os: ubuntu-latest,
49+
name: 'ubuntu-24.04 x64 ASAN',
50+
os: ubuntu-24.04,
4951
arch: x64,
5052
build-system: 'cmake',
53+
diet-build: 'OFF',
5154
enable-asan: 'ON'
5255
}
5356

5457
steps:
5558
- uses: actions/checkout@v3
5659

57-
- name: prepare
60+
- name: Set up Python
61+
uses: actions/setup-python@v4
62+
with:
63+
python-version: ${{ matrix.config.python-version }}
64+
65+
- name: Prepare fuzzing
5866
run: |
5967
export LD_LIBRARY_PATH=`pwd`/tests/:$LD_LIBRARY_PATH
6068
wget https://github.com/groundx/capstonefuzz/raw/master/corpus/corpus-libFuzzer-capstone_fuzz_disasmnext-latest.zip
6169
unzip -q corpus-libFuzzer-capstone_fuzz_disasmnext-latest.zip -d suite/fuzz
62-
git clone https://git.cryptomilk.org/projects/cmocka.git suite/cstest/cmocka
63-
chmod +x suite/cstest/build_cstest.sh
6470
6571
- name: make
6672
if: startsWith(matrix.config.build-system, 'make')
6773
run: |
6874
./make.sh
69-
make check
7075
sudo make install
71-
cp libcapstone.so.5 libcapstone.so.5.0
7276
7377
- name: cmake
7478
if: startsWith(matrix.config.build-system, 'cmake')
@@ -82,47 +86,55 @@ jobs:
8286
# build shared library
8387
cmake -DCAPSTONE_INSTALL=1 -DBUILD_SHARED_LIBS=1 -DCMAKE_INSTALL_PREFIX=/usr -DCAPSTONE_BUILD_CSTEST=ON -DENABLE_ASAN=${asan} ..
8488
sudo cmake --build . --config Release --target install
85-
cp libcapstone.* ../
86-
cp libcapstone.* ../tests/
87-
cp test_* ../tests/
8889
8990
- name: Lower number of KASL randomized address bits
9091
run: |
9192
# Work-around ASAN bug https://github.com/google/sanitizers/issues/1716
9293
sudo sysctl vm.mmap_rnd_bits=28
9394
94-
- name: "Compatibility header test build"
95-
if: matrix.config.diet-build == 'OFF'
96-
env:
97-
asan: ${{ matrix.config.enable-asan }}
95+
- name: "Compatibility header test"
96+
if: startsWith(matrix.config.build-system, 'cmake') && matrix.config.diet-build == 'OFF'
9897
run: |
99-
cd "$(git rev-parse --show-toplevel)/suite/auto-sync/c_tests/"
100-
if [ "$asan" = "ON" ]; then
101-
clang -lcapstone -fsanitize=address src/test_arm64_compatibility_header.c -o test_arm64_compatibility_header
102-
else
103-
clang -lcapstone src/test_arm64_compatibility_header.c -o test_arm64_compatibility_header
104-
fi
105-
./test_arm64_compatibility_header
98+
ctest --test-dir build --output-on-failure -R ASCompatibilityHeaderTest
10699
107100
- name: cstool - reaches disassembler engine
108101
run: |
109102
sh suite/run_invalid_cstool.sh
110103
111-
- name: cstest (cmake)
104+
- name: cstest unit tests
112105
if: startsWith(matrix.config.build-system, 'cmake')
113106
run: |
114-
python suite/cstest/cstest_report.py -D -d suite/MC
115-
python suite/cstest/cstest_report.py -D -f suite/cstest/issues.cs
116-
python suite/cstest/cstest_report.py -D -f tests/cs_details/issue.cs
107+
ctest --test-dir build --output-on-failure -R UnitCSTest
117108
118-
- name: cstest (make)
119-
if: startsWith(matrix.config.build-system, 'make')
109+
- name: cstest integration tests
110+
if: startsWith(matrix.config.build-system, 'cmake')
111+
run: |
112+
ctest --test-dir build --output-on-failure -R IntegrationCSTest
113+
114+
- name: cstest MC
115+
if: startsWith(matrix.config.build-system, 'cmake')
116+
run: |
117+
ctest --test-dir build --output-on-failure -R MCTests
118+
119+
- name: cstest details
120+
if: startsWith(matrix.config.build-system, 'cmake')
121+
run: |
122+
ctest --test-dir build --output-on-failure -R DetailTests
123+
124+
- name: cstest issues
125+
if: startsWith(matrix.config.build-system, 'cmake')
126+
run: |
127+
ctest --test-dir build --output-on-failure -R IssueTests
128+
129+
- name: cstest features
130+
if: startsWith(matrix.config.build-system, 'cmake')
131+
run: |
132+
ctest --test-dir build --output-on-failure -R FeaturesTests
133+
134+
- name: Legacy integration tests
135+
if: startsWith(matrix.config.build-system, 'cmake')
120136
run: |
121-
cd suite/cstest && ./build_cstest.sh
122-
python cstest_report.py -D -t build/cstest -d ../MC
123-
python cstest_report.py -D -t build/cstest -f issues.cs
124-
python cstest_report.py -D -t build/cstest -f ../../tests/cs_details/issue.cs
125-
cd ../../
137+
ctest --test-dir build --output-on-failure -R legacy*
126138
127139
Windows:
128140
runs-on: ${{ matrix.config.os }}

.github/workflows/auto-sync.yml

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,17 @@ on:
33
push:
44
paths:
55
- "suite/auto-sync/**"
6+
- ".github/workflows/auto-sync.yml"
67
pull_request:
78

9+
# Stop previous runs on the same branch on new push
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
814
jobs:
915
check:
10-
runs-on: ubuntu-latest
16+
runs-on: ubuntu-24.04
1117
defaults:
1218
run:
1319
working-directory: suite/auto-sync/
@@ -30,16 +36,40 @@ jobs:
3036
run: |
3137
python3.11 -m black --check src/autosync
3238
33-
- name: Build llvm-tblgen
39+
- name: Install llvm-mc
40+
run: |
41+
sudo apt install llvm-18
42+
llvm-mc-18 --version
43+
FileCheck-18 --version
44+
sudo ln -s $(whereis -b llvm-mc-18 | grep -Eo "/.*") /usr/local/bin/llvm-mc
45+
sudo ln -s $(whereis -b FileCheck-18 | grep -Eo "/.*") /usr/local/bin/FileCheck
46+
llvm-mc --version
47+
FileCheck --version
48+
49+
- name: Clone llvm-capstone
3450
run: |
3551
git clone https://github.com/capstone-engine/llvm-capstone.git vendor/llvm_root
52+
53+
- name: Build llvm-tblgen
54+
run: |
3655
cd vendor/llvm_root
3756
mkdir build
3857
cd build
3958
cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug ../llvm
4059
cmake --build . --target llvm-tblgen --config Debug
4160
cd ../../../
4261
62+
- name: Test Header patcher
63+
run: |
64+
python -m unittest src/autosync/Tests/test_header_patcher.py
65+
python -m unittest src/autosync/Tests/test_mcupdater.py
66+
67+
- name: Remove llvm-mc
68+
run: |
69+
sudo apt remove llvm-18
70+
sudo rm /usr/local/bin/llvm-mc
71+
sudo rm /usr/local/bin/FileCheck
72+
4373
- name: Test generation of inc files
4474
run: |
4575
./src/autosync/ASUpdater.py -d -a AArch64 -s IncGen
@@ -63,11 +93,9 @@ jobs:
6393
./src/autosync/ASUpdater.py --ci -d -a PPC -s Translate
6494
./src/autosync/ASUpdater.py --ci -d -a LoongArch -s Translate
6595
66-
- name: Test Header patcher
67-
run: |
68-
python -m unittest src/autosync/Tests/test_header_patcher.py
69-
python -m unittest src/autosync/Tests/test_mcupdater.py
70-
7196
- name: Differ - Test save file is up-to-date
7297
run: |
7398
./src/autosync/cpptranslator/Differ.py -a AArch64 --check_saved
99+
./src/autosync/cpptranslator/Differ.py -a ARM --check_saved
100+
./src/autosync/cpptranslator/Differ.py -a PPC --check_saved
101+
./src/autosync/cpptranslator/Differ.py -a LoongArch --check_saved

.github/workflows/clang-tidy.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ on:
88

99
jobs:
1010
analyze:
11-
runs-on: ubuntu-latest
11+
runs-on: ubuntu-24.04
1212

1313
name: clang-tidy
1414
steps:
15-
- uses: actions/checkout@v3
15+
- uses: actions/checkout@v4
1616
with:
1717
fetch-depth: 0
1818
- name: Install clang-tidy
@@ -26,13 +26,18 @@ jobs:
2626
CC=clang sudo cmake --build . --config Release
2727
cd ..
2828
29-
- name: Install clang-tidy-15
29+
- name: Install clang-tidy-18
3030
run: |
31-
sudo apt install clang-tidy-15
31+
sudo apt install clang-tidy-18
3232
3333
- name: Check for warnings
3434
env:
3535
base_sha: ${{ github.event.pull_request.base.sha }}
3636
head_sha: ${{ github.event.pull_request.head.sha }}
3737
run: |
3838
./run-clang-tidy.sh build
39+
40+
- uses: actions/upload-artifact@v4
41+
if: ${{ failure() }}
42+
with:
43+
path: ct-warnings.txt

.github/workflows/python-tests.yml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,30 @@ jobs:
2828
- name: Build and install capstone
2929
run: pip install ./bindings/python
3030

31-
- name: Run tests
31+
- name: Install cstest_py
32+
run: pip install ./bindings/python/cstest_py
33+
34+
- name: Run legacy tests
3235
run: python ./bindings/python/tests/test_all.py
36+
37+
- name: cstest_py integration tests
38+
run: |
39+
cd suite/cstest/test/
40+
python3 ./integration_tests.py cstest_py
41+
cd ../../../
42+
43+
- name: cstest_py MC
44+
run: |
45+
cstest_py tests/MC/
46+
47+
- name: cstest_py details
48+
run: |
49+
cstest_py tests/details/
50+
51+
- name: cstest_py issues
52+
run: |
53+
cstest_py tests/issues/
54+
55+
- name: cstest_py features
56+
run: |
57+
cstest_py tests/features/

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
# python
2626
bindings/python/build/
2727
bindings/python/capstone.egg-info/
28+
bindings/python/cstest_py/src/cstest_py.egg**
2829
bindings/cython/capstone.egg-info/
2930
*.pyc
3031

@@ -133,7 +134,6 @@ fuzz_disasm
133134
fuzz_decode_platform
134135
capstone_get_setup
135136
suite/fuzz/corpus
136-
suite/cstest/cmocka/
137137

138138
*.s
139139

@@ -147,3 +147,6 @@ android-ndk-*
147147

148148
# Auto-sync files
149149
suite/auto-sync/src/autosync.egg-info
150+
151+
# clangd cache
152+
/.cache

0 commit comments

Comments
 (0)