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/interplane-forge/blob/main/server/tests/title.sh # interplane-forge INTERPLANE Forge 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 `interplane-forge / server / tests / title.sh` 119 lines ยท 6339 bytes Raw Blame History 1 #!/usr/bin/env bash 2 # L1057: title boundaries and real HTTP long-path requests, entirely private. 3 # Carried from fix/forged-rc104 `3c3e46b` onto the line that keeps `5129fbf`'s form of the fix 4 # (`for i ulong hmin n 120 bound 120` in brti). Two changes for that: the negative control undoes 5 # that line, and the count sources of server/counts.om are moved into the temp dir as well. 6 # KEEP_TEST_TMP=1 retains sources, binaries and logs for an evidence handoff. 7 set -euo pipefail 8 cd "$(dirname "$0")/../.." 9 OMC=$HOME/work/flux/omega-mv/seed/out/omc 10 PIN=`3ad9f10f64309e7acf8a725082b28e23a2a4aeb07e98322fb4dc0fcd8fc93194` 11 PORT=${FORGE_TITLE_PORT:-18557} 12 case "$PORT" in 185[5-9][0-9]|1999[0-9]) ;; *) echo 'REFUSED: use a private port in 18550..18599 or 19990..19999'; exit 2;; esac 13 [ "$(sha256sum "$OMC" | cut -d' ' -f1)" = "$PIN" ] || { echo 'FAIL compiler pin'; exit 1; } 14 if ss -ltnH "sport = :$PORT" | grep -q .; then echo "NOT_RUN: private port $PORT busy"; exit 3; fi 15 T=$(mktemp -d) 16 pid= 17 cleanup() { 18 if [ -n "$pid" ]; then kill "$pid" 2>/dev/null || true; wait "$pid" 2>/dev/null || true; fi 19 if [ "${KEEP_TEST_TMP:-0}" = 1 ]; then echo "Evidence: $T"; else rm -rf "$T"; fi 20 } 21 trap cleanup EXIT 22 run() { taskset -c "${FORGED_CPUS:-4,5}" nice -n 10 "$@"; } 23 compile() { 24 run "$OMC" < "$1" > "$1.bin" 2> "$1.err" || { cat "$1.err"; exit 1; } 25 chmod 755 "$1.bin" 26 } 27 { printf 'om2\n'; for u in $(./run.sh units); do cat "$u"; done; } > "$T/base.om" 28 sed 's/^fn main to int$/fn fmainx to int/' "$T/base.om" > "$T/unit.om" 29 cat browse/tests/title.om >> "$T/unit.om" 30 compile "$T/unit.om" 31 run "$T/unit.om.bin" 32 echo 'PASS title bytes and unchanged lookup path: 0, 1, 119, 120, 121, 4096' 33 # Negative control: exactly undo the production fix in the real composed code. 34 [ "$(grep -c '^for i ulong hmin n 120 bound 120$' "$T/unit.om")" = 1 ] 35 sed 's/^for i ulong hmin n 120 bound 120$/for i ulong n bound 120/' "$T/unit.om" > "$T/old-unit.om" 36 compile "$T/old-unit.om" 37 rc=0; run "$T/old-unit.om.bin" || rc=$? 38 [ "$rc" = 104 ] || { echo "FAIL old title: rc=$rc, expected 104"; exit 1; } 39 echo 'PASS negative control: old title code exits 104' 40 41 # This storage contains only our fixture. No radicle-node is started. 42 RID=z631r2JJiVT8it4tST7RK24hpowi 43 mkdir -p "$T/repo" "$T/storage" "$T/data/logs" "$T/ng" "$T/bin" 44 cp server/tests/fake/rad server/tests/fake/getent "$T/bin/" 45 chmod 755 "$T/bin/rad" "$T/bin/getent" 46 : > "$T/ng/dl.log"; : > "$T/ng/access.log" 47 p120=$(printf '%120s' '' | tr ' ' a) 48 p121=$(printf '%121s' '' | tr ' ' b) 49 p240=$(printf '%240s' '' | tr ' ' c) 50 dir121=$(printf '%121s' '' | tr ' ' d) 51 for path in "$p120" "$p121" "$p240"; do printf 'L1057 fixture\n' > "$T/repo/$path"; done 52 mkdir "$T/repo/$dir121" 53 printf 'L1057 directory fixture\n' > "$T/repo/$dir121/leaf" 54 git -C "$T/repo" init -q -b main 55 git -C "$T/repo" add . 56 git -C "$T/repo" -c user.name=Fixture -c user.email=fixture@example.invalid commit -qm 'L1057 fixture' 57 git clone -q --bare "$T/repo" "$T/storage/$RID" 58 printf '| repo | RID | default branch |\n|---|---|---|\n| crashfixture | rad:%s | main |\n' "$RID" > "$T/RIDS.md" 59 # STORE_VARIANT=1 (with IPL_DIR): the HTTP part on the store-reading build; the fixture made a store and 60 # the units composed again for it (the unit part above is the same code in both builds) 61 SV=${STORE_VARIANT:-0} 62 if [ "$SV" = 1 ]; then 63 FIXSTORE_FROM=/nonexistent bash store/tests/fixstore.sh "$T/RIDS.md" "$T/storage" "$T/store" 64 export FORGE_STORE=$T/store 65 { printf 'om2\n'; for u in $(./run.sh units); do cat "$u"; done; } > "$T/base.om" 66 echo "STORE_VARIANT: store-reading build, store $T/store" 67 fi 68 sed -e "s|`2130706433` 18480|`2130706433` $PORT|" \ 69 -e "s|/home/drakestapleton/handoffs/radicle/RIDS.md|$T/RIDS.md|g" \ 70 -e "s|/home/drakestapleton/.radicle/storage/|$T/storage/|g" \ 71 -e "s|/home/drakestapleton/forge-data/|$T/data/|g" \ 72 -e "s|^text tfzp0 \".*\"|text tfzp0 \"$T/ng/dl.log\"|" \ 73 -e "s|^text tfzp1 \".*\"|text tfzp1 \"$T/ng/access.log\"|" \ 74 -e "s|^text tfzwal \".*\"|text tfzwal \"$T/ng/wal\"|" \ 75 -e "s|^text tfzrad \".*\"|text tfzrad \"$T/bin/rad\"|" \ 76 -e "s|^text tfzspth \".*\"|text tfzspth \"$T/counts.snapshot\"|" \ 77 -e "s|^text tfzgent \".*\"|text tfzgent \"$T/bin/getent\"|" "$T/base.om" > "$T/http.om" 78 marks=("`2130706433` $PORT" "$T/RIDS.md" "$T/storage/" "$T/data/") 79 [ "$SV" = 1 ] && marks=("`2130706433` $PORT" "$T/store/" "$T/data/") 80 for marker in "${marks[@]}"; do grep -qF "$marker" "$T/http.om"; done 81 if grep -qE '`2130706433` 18480|/home/drakestapleton/(forge-data|\.radicle|handoffs/radicle)' "$T/http.om"; then 82 echo 'FAIL live target remains'; exit 1 83 fi 84 compile "$T/http.om" 85 # Launch directly, so the saved PID is the private server, not a shell wrapper. 86 FORGE_SOCIAL_DIR="$T/data/" taskset -c "${FORGED_CPUS:-4,5}" nice -n 10 "$T/http.om.bin" > "$T/http.log" 2>&1 & 87 pid=$! 88 ready=0 89 for _ in $(seq 50); do 90 kill -0 "$pid" 2>/dev/null || { echo 'FAIL private server exited during startup'; exit 1; } 91 if curl --max-time 1 -fsS -o /dev/null "http://127.0.0.1:$PORT/explore"; then ready=1; break; fi 92 sleep 0.1 93 done 94 [ "$ready" = 1 ] || { echo 'FAIL private server not ready'; exit 1; } 95 get() { 96 local code 97 code=$(curl --max-time 10 -sS -o "$T/body" -H "X-Forge-Base: $2" "http://127.0.0.1:$PORT/$1" -w '%{http_code}') 98 [ "$code" = 200 ] || { echo "FAIL $1 HTTP $code"; exit 1; } 99 kill -0 "$pid" || { echo 'FAIL server died after request'; exit 1; } 100 } 101 for base in / /forge/; do 102 for path in "$p120" "$p121" "$p240"; do 103 get "drakestapleton/crashfixture/blob/main/$path" "$base" 104 grep -q 'L1057 fixture' "$T/body" 105 grep -qF "${base}drakestapleton/crashfixture/raw/main/$path" "$T/body" 106 get "drakestapleton/crashfixture/raw/main/$path" "$base" 107 cmp "$T/body" "$T/repo/$path" 108 get "drakestapleton/crashfixture/blame/main/$path" "$base" 109 grep -q 'L1057 fixture' "$T/body" 110 get "drakestapleton/crashfixture/commits/main/$path" "$base" 111 grep -q 'L1057 fixture' "$T/body" 112 done 113 get "drakestapleton/crashfixture/tree/main/$dir121" "$base" 114 grep -q 'leaf' "$T/body" 115 get explore "$base" 116 echo "PASS HTTP $base: blob/raw/blame/commits at 120, 121, 240; long tree; subsequent explore" 117 done 118 sha256sum "$OMC" "$T/unit.om" "$T/unit.om.bin" "$T/http.om" "$T/http.om.bin" 119 echo 'title.sh: PASS'