Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aien-sovereign-core-mv/blob/main/scripts/test-pkv-lib.sh # aien-sovereign-core-mv AienOS host runtime: inference scheduling, paged KV state, the aien CLI and Spark verification tooling. Its inference engine is in alpha testing (DGX Spark GB10); Omega is the implementation destination. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aien-sovereign-core-mv / scripts / test-pkv-lib.sh` 74 lines ยท 2914 bytes Raw Blame History 1 #!/usr/bin/env bash 2 # test-pkv-lib.sh: host-only self-test of scripts/own30b-pkv-lib.sh (sc#523 items 7 and 8) with 3 # stub curl, ss and sleep on PATH: no server, no chip, no network, no real port. Proves: 4 # wait_parks settles only on a number (a null or empty parked_chunks never counts as settled), 5 # and a port still held at exit makes the EXIT trap fail the run without skipping its cleanup. 6 set -euo pipefail 7 ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" 8 LIB="$ROOT/scripts/own30b-pkv-lib.sh" 9 T=$(mktemp -d); trap 'rm -rf "$T"' EXIT 10 fail=0 11 chk() { if eval "$1"; then echo " ok $2"; else echo " FAIL $2"; fail=1; fi; } 12 13 mkdir "$T/bin" 14 # curl: the live port never answers; any other URL answers with $T/health when it exists. 15 cat >"$T/bin/curl" <"$T/bin/ss" <"$T/bin/sleep" 28 chmod +x "$T/bin/curl" "$T/bin/ss" "$T/bin/sleep" 29 30 # wait_parks against a /health body; prints its exit status. 31 parks() { 32 printf '%s\n' "$1" >"$T/health" 33 (PATH="$T/bin:$PATH"; set -euo pipefail; . "$LIB"; wait_parks) >/dev/null 2>&1 && echo 0 || echo $? 34 } 35 echo "test-pkv-lib: wait_parks (item 7)" 36 chk '[ "$(parks "{\"persistent_kv\":{\"parked_chunks\":3}}")" = 0 ]' "a steady number settles" 37 chk '[ "$(parks "{\"persistent_kv\":{\"parked_chunks\":0}}")" != 0 ]' "zero never settles" 38 chk '[ "$(parks "{\"persistent_kv\":{\"parked_chunks\":null}}")" != 0 ]' "null never settles" 39 chk '[ "$(parks "{\"persistent_kv\":{}}")" != 0 ]' "a missing counter never settles" 40 chk '[ "$(parks "{\"status\":\"ok\"}")" != 0 ]' "persistence absent never settles" 41 chk '[ "$(parks "")" != 0 ]' "an empty reply never settles" 42 rm -f "$T/health" 43 44 echo "test-pkv-lib: the EXIT trap with the port still held (item 8)" 45 # pkv_begin with a free port, then something keeps listening after our server is gone. 46 rc=0 47 ( 48 PATH="$T/bin:$PATH" 49 set -euo pipefail 50 . "$LIB" 51 dir="$T/ev" BIN=/bin/true 52 pkv_begin 53 echo "$work" >"$T/work" 54 echo 999999 >"$PIDF" # not an aien-serve-http: stop_server sends no signal 55 touch "$T/listening" 56 ) >"$T/trap.out" 2>&1 || rc=$? 57 chk '[ "$rc" != 0 ]' "the run fails (exit $rc)" 58 chk 'grep -q "still listens" "$T/trap.out"' "the leftover listener is reported" 59 chk '[ -s "$T/work" ] && [ ! -e "$(cat "$T/work")" ]' "the trap still removed the private work dir" 60 61 rm -f "$T/listening" 62 rc=0 63 ( 64 PATH="$T/bin:$PATH" 65 set -euo pipefail 66 . "$LIB" 67 dir="$T/ev2" BIN=/bin/true 68 pkv_begin 69 echo "$work" >"$T/work2" 70 ) >/dev/null 2>&1 || rc=$? 71 chk '[ "$rc" = 0 ]' "a clean stop exits 0 (control)" 72 chk '[ ! -e "$(cat "$T/work2")" ]' "and removes the work dir" 73 74 [ "$fail" = 0 ] && echo "test-pkv-lib: PASS" || { echo "test-pkv-lib: FAIL"; exit 1; }