Skip to content

Commit fb21e30

Browse files
committed
tests : use CMake definitions for model/sample paths
This commit modifies the test-vad and test-vad-full tests to use CMake definitions for the model and sample paths. The motivation for this is that currently the tests use relative paths which might not always be correct depending on the working directory. With the changes in this commit the tests can be run usins ctest: ```console $ ctest -R ^test-vad$ --test-dir build ``` Or directly (which is not currently possible without this fix): ``` ./build/bin/test-vad ``` Resolves: ggml-org#3404
1 parent 7745fcf commit fb21e30

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

tests/CMakeLists.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ set(VAD_TEST test-vad)
9393
add_executable(${VAD_TEST} ${VAD_TEST}.cpp)
9494
target_include_directories(${VAD_TEST} PRIVATE ../include ../ggml/include ../examples)
9595
target_link_libraries(${VAD_TEST} PRIVATE common)
96+
target_compile_definitions(${VAD_TEST} PRIVATE
97+
VAD_MODEL_PATH="${PROJECT_SOURCE_DIR}/models/for-tests-silero-v5.1.2-ggml.bin"
98+
SAMPLE_PATH="${PROJECT_SOURCE_DIR}/samples/jfk.wav")
9699
add_test(NAME ${VAD_TEST} COMMAND ${VAD_TEST})
97100
set_tests_properties(${VAD_TEST} PROPERTIES LABELS "unit")
98101

@@ -101,5 +104,9 @@ set(VAD_TEST test-vad-full)
101104
add_executable(${VAD_TEST} ${VAD_TEST}.cpp)
102105
target_include_directories(${VAD_TEST} PRIVATE ../include ../ggml/include ../examples)
103106
target_link_libraries(${VAD_TEST} PRIVATE common)
107+
target_compile_definitions(${VAD_TEST} PRIVATE
108+
WHISPER_MODEL_PATH="${PROJECT_SOURCE_DIR}/models/ggml-base.en.bin"
109+
VAD_MODEL_PATH="${PROJECT_SOURCE_DIR}/models/for-tests-silero-v5.1.2-ggml.bin"
110+
SAMPLE_PATH="${PROJECT_SOURCE_DIR}/samples/jfk.wav")
104111
add_test(NAME ${VAD_TEST} COMMAND ${VAD_TEST})
105-
set_tests_properties(${VAD_TARGET} PROPERTIES LABELS "base;en")
112+
set_tests_properties(${VAD_TEST} PROPERTIES LABELS "base;en")

tests/test-vad-full.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
#include <cassert>
1414

1515
int main() {
16-
std::string whisper_model_path = "../../models/ggml-base.en.bin";
17-
std::string vad_model_path = "../../models/for-tests-silero-v5.1.2-ggml.bin";
18-
std::string sample_path = "../../samples/jfk.wav";
16+
std::string whisper_model_path = WHISPER_MODEL_PATH;
17+
std::string vad_model_path = VAD_MODEL_PATH;
18+
std::string sample_path = SAMPLE_PATH;
1919

2020
// Load the sample audio file
2121
std::vector<float> pcmf32;

tests/test-vad.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ struct whisper_vad_segments * test_detect_timestamps(
4848
}
4949

5050
int main() {
51-
std::string vad_model_path = "../../models/for-tests-silero-v5.1.2-ggml.bin";
52-
std::string sample_path = "../../samples/jfk.wav";
51+
std::string vad_model_path = VAD_MODEL_PATH;
52+
std::string sample_path = SAMPLE_PATH;
5353

5454
// Load the sample audio file
5555
std::vector<float> pcmf32;

0 commit comments

Comments
 (0)