test(llama.cpp): validate downloader failure paths

This commit is contained in:
游雁
2026-07-15 04:35:18 +00:00
parent 9c17931645
commit 916c175ec9
2 changed files with 29 additions and 2 deletions
+10 -2
View File
@@ -57,7 +57,7 @@ esac
# huggingface_hub ships `hf` (new CLI); older versions only have `huggingface-cli` (deprecated). Use whichever exists.
if command -v hf >/dev/null 2>&1; then HF=hf
elif command -v huggingface-cli >/dev/null 2>&1; then HF=huggingface-cli
else echo "need the Hugging Face CLI: pip install -U huggingface_hub"; exit 1; fi
else echo "error: need the Hugging Face CLI: pip install -U huggingface_hub" >&2; exit 1; fi
mkdir -p "$OUT"
echo "downloading $REPO ..."
if [ ${#FILES[@]} -eq 0 ]; then
@@ -69,4 +69,12 @@ if [ "$MODEL" != "fsmn-vad" ] && [ "$MODEL" != "vad" ]; then
echo "downloading FSMN-VAD (for --vad) ..."
"$HF" download FunAudioLLM/fsmn-vad-GGUF fsmn-vad.gguf --local-dir "$OUT"
fi
echo "done -> $OUT"; ls -1 "$OUT"/*.gguf
shopt -s nullglob
GGUF_FILES=("$OUT"/*.gguf)
shopt -u nullglob
if [ ${#GGUF_FILES[@]} -eq 0 ]; then
echo "error: no GGUF files found in $OUT" >&2
exit 1
fi
echo "done -> $OUT"
printf '%s\n' "${GGUF_FILES[@]}"
@@ -13,6 +13,10 @@ set -euo pipefail
printf '%s\n' "$*" >>"$HF_LOG"
if [[ "${HF_SKIP_CREATE:-0}" == 1 ]]; then
exit 0
fi
out=
args=("$@")
for ((i = 0; i < ${#args[@]}; i++)); do
@@ -87,4 +91,19 @@ if bash "$SCRIPT" sensevoice "$TMP/out" q4km >/dev/null 2>&1; then
fi
[[ ! -s "$HF_LOG" ]]
mkdir -p "$TMP/empty-bin"
if PATH="$TMP/empty-bin" /bin/bash "$SCRIPT" sensevoice "$TMP/out" >"$TMP/stdout" 2>"$TMP/stderr"; then
echo "download succeeded without a Hugging Face CLI" >&2
exit 1
fi
[[ ! -s "$TMP/stdout" ]]
grep -F "need the Hugging Face CLI" "$TMP/stderr" >/dev/null
reset_case
if HF_SKIP_CREATE=1 bash "$SCRIPT" sensevoice "$TMP/out" >"$TMP/stdout" 2>"$TMP/stderr"; then
echo "download succeeded without producing a GGUF file" >&2
exit 1
fi
grep -F "no GGUF files found in $TMP/out" "$TMP/stderr" >/dev/null
echo "download-funasr-model contract tests passed"