Skip to content

Commit e076794

Browse files
committed
Add CTest targets
1 parent 57b9b3b commit e076794

File tree

2 files changed

+45
-7
lines changed

2 files changed

+45
-7
lines changed

CMakeLists.txt

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,35 @@ set_target_properties(kanzi PROPERTIES
141141
add_executable(kanzi_static ${APP_SOURCES})
142142
target_link_libraries(kanzi_static libkanzi)
143143

144-
# Custom target to build all tests
145-
add_custom_target(test
144+
# Custom target to build all tests (Named to avoid conflict with CTest 'make test')
145+
add_custom_target(build_tests
146146
DEPENDS testBWT testTransforms testEntropyCodec testDefaultBitStream testCompressedStream testAPI
147147
)
148+
149+
# --- CTest Configuration ---
150+
enable_testing()
151+
152+
if(DEFINED ENV{TMPDIR})
153+
set(SYSTEM_TEMP_DIR "$ENV{TMPDIR}") # Linux/macOS standard
154+
elseif(DEFINED ENV{TEMP})
155+
set(SYSTEM_TEMP_DIR "$ENV{TEMP}") # Windows standard
156+
elseif(DEFINED ENV{TMP})
157+
set(SYSTEM_TEMP_DIR "$ENV{TMP}") # Windows fallback
158+
else()
159+
set(SYSTEM_TEMP_DIR "/tmp") # Fallback default
160+
endif()
161+
162+
file(TO_CMAKE_PATH "${SYSTEM_TEMP_DIR}" SYSTEM_TEMP_DIR)
163+
164+
# Register executables as CTest tests
165+
# Syntax: add_test(NAME <NameInReport> COMMAND <TargetName>)
166+
add_test(NAME BWT COMMAND testBWT -noperf)
167+
add_test(NAME Transforms COMMAND testTransforms -type=all -noperf)
168+
add_test(NAME EntropyCodec COMMAND testEntropyCodec -type=all -noperf)
169+
add_test(NAME DefaultBitStream COMMAND testDefaultBitStream ${SYSTEM_TEMP_DIR}/testDefaultBitStream.tmp -noperf)
170+
add_test(NAME CompressedStream COMMAND testCompressedStream)
171+
add_test(NAME API COMMAND testAPI)
172+
148173
# Custom target to build static libraries
149174
add_custom_target(static_lib
150175
DEPENDS libkanzi #libkanzi_comp libkanzi_decomp

src/test/TestBWT.cpp

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -270,16 +270,29 @@ int testBWTSpeed(bool isBWT, int iter, bool isSmallSize)
270270
}
271271

272272
#ifdef __GNUG__
273-
int main()
273+
int main(int argc, const char* argv[])
274274
#else
275-
int TestBWT_main()
275+
int TestBWT_main(int argc, const char* argv[])
276276
#endif
277277
{
278+
bool doPerf = true;
279+
280+
if (argc > 1) {
281+
string str = argv[1];
282+
transform(str.begin(), str.end(), str.begin(), ::toupper);
283+
doPerf = str != "-NOPERF";
284+
}
285+
278286
int res = 0;
279287
res |= testBWTCorrectness(true);
280288
res |= testBWTCorrectness(false);
281-
res |= testBWTSpeed(true, 200, true); // test MergeTPSI inverse
282-
res |= testBWTSpeed(true, 5, false); // test BiPSIv2 inverse
283-
res |= testBWTSpeed(false, 200, true);
289+
290+
if (doPerf) {
291+
res |= testBWTSpeed(true, 200, true); // test MergeTPSI inverse
292+
res |= testBWTSpeed(true, 5, false); // test BiPSIv2 inverse
293+
res |= testBWTSpeed(false, 200, true);
294+
}
295+
284296
return res;
285297
}
298+

0 commit comments

Comments
 (0)