mirror of
https://github.com/capstone-engine/capstone.git
synced 2026-10-12 02:11:43 +00:00
Add Valgrind cmake tests. (#3030)
This commit is contained in:
@@ -120,6 +120,11 @@ jobs:
|
||||
wget https://github.com/groundx/capstonefuzz/raw/master/corpus/corpus-libFuzzer-capstone_fuzz_disasmnext-latest.zip
|
||||
unzip -q corpus-libFuzzer-capstone_fuzz_disasmnext-latest.zip -d suite/fuzz
|
||||
|
||||
- name: Install test dependencies
|
||||
run: |
|
||||
sudo apt-get -y update
|
||||
sudo apt-get -y install valgrind
|
||||
|
||||
- name: make
|
||||
if: startsWith(matrix.config.build-system, 'make')
|
||||
run: |
|
||||
@@ -167,12 +172,12 @@ jobs:
|
||||
- name: unit tests
|
||||
if: startsWith(matrix.config.build-system, 'cmake')
|
||||
run: |
|
||||
ctest --test-dir build --output-on-failure -R unit_*
|
||||
ctest --test-dir build --output-on-failure -R "^unit_*"
|
||||
|
||||
- name: "Integration tests"
|
||||
if: startsWith(matrix.config.build-system, 'cmake') && matrix.config.diet-build == 'OFF'
|
||||
run: |
|
||||
ctest --test-dir build --output-on-failure -R integration_*
|
||||
ctest --test-dir build --output-on-failure -R "^integration_*"
|
||||
|
||||
- name: cstool - reaches disassembler engine
|
||||
run: |
|
||||
@@ -191,22 +196,22 @@ jobs:
|
||||
- name: cstest MC
|
||||
if: startsWith(matrix.config.build-system, 'cmake')
|
||||
run: |
|
||||
ctest --test-dir build --output-on-failure -R MCTests
|
||||
ctest --test-dir build --output-on-failure -R "^MCTests"
|
||||
|
||||
- name: cstest details
|
||||
if: startsWith(matrix.config.build-system, 'cmake')
|
||||
run: |
|
||||
ctest --test-dir build --output-on-failure -R DetailTests
|
||||
ctest --test-dir build --output-on-failure -R "^DetailTests"
|
||||
|
||||
- name: cstest issues
|
||||
if: startsWith(matrix.config.build-system, 'cmake')
|
||||
run: |
|
||||
ctest --test-dir build --output-on-failure -R IssueTests
|
||||
ctest --test-dir build --output-on-failure -R "^IssueTests"
|
||||
|
||||
- name: cstest features
|
||||
if: startsWith(matrix.config.build-system, 'cmake')
|
||||
run: |
|
||||
ctest --test-dir build --output-on-failure -R FeaturesTests
|
||||
ctest --test-dir build --output-on-failure -R "^FeaturesTests"
|
||||
|
||||
- name: Legacy integration tests
|
||||
if: startsWith(matrix.config.build-system, 'cmake')
|
||||
@@ -216,12 +221,7 @@ jobs:
|
||||
- name: Valgrind cstest
|
||||
if: startsWith(matrix.config.build-system, 'cmake') && startsWith(matrix.config.enable-asan, 'OFF') && startsWith(matrix.config.enable-msan, 'OFF')
|
||||
run: |
|
||||
sudo apt-get -y update
|
||||
sudo apt-get -y install valgrind
|
||||
valgrind --leak-check=full cstest tests/details
|
||||
valgrind --leak-check=full cstest tests/features
|
||||
valgrind --leak-check=full cstest tests/issues
|
||||
valgrind --leak-check=full cstest tests/MC
|
||||
ctest --test-dir build --output-on-failure -R valgrind_*
|
||||
|
||||
- name: Compatibility header generation
|
||||
# clang-format-20 is only available in Ubuntu 24.04
|
||||
|
||||
@@ -169,32 +169,32 @@ jobs:
|
||||
- name: unit tests
|
||||
if: ${{ matrix.config.skip_tests != true }}
|
||||
run: |
|
||||
ctest --test-dir build --output-on-failure -R unit_*
|
||||
ctest --test-dir build --output-on-failure -R "^unit_*"
|
||||
|
||||
- name: "Integration tests"
|
||||
if: ${{ matrix.config.skip_tests != true }}
|
||||
run: |
|
||||
ctest --test-dir build --output-on-failure -R integration_c_*
|
||||
ctest --test-dir build --output-on-failure -R "^integration_c_*"
|
||||
|
||||
- name: cstest MC
|
||||
if: ${{ matrix.config.skip_tests != true }}
|
||||
run: |
|
||||
ctest --test-dir build --output-on-failure -R MCTests
|
||||
ctest --test-dir build --output-on-failure -R "^MCTests"
|
||||
|
||||
- name: cstest details
|
||||
if: ${{ matrix.config.skip_tests != true }}
|
||||
run: |
|
||||
ctest --test-dir build --output-on-failure -R DetailTests
|
||||
ctest --test-dir build --output-on-failure -R "^DetailTests"
|
||||
|
||||
- name: cstest issues
|
||||
if: ${{ matrix.config.skip_tests != true }}
|
||||
run: |
|
||||
ctest --test-dir build --output-on-failure -R IssueTests
|
||||
ctest --test-dir build --output-on-failure -R "^IssueTests"
|
||||
|
||||
- name: cstest features
|
||||
if: ${{ matrix.config.skip_tests != true }}
|
||||
run: |
|
||||
ctest --test-dir build --output-on-failure -R FeaturesTests
|
||||
ctest --test-dir build --output-on-failure -R "^FeaturesTests"
|
||||
|
||||
- name: Legacy integration tests
|
||||
if: ${{ matrix.config.skip_tests != true }}
|
||||
|
||||
@@ -1098,6 +1098,7 @@ if(CAPSTONE_BUILD_CSTOOL)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
find_program(VALGRIND_BIN NAMES valgrind)
|
||||
if(CAPSTONE_BUILD_CSTEST)
|
||||
enable_testing()
|
||||
set(CSTEST_DIR ${PROJECT_SOURCE_DIR}/suite/cstest)
|
||||
|
||||
@@ -161,6 +161,25 @@ add_test(NAME FeaturesTests
|
||||
COMMAND cstest ${PROJECT_SOURCE_DIR}/tests/features
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||
)
|
||||
if (VALGRIND_BIN)
|
||||
add_test(NAME valgrind_MCTests
|
||||
COMMAND ${VALGRIND_BIN} --leak-check=full --error-exitcode=1 cstest ${PROJECT_SOURCE_DIR}/tests/MC
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||
)
|
||||
add_test(NAME valgrind_DetailTests
|
||||
COMMAND ${VALGRIND_BIN} --leak-check=full --error-exitcode=1 cstest ${PROJECT_SOURCE_DIR}/tests/details
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||
)
|
||||
add_test(NAME valgrind_IssueTests
|
||||
COMMAND ${VALGRIND_BIN} --leak-check=full --error-exitcode=1 cstest ${PROJECT_SOURCE_DIR}/tests/issues
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||
)
|
||||
add_test(NAME valgrind_FeaturesTests
|
||||
COMMAND ${VALGRIND_BIN} --leak-check=full --error-exitcode=1 cstest ${PROJECT_SOURCE_DIR}/tests/features
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||
)
|
||||
endif()
|
||||
|
||||
|
||||
# These tests must be run independently. Otherwise we won't detect when one succeeds.
|
||||
# Because cstest will always return not 0 from the first failing test onwards.
|
||||
|
||||
@@ -17,6 +17,14 @@ add_test(NAME unit_cstest
|
||||
COMMAND unit_test
|
||||
WORKING_DIRECTORY ${CSTEST_TEST_DIR}
|
||||
)
|
||||
|
||||
if (VALGRIND_BIN)
|
||||
add_test(NAME valgrind_unit_cstest
|
||||
COMMAND ${VALGRIND_BIN} --leak-check=full --error-exitcode=1 $<TARGET_FILE:unit_test>
|
||||
WORKING_DIRECTORY ${CSTEST_TEST_DIR}
|
||||
)
|
||||
endif()
|
||||
|
||||
add_test(NAME integration_py_cstest
|
||||
COMMAND python3 ${CSTEST_TEST_DIR}/integration_tests.py $<TARGET_FILE:cstest>
|
||||
WORKING_DIRECTORY ${CSTEST_TEST_DIR}
|
||||
|
||||
@@ -42,5 +42,8 @@ foreach(TSRC ${INTEGRATION_TEST_SRC})
|
||||
string(REGEX REPLACE ".c$" "" TBIN ${TSRC})
|
||||
add_executable(${TBIN} "${TESTS_INTEGRATION_DIR}/${TSRC}")
|
||||
target_link_libraries(${TBIN} PRIVATE capstone)
|
||||
add_test(NAME "integration_${TBIN}" COMMAND ${TBIN})
|
||||
add_test(NAME "integration_${TBIN}" COMMAND $<TARGET_FILE:${TBIN}>)
|
||||
if(VALGRIND_BIN)
|
||||
add_test(NAME "valgrind_integration_${TBIN}" COMMAND ${VALGRIND_BIN} --leak-check=full --error-exitcode=1 $<TARGET_FILE:${TBIN}>)
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
Reference in New Issue
Block a user