Skip to content

Commit 916c175

Browse files
committed
test(llama.cpp): validate downloader failure paths
1 parent 9c17931 commit 916c175

2 files changed

Lines changed: 29 additions & 2 deletions

File tree

runtime/llama.cpp/download-funasr-model.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ esac
5757
# huggingface_hub ships `hf` (new CLI); older versions only have `huggingface-cli` (deprecated). Use whichever exists.
5858
if command -v hf >/dev/null 2>&1; then HF=hf
5959
elif command -v huggingface-cli >/dev/null 2>&1; then HF=huggingface-cli
60-
else echo "need the Hugging Face CLI: pip install -U huggingface_hub"; exit 1; fi
60+
else echo "error: need the Hugging Face CLI: pip install -U huggingface_hub" >&2; exit 1; fi
6161
mkdir -p "$OUT"
6262
echo "downloading $REPO ..."
6363
if [ ${#FILES[@]} -eq 0 ]; then
@@ -69,4 +69,12 @@ if [ "$MODEL" != "fsmn-vad" ] && [ "$MODEL" != "vad" ]; then
6969
echo "downloading FSMN-VAD (for --vad) ..."
7070
"$HF" download FunAudioLLM/fsmn-vad-GGUF fsmn-vad.gguf --local-dir "$OUT"
7171
fi
72-
echo "done -> $OUT"; ls -1 "$OUT"/*.gguf
72+
shopt -s nullglob
73+
GGUF_FILES=("$OUT"/*.gguf)
74+
shopt -u nullglob
75+
if [ ${#GGUF_FILES[@]} -eq 0 ]; then
76+
echo "error: no GGUF files found in $OUT" >&2
77+
exit 1
78+
fi
79+
echo "done -> $OUT"
80+
printf '%s\n' "${GGUF_FILES[@]}"

runtime/llama.cpp/tests/test_download_funasr_model.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ set -euo pipefail
1313
1414
printf '%s\n' "$*" >>"$HF_LOG"
1515
16+
if [[ "${HF_SKIP_CREATE:-0}" == 1 ]]; then
17+
exit 0
18+
fi
19+
1620
out=
1721
args=("$@")
1822
for ((i = 0; i < ${#args[@]}; i++)); do
@@ -87,4 +91,19 @@ if bash "$SCRIPT" sensevoice "$TMP/out" q4km >/dev/null 2>&1; then
8791
fi
8892
[[ ! -s "$HF_LOG" ]]
8993

94+
mkdir -p "$TMP/empty-bin"
95+
if PATH="$TMP/empty-bin" /bin/bash "$SCRIPT" sensevoice "$TMP/out" >"$TMP/stdout" 2>"$TMP/stderr"; then
96+
echo "download succeeded without a Hugging Face CLI" >&2
97+
exit 1
98+
fi
99+
[[ ! -s "$TMP/stdout" ]]
100+
grep -F "need the Hugging Face CLI" "$TMP/stderr" >/dev/null
101+
102+
reset_case
103+
if HF_SKIP_CREATE=1 bash "$SCRIPT" sensevoice "$TMP/out" >"$TMP/stdout" 2>"$TMP/stderr"; then
104+
echo "download succeeded without producing a GGUF file" >&2
105+
exit 1
106+
fi
107+
grep -F "no GGUF files found in $TMP/out" "$TMP/stderr" >/dev/null
108+
90109
echo "download-funasr-model contract tests passed"

0 commit comments

Comments
 (0)