blob: 9431c1f0f0cc15ee23c6d3f8a71c740e96f2f6f1 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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 "$@"
|