Skip to content

Commit e16b02a

Browse files
committed
Add negative tests to cmake and CI.
1 parent b2f0ed0 commit e16b02a

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

.github/workflows/CITest.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,16 @@ jobs:
147147
run: |
148148
sh suite/run_invalid_cstool.sh
149149
150+
- name: cstest negatives
151+
if: startsWith(matrix.config.build-system, 'cmake')
152+
run: |
153+
ctest --test-dir build --output-on-failure -R NegativeTests1
154+
ctest --test-dir build --output-on-failure -R NegativeTests2
155+
ctest --test-dir build --output-on-failure -R NegativeTests3
156+
ctest --test-dir build --output-on-failure -R NegativeTests4
157+
ctest --test-dir build --output-on-failure -R NegativeTests5
158+
ctest --test-dir build --output-on-failure -R NegativeTests6
159+
150160
- name: cstest MC
151161
if: startsWith(matrix.config.build-system, 'cmake')
152162
run: |
@@ -177,7 +187,10 @@ jobs:
177187
run: |
178188
sudo apt-get -y update
179189
sudo apt-get -y install valgrind
180-
valgrind --leak-check=full cstest tests
190+
valgrind --leak-check=full cstest tests/details
191+
valgrind --leak-check=full cstest tests/features
192+
valgrind --leak-check=full cstest tests/issues
193+
valgrind --leak-check=full cstest tests/MC
181194
182195
- name: Comaptibility header generation
183196
# clang-format-17 is only available in Ubuntu 24.04

suite/cstest/CMakeLists.txt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,40 @@ add_test(FeaturesTests
8888
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
8989
)
9090

91+
# These tests must be run independently. Otherwise we won't detect when one succeeds.
92+
# Because cstest will always return not 0 from the first failing test onwards.
93+
# But we need to ensure all of them fail always.
94+
add_test(NegativeTests1
95+
cstest ${PROJECT_SOURCE_DIR}/tests/negative/should_fail_I.yaml
96+
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
97+
)
98+
set_property(TEST NegativeTests1 PROPERTY WILL_FAIL TRUE)
99+
add_test(NegativeTests2
100+
cstest ${PROJECT_SOURCE_DIR}/tests/negative/should_fail_II.yaml
101+
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
102+
)
103+
set_property(TEST NegativeTests2 PROPERTY WILL_FAIL TRUE)
104+
add_test(NegativeTests3
105+
cstest ${PROJECT_SOURCE_DIR}/tests/negative/should_fail_III.yaml
106+
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
107+
)
108+
set_property(TEST NegativeTests3 PROPERTY WILL_FAIL TRUE)
109+
add_test(NegativeTests4
110+
cstest ${PROJECT_SOURCE_DIR}/tests/negative/should_fail_IV.yaml
111+
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
112+
)
113+
set_property(TEST NegativeTests4 PROPERTY WILL_FAIL TRUE)
114+
add_test(NegativeTests5
115+
cstest ${PROJECT_SOURCE_DIR}/tests/negative/should_fail_V.yaml
116+
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
117+
)
118+
set_property(TEST NegativeTests5 PROPERTY WILL_FAIL TRUE)
119+
add_test(NegativeTests6
120+
cstest ${PROJECT_SOURCE_DIR}/tests/negative/should_fail_VI.yaml
121+
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
122+
)
123+
set_property(TEST NegativeTests6 PROPERTY WILL_FAIL TRUE)
124+
91125

92126
if(CAPSTONE_INSTALL)
93127
install(TARGETS cstest EXPORT capstone-targets DESTINATION ${CMAKE_INSTALL_BINDIR})

0 commit comments

Comments
 (0)