aboutsummaryrefslogtreecommitdiff
path: root/tools/test-linux.sh
diff options
context:
space:
mode:
authorOnur Gündüz <ogunduz@gmail.com>2026-09-29 15:41:41 +0200
committerOnur Gündüz <ogunduz@gmail.com>2026-09-29 16:06:03 +0200
commit939b9a8deae07c2f06aa16c08f3ddad70f97b261 (patch)
tree00245f8e747349ddcca171be878e5ac19e8110a4 /tools/test-linux.sh
parent91c6aa07597462705a7f30ee5b97e2c7943b5616 (diff)
downloadlangdet-master.tar.gz
langdet-master.zip
Add Linux OpenBLAS builds and Docker validationHEADmaster
Diffstat (limited to 'tools/test-linux.sh')
-rwxr-xr-xtools/test-linux.sh30
1 files changed, 30 insertions, 0 deletions
diff --git a/tools/test-linux.sh b/tools/test-linux.sh
new file mode 100755
index 0000000..9431c1f
--- /dev/null
+++ b/tools/test-linux.sh
@@ -0,0 +1,30 @@
+#!/usr/bin/env bash
+set -euo pipefail
+
+root=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)
+arch=${1:-$(docker info --format '{{.Architecture}}')}
+case "$arch" in
+ arm64|aarch64) arch=arm64 ;;
+ amd64|x86_64) arch=amd64 ;;
+ *) printf 'Usage: %s [arm64|amd64] [MAKE_ARGUMENT ...]\n' "$0" >&2; exit 2 ;;
+esac
+if [ "$#" -gt 0 ]; then shift; fi
+
+if [ ! -f "$root/model/model.safetensors" ]; then
+ printf 'Download the model first: python3 %s/download_model.py\n' "$root" >&2
+ exit 1
+fi
+
+image="langdet-linux-test:$arch"
+docker build --platform "linux/$arch" -f "$root/tools/linux.Dockerfile" -t "$image" "$root/tools"
+args=(run --rm --network none --platform "linux/$arch" --workdir /work)
+for path in Makefile langdetect.c liblangdet deps tools examples model; do
+ args+=(--mount "type=bind,src=$root/$path,dst=/work/$path,readonly")
+done
+docker "${args[@]}" "$image" sh -eu -c '
+ make -j4 test "$@"
+ cc -Iliblangdet examples/detect.c liblangdet.a $(pkg-config --libs openblas) -lm -pthread -o build/detect-example
+ c++ -Iliblangdet -x c++ examples/detect.c -x none liblangdet.a $(pkg-config --libs openblas) -lm -pthread -o build/detect-example-cpp
+ ./build/detect-example model "This is an English sentence." "Bugün hava çok güzel."
+ ./build/detect-example-cpp model "This is an English sentence." "Bugün hava çok güzel."
+' linux-tests "$@"