Files
ziran/tests/package_process.sh
T
waozi 4838ce9b2f Improve runtimes, add an experimental direct backend, and prune Ziran tests
Prepare short portable helpers and scalar record reads, improve JSON SIMD scanning, expose one-line execution, and publish qualified Alpha benchmark artifacts. Add the experimental verified lowered execution, serialization and Linux x86-64 backend with source maps.

Physically remove 263 redundant test entry points and unused helpers, migrate retained helpers to Ziran, and execute the full retained suite without sharding. Allow ignored backup state for the managed physical Alpha workflow.

Local validation: all 268 retained tests passed across the full run and corrected targeted reruns; bootstrap matches. Current assembly verifier, x86-64, executor and serializer tests passed. Website examples and all 4661 local links passed. Six Alpha JSON/text workloads retain verified artifacts, raw samples and explicit unsupported Wasm diagnostics. The mobile sub-500 ns target remains pending.
2026-11-11 18:46:34 -03:00

96 lines
4.3 KiB
Bash

#!/bin/sh
set -eu
ziran=$1
repo=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
mkdir -p "$repo/build/tests"
work=$(mktemp -d "$repo/build/tests/package-process-XXXXXX")
trap 'rm -rf "$work"' EXIT HUP INT TERM
"$ziran" build --target=c --exe --root "$repo/tests" --entry process_fixture:main \
-o "$work/child" "$repo/tests/process_fixture.zi"
export ZIRAN_PROCESS_FIXTURE="$work/child/process_fixture"
cat > "$work/transport.zi" <<'ZI'
#import "package_process"
#import "std/byte_text_linux"
#import "std/file_linux"
#import "std/environment_linux"
Check :: (directory: string) -> s32 {
output: [4096]u8
names: [1]string = .["ZIRAN_PROCESS_TEST"]
values: [1]string = .["child ; $literal"]
none: [0]string
args: [3]string = .[EnvironmentText("ZIRAN_PROCESS_FIXTURE"), "text",
"quotes ' \" ; $(literal) * spaces"]
if RunProcess(args[:], "", none[:], none[:], output[:]) != 0 { return 1 }
if TextFromCString(*output[0]) != args[2] { return 2 }
args[1] = "environment"
args[2] = "ZIRAN_PROCESS_TEST"
if RunProcess(args[:], "", names[:], values[:], output[:]) != 0 { return 3 }
if TextFromCString(*output[0]) != "child ; $literal\n" { return 4 }
if RunProcess(args[:], "", none[:], none[:], output[:]) != 0 { return 5 }
if TextFromCString(*output[0]) != "parent\n" { return 6 }
clear: [1]string = .[""]
if RunProcess(args[:], "", names[:], clear[:], output[:]) != 0 { return 25 }
if TextFromCString(*output[0]) != "unset\n" { return 26 }
pwd: [1]string = .["/bin/pwd"]
if RunProcess(pwd[:], directory, none[:], none[:], output[:]) != 0 { return 7 }
if TextFromCString(*output[0])[0:directory.count] != directory { return 8 }
shell: [3]string = .["/bin/sh", "-c", "printf out; printf err >&2; exit 17"]
if RunProcess(shell[:], "", none[:], none[:], output[:]) != 17 { return 9 }
if TextFromCString(*output[0]) != "outerr" { return 10 }
shell[2] = "kill -TERM $$"
if RunProcess(shell[:], "", none[:], none[:], output[:]) != 143 { return 11 }
missing: [1]string = .["/ziran-test-no-such-executable"]
if RunProcess(missing[:], "", none[:], none[:], output[:]) != 127 { return 12 }
if RunProcess(pwd[:], "/ziran-test-no-such-directory", none[:], none[:], output[:]) != 127 { return 13 }
args[1] = "drain"
args[2] = directory
small: [4]u8
if RunProcess(args[:], "", none[:], none[:], small[:]) != -1 { return 14 }
if TextFromCString(*small[0]) != "xxx" { return 15 }
one: [1]u8
shell[2] = "printf x"
if RunProcess(shell[:], "", none[:], none[:], one[:]) != -1 || one[0] != 0 { return 16 }
shell[2] = "exit 0"
one[0] = 99
if RunProcess(shell[:], "", none[:], none[:], one[:]) != 0 || one[0] != 0 { return 17 }
empty: [0]u8
if RunProcess(shell[:], "", none[:], none[:], empty[:]) != 0 { return 18 }
if RunProcess(none[:], "", none[:], none[:], output[:]) != -1 { return 19 }
many: [600]string
for i: 0..599 { many[i] = "argument" }
many[0] = "true"
if RunProcess(many[:], "", none[:], none[:], output[:]) != 0 { return 20 }
if RunProcess(pwd[:], "", names[:], none[:], output[:]) != -1 { return 21 }
nul: [3]u8 = .[65, 0, 66]
missing[0] = TextFromBytes(nul[:])
if RunProcess(missing[:], "", none[:], none[:], output[:]) != -1 { return 22 }
if RunProcess(pwd[:], TextFromBytes(nul[:]), none[:], none[:], output[:]) != -1 { return 23 }
values[0] = TextFromBytes(nul[:])
if RunProcess(pwd[:], "", names[:], values[:], output[:]) != -1 { return 24 }
return 42
}
main :: (argc: s32, argv: **u8) -> s32 {
if argc != 2 { return 1 }
result := Check(TextFromCString(argv[1]))
print("%\n", result)
if result == 42 { return 0 }
return 1
}
ZI
"$ziran" ir --root "$work" --module-path "$repo/cmd" -o "$work/ir" "$work/transport.zi"
for input in "$work/transport.zi" "$work/ir/transport.zir"; do
form=source
case "$input" in *.zir) form=saved ;; esac
"$ziran" build --target=c --exe --entry transport:main --root "$work" \
--module-path "$repo/cmd" -o "$work/$form" "$input"
mkdir -p "$work/$form/cwd with spaces"
ZIRAN_PROCESS_TEST=parent "$work/$form/transport" "$work/$form/cwd with spaces" > "$work/$form.out"
test "$(cat "$work/$form.out")" = 42
test "$(cat "$work/$form/cwd with spaces/drained")" = done
done