Files
ziran/tests/thread_linux.sh
waozi 1c0c6c3c26
Publish website / build (push) Successful in 14m34s
Publish website / deploy (push) Failing after 18s
Build check / check (push) Canceled after 1h11m29s
Build check / Publish a new Ziran version (push) Skipped
Run Go workers and native callbacks with checked C borrows
2026-11-29 08:23:02 -03:00

56 lines
1.9 KiB
Bash

#!/bin/sh
set -eu
work=${ZIRAN_THREAD_TEST_BUILD:-"$(pwd)/build/thread-linux"}
mkdir -p "$work"
exec 9>"$work/check.lock"
flock -n 9 || { echo 'Thread checks are already running' >&2; exit 1; }
"$1" check --root tests/spec --module-path std \
tests/spec/thread_linux_test.zi
"$1" ir --root tests/spec --module-path std -o "$work/ir" \
tests/spec/thread_linux_test.zi
for form in source saved; do
output="$work/$form-c"
entry=tests/spec/thread_linux_test.zi
root=tests/spec
modules=std
if test "$form" = saved; then
entry="$work/ir/thread_linux_test.zir"
root="$work/ir"
modules="$work/ir"
fi
"$1" build --target=c --no-main \
--root "$root" --module-path "$modules" -o "$output" "$entry"
"${CC:-cc}" -std=c11 -Iinclude -I"$output" tests/thread_completion_test.c \
"$output"/*.c -pthread -Wl,--wrap=pthread_join -Wl,--wrap=pthread_mutex_lock -o "$work/test"
env -u DISPLAY -u WAYLAND_DISPLAY -u XAUTHORITY -u DBUS_SESSION_BUS_ADDRESS "$work/test"
done
"$1" ir --target=go --root tests/spec --module-path std -o "$work/go-ir" \
tests/spec/thread_linux_test.zi
for form in source saved; do
output="$work/$form-go"
entry=tests/spec/thread_linux_test.zi
root=tests/spec
modules=std
if test "$form" = saved; then
entry="$work/go-ir/thread_linux_test.zir"
root="$work/go-ir"
modules="$work/go-ir"
fi
"$1" build --target=go --exe --pkg main --entry thread_linux_test:SelfTest \
--root "$root" --module-path "$modules" -o "$output" "$entry"
(cd "$output" && CGO_ENABLED=0 GO111MODULE=off \
go build -p 2 -o "$work/test-go" .)
status=0
"$work/test-go" || status=$?
test "$status" = 42
(cd "$output" && CGO_ENABLED=1 GOEXPERIMENT=cgocheck2 GO111MODULE=off \
go build -race -p 2 -o "$work/test-go" .)
status=0
"$work/test-go" || status=$?
test "$status" = 42
done
echo 'PASS: native Go completion, notifications and reuse from source and saved IR'