Files
whisper.cpp/tests/test-whisper-zero-samples.cpp
T
Abir Deol 79f2d92112 tests : load backends before init when built with GGML_BACKEND_DL (#4031)
With GGML_BACKEND_DL=ON no backend is registered until something calls
ggml_backend_load_all(). Every example does; the tests never did, so
whisper_init_* and parakeet_init_* ran with devices = 0 and aborted on
GGML_ASSERT(device) in ggml_backend_dev_backend_reg.

Three tests aborted on such a build - test-whisper-zero-samples,
test-vad and test-parakeet - taking ctest -L gh to 2 of 4.
test-vad-full has the same fault and reaches it only once a real
base.en model is present.

No workflow caught this because none pairs the two: build-clang,
build-gcc and build-sanitize run ctest -L gh but never set
GGML_BACKEND_DL, while release.yml sets it and runs no tests.

ggml_backend_load_all() is already reachable through whisper.h and
parakeet.h via ggml-cpu.h, so no new include is needed.

Resolves: https://github.com/ggml-org/whisper.cpp/issues/4030
2026-09-08 07:14:42 +02:00

33 lines
788 B
C++

#include "whisper.h"
#include <cstdio>
#ifdef NDEBUG
#undef NDEBUG
#endif
#include <cassert>
int main() {
ggml_backend_load_all();
struct whisper_context_params cparams = whisper_context_default_params();
cparams.use_gpu = false;
struct whisper_context * ctx = whisper_init_from_file_with_params(WHISPER_MODEL_PATH, cparams);
assert(ctx != nullptr);
struct whisper_full_params params = whisper_full_default_params(WHISPER_SAMPLING_GREEDY);
params.no_timestamps = true;
params.print_progress = false;
params.print_realtime = false;
const int rc = whisper_full(ctx, params, nullptr, 0);
assert(rc == 0);
assert(whisper_full_n_segments(ctx) == 0);
whisper_free(ctx);
printf("test-whisper-zero-samples: OK\n");
return 0;
}