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-install/blob/main/tests/run.sh # interplane-install This project has not described itself yet. 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-install / tests / run.sh` 704 lines ยท 48761 bytes Raw Blame History 1 #!/bin/bash 2 # tests/run.sh SOURCE: the gate. Installs into fresh home folders and checks what a person gets, 3 # and that each thing that must be refused is refused. 4 # SOURCE a directory holding omega-mv/repo.git and interplane-forge/repo.git (a copy of what 5 # interplane.io serves), or an https base such as https://interplane.io/projects (then the 6 # piped-install case N takes this installer from there too, as a person would) 7 # Run it from a clone of this repository whose main is the commit under test. Needs a 64-bit Arm 8 # Linux host. Ends with "GATE PASS cases=N" or "GATE FAIL ...". 9 set -u 10 SRC=${1:?usage: tests/run.sh SOURCE} 11 HERE=$(cd "$(dirname "$0")/.." && pwd) 12 [ "$(git -C "$HERE" rev-parse HEAD)" = "$(git -C "$HERE" rev-parse refs/heads/main)" ] || { echo "GATE FAIL: run from a checkout of main" >&2; exit 2; } 13 # check takes ONE command. `check NAME [ a ] && [ b ]` would test only a, and `check NAME cmd; cmd2` 14 # would run cmd2 outside the check, so the gate refuses to run while any check line (also an indented 15 # one, and a kill_check) holds && || or ; outside single quotes (reviews of `175e9ef9` and `69cc9475`). 16 bad=$(grep -E '^[[:space:]]*(kill_)?check ' "$0" | sed "s/'[^']*'//g" | grep -E '&&|\|\||;' || true) 17 if [ -n "$bad" ]; then printf '%s\n' "$bad"; echo "GATE FAIL: a check line joins two commands; use one command (none_of, not, bash -c)" >&2; exit 2; fi 18 W=$(mktemp -d "${TMPDIR:-/tmp}/interplane-install-gate.XXXXXX") 19 trap 'pkill -f "git-daemon.*$W" 2>/dev/null; rm -rf "$W"' 0 20 # A folder source (a live copy of what interplane.io serves) can move while the gate runs, and a case that 21 # compares two installs would then see a change that is not the installer's. Take main of each project 22 # once, and use that for every case. 23 if [ -d "$SRC/omega-mv/repo.git" ]; then 24 for n in omega-mv interplane-forge; do 25 mkdir -p "$W/source/$n" && git init -q --bare -b main "$W/source/$n/repo.git" && 26 git --git-dir="$W/source/$n/repo.git" fetch -q --no-tags "$SRC/$n/repo.git" +refs/heads/main:refs/heads/main || { echo "GATE FAIL: could not copy $SRC/$n" >&2; exit 2; } 27 done 28 SRC=$W/source 29 fi 30 exec 8>&1 31 pass=0 fail=0 killed=0 nmut=0 INV=1 invn=0 32 : > "$W/names" 33 ok() { pass=$((pass + 1)); echo "PASS $1" >&8; printf '%s\n' "$1" >> "$W/names"; } 34 no() { fail=$((fail + 1)); echo "FAIL $1" >&8; } 35 check() { local n=$1; shift; if "$@" >/dev/null 2>&1; then ok "$n"; else no "$n"; fi; } 36 # kill_check NAME cmd...: the gate's own mutant check. cmd is a case's check run against an installer 37 # with one deliberate fault; it must FAIL there, and then the mutant counts as killed. 38 kill_check() { local n=$1; shift; if "$@" >/dev/null 2>&1; then no "$n (the faulty installer passed it)"; else ok "$n"; killed=$((killed + 1)); fi; } 39 not() { ! "$@"; } 40 # home NAME: a fresh, empty home folder; sets H 41 home() { H=$W/$1; mkdir -p "$H"; } 42 # inst: the installer, then (after a run that exits 0) the invariants of what the person has 43 inst() { 44 local rc=0 out=$W/.inst.out 45 env -i HOME="$H" PATH="$H/.local/bin:${P:-/usr/bin:/bin}" INTERPLANE_SOURCE="${SOURCE:-$SRC}" ${STOP:+IPL_TEST_STOP=$STOP} sh "${INSTALLER:-$HERE}/install.sh" "$@" > "$out" 2>&1 || rc=$? 46 cat "$out" 47 if [ "$rc" = 0 ] && [ "$INV" = 1 ]; then invariants "$out"; fi 48 return "$rc" 49 } 50 none_of() { local f; for f; do [ ! -e "$f" ] && [ ! -L "$f" ] || return 1; done; } 51 empty_store() { [ -z "$(ls -A "$H/$DATA/store/projects" 2>/dev/null)" ]; } 52 mode_is() { [ "$(stat -c %a "$2")" = "$1" ]; } 53 commit() { git -C "$1" -c user.name=t -c user.email=t@t commit -q --allow-empty -m "$2"; } 54 store_hash() { cat "$H/$DATA/store/catalog.tsv" "$H"/$DATA/store/projects/*/chain.tsv | sha256sum; } 55 ipc() { env -i HOME="$H" PATH="$H/.local/bin:/usr/bin:/bin" interplane "$@"; } 56 OMC_SHA=$(sed -n 's/^OMEGA_RELEASE_OMC_SHA256=//p' "$HERE/install.sh") 57 DATA=.local/share/interplane 58 pin_of() { sed -n "s/^$2=//p" "$1/install.sh"; } 59 inv_ipc() { env -i HOME="$H" PATH=/usr/bin:/bin bash "$H/$DATA/install/bin/interplane" "$@"; } 60 bin_omc_sha() { sha256sum < "$H/.local/bin/omc" | cut -d' ' -f1; } 61 store_install_main() { git --git-dir="$H/$DATA/store/projects/interplane-install/repo.git" rev-parse main 2> /dev/null; } 62 # inv_why LOG: after a run of the installer that exits 0, what the person has must be what the installer 63 # says and what its pins say, whatever way it was run: the compiler in lib and in bin is the pinned one (or 64 # bin has a file of theirs that the run said it kept, and that is not one the installer put there), the 65 # store tool is the pinned commit, the command is the store's installer, the final line names that 66 # installer, and the store verifies. A promise that the installer's words make about what was installed 67 # is checked here for every run of every case, not once. Prints what is wrong (nothing when all holds). 68 inv_why() { 69 local log=$1 dir=${INSTALLER:-$HERE} why= want forge store smain 70 want=$(pin_of "$dir" OMEGA_RELEASE_OMC_SHA256); forge=$(pin_of "$dir" FORGE_COMMIT) 71 [ "$(sha256sum < "$H/$DATA/lib/omc" | cut -d' ' -f1)" = "$want" ] || why="$why lib-omc" 72 if [ "$(bin_omc_sha)" != "$want" ]; then 73 grep -q '^kept your existing .*/omc' "$log" || why="$why bin-omc-stale" 74 if grep -qxF "$(bin_omc_sha)" "$H/$DATA/omc-installed" 2> /dev/null; then why="$why bin-omc-is-ours-and-stale"; fi 75 fi 76 [ "$(git -C "$H/$DATA/interplane" rev-parse HEAD 2> /dev/null)" = "$forge" ] || why="$why tools-commit" 77 store=$(inv_ipc where | sed -n 's/^store //p') 78 smain=$(git --git-dir="$store/projects/interplane-install/repo.git" rev-parse main 2> /dev/null) 79 { [ -n "$smain" ] && [ "$(git -C "$H/$DATA/install" rev-parse HEAD 2> /dev/null)" = "$smain" ]; } || why="$why command-commit" 80 grep -qx "Installer: interplane-install ${smain:0:12}" "$log" || why="$why final-line" 81 inv_ipc verify > /dev/null 2>&1 || why="$why verify" 82 echo "$why" 83 } 84 inv_holds() { [ -z "$(inv_why "$1")" ]; } 85 invariants() { 86 local why 87 invn=$((invn + 1)); why=$(inv_why "$1") 88 if [ -z "$why" ]; then ok "INV-$invn"; else no "INV-$invn:$why ($1)"; fi 89 } 90 91 # --- cases that the gate also runs against a faulty copy of the installer (the mutants at the end) -- 92 # so each is a function of the installer folder; they use the installed home H. 93 # src_update_run INSTALLER NAME: the source's omega-mv main has one more commit than the store's 94 # (made without a checkout); run the installer against it. Sets SU_NEW, SU_LINES, SU_RC. 95 src_update_run() { 96 local s4=$W/src4-$2 g4 t 97 rm -rf "$s4"; mkdir -p "$s4/omega-mv" "$s4/interplane-forge" 98 git clone -q --bare "$H/$DATA/store/projects/omega-mv/repo.git" "$s4/omega-mv/repo.git" 99 git clone -q --bare "$H/$DATA/store/projects/interplane-forge/repo.git" "$s4/interplane-forge/repo.git" 100 g4=$s4/omega-mv/repo.git 101 t=$(git --git-dir="$g4" rev-parse 'main^{tree}') 102 SU_NEW=$(git --git-dir="$g4" -c user.name=t -c user.email=t@t commit-tree "$t" -p "$(git --git-dir="$g4" rev-parse main)" -m newer) 103 git --git-dir="$g4" update-ref refs/heads/main "$SU_NEW" 104 SU_LINES=$(wc -l < "$H/$DATA/store/projects/omega-mv/chain.tsv") 105 INSTALLER=$1 SOURCE=$s4 inst --quick > "$W/su-$2.log" 2>&1; SU_RC=$? 106 } 107 su_new_main() { [ "$(git --git-dir="$H/$DATA/store/projects/omega-mv/repo.git" rev-parse main)" = "$SU_NEW" ]; } 108 su_two_more_lines() { [ "$(wc -l < "$H/$DATA/store/projects/omega-mv/chain.tsv")" = $((SU_LINES + 2)) ]; } 109 # share_with_stray_mark SCRIPT PROJECT: a stray export mark in the private PROJECT, then `interplane 110 # share` (SCRIPT) is started and waited for. Sets port; log in $W/share-PROJECT.log. 111 share_with_stray_mark() { 112 port=$((20000 + RANDOM % 20000)) 113 : > "$H/$DATA/store/projects/$2/repo.git/git-daemon-export-ok" 114 env -i HOME="$H" PATH="$H/.local/bin:/usr/bin:/bin" setsid bash "$1" share --port "$port" > "$W/share-$2.log" 2>&1 & 115 for _ in $(seq 50); do grep -q '^Read-only' "$W/share-$2.log" && (exec 3<>"/dev/tcp/127.0.0.1/$port") 2>/dev/null && break; sleep 0.2; done 116 } 117 stop_share() { pkill -f "git-daemon.*--port=$port" 2>/dev/null; pkill -f "git daemon.*--port=$port" 2>/dev/null; return 0; } 118 # The password used in the address cases is made fresh each run, so that no file of any project (this 119 # gate's own text is installed into the store too) can hold it by accident. It has an @ in it: both 120 # halves must stay out of everything the installer prints or writes. 121 PWHEAD=pw$(od -An -N8 -tx1 /dev/urandom | tr -d ' \n') 122 PWTAIL=tail$(od -An -N8 -tx1 /dev/urandom | tr -d ' \n') 123 PWSEC=$PWHEAD@$PWTAIL 124 # pw_run INSTALLER LOGNAME: a source address with a password in it (rewritten by git to the real source) 125 pw_run() { 126 PW_LOG=$2.log 127 printf '[url "%s/"]\n\tinsteadOf = https://tok:%s@example.invalid/\n' "$SRC" "$PWSEC" > "$H/.gitconfig" 128 INSTALLER=$1 SOURCE=https://tok:$PWSEC@example.invalid inst --quick > "$W/$PW_LOG" 2>&1; PW_RC=$? 129 } 130 pw_clean() { ! grep -rqF -e "$PWHEAD" -e "$PWTAIL" "$H/.local" "$H/.config" "$W/$PW_LOG"; } 131 132 # --- A: a full install, with the store tool's own gate -------------------------------------------- 133 home a 134 inst > "$W/a.log" 2>&1; rc=$? 135 check A-installs-exit-0 [ "$rc" = 0 ] 136 check A-store-gate-passed grep -q '^ok: GATE PASS' "$W/a.log" 137 check A-omc-is-the-release [ "$(sha256sum < "$H/.local/bin/omc" | cut -d' ' -f1)" = "$OMC_SHA" ] 138 printf 'fn main to int\nret 42\nend\n' > "$W/p.om" 139 "$H/.local/bin/omc" < "$W/p.om" > "$W/p" 2>/dev/null && chmod +x "$W/p" && "$W/p"; rc=$? 140 check A-omc-compiles-and-runs [ "$rc" = 42 ] 141 check A-three-private-projects [ "$(ipc list | awk 'NR > 1 && $2 == "no"' | wc -l)" = 3 ] 142 check A-verify-all ipc verify 143 check A-key-private [ "$(stat -c %a "$H/.config/interplane/owner-key")" = 600 ] 144 check A-pins-private [ "$(stat -c %a "$H/.config/interplane/owner-pins")" = 600 ] 145 check A-store-only-yours mode_is 700 "$H/$DATA/store" 146 check A-repo-only-yours mode_is 700 "$H/$DATA/store/projects/omega-mv/repo.git" 147 check A-chain-only-yours mode_is 600 "$H/$DATA/store/projects/omega-mv/chain.tsv" 148 check A-omc-runs-for-you mode_is 755 "$H/.local/bin/omc" 149 sh "$HERE/install.sh" --help > "$W/help.txt" 2>&1; ipc help > "$W/help2.txt" 2>&1 150 check A-help-is-text-only bash -c '! grep -q "^set \|^umask" "$1" "$2" && grep -q "^What it does" "$1" && grep -q "interplane list" "$2"' _ "$W/help.txt" "$W/help2.txt" 151 152 check A-installer-line bash -c 'grep -q "^Installer: interplane-install [0-9a-f]\{12\}$" "$1"' _ "$W/a.log" 153 # help is text, also when the file is piped into sh (no file of its own to read it from) 154 ( cd "$W" && env -i HOME="$H" PATH=/usr/bin:/bin sh -s -- --help < "$HERE/install.sh" ) > "$W/phelp.txt" 2>&1; rc=$? 155 check A-piped-help-exit-0 [ "$rc" = 0 ] 156 check A-piped-help-has-the-text grep -q '^What it does' "$W/phelp.txt" 157 sh "$HERE/install.sh" --help > "$W/help3.txt" 2>&1; rc=$? 158 check A-help-exit-0 [ "$rc" = 0 ] 159 check A-help-has-the-text grep -q '^What it does' "$W/help3.txt" 160 check A-help-prints-no-code bash -c '! grep -q "^set \|^umask" "$1" "$2"' _ "$W/phelp.txt" "$W/help3.txt" 161 162 # --- B: running it again changes nothing ---------------------------------------------------------- 163 before=$(cat "$H/$DATA/store/catalog.tsv" "$H/$DATA"/store/projects/*/chain.tsv | sha256sum) 164 inst --quick > "$W/b.log" 2>&1; rc=$? 165 check B-rerun-exit-0 [ "$rc" = 0 ] 166 check B-rerun-changes-nothing [ "$(cat "$H/$DATA/store/catalog.tsv" "$H/$DATA"/store/projects/*/chain.tsv | sha256sum)" = "$before" ] 167 168 # --- C: a new project, a change, a landing; a rewrite of history is refused ----------------------- 169 ( cd "$W" && ipc new notes >/dev/null && ipc get notes "$W/notes" >/dev/null ) 170 check C-new-and-get [ -d "$W/notes/.git" ] 171 commit "$W/notes" one 172 check C-land ipc land notes "$W/notes" 173 commit "$W/notes" two 174 check C-land-again ipc land notes "$W/notes" 175 chain=$(sha256sum < "$H/$DATA/store/projects/notes/chain.tsv") 176 git -C "$W/notes" reset -q --hard HEAD~1 177 commit "$W/notes" other 178 ipc land notes "$W/notes" >/dev/null 2>&1; rc=$? 179 check C-rewrite-refused [ "$rc" != 0 ] 180 check C-rewrite-left-no-record [ "$(sha256sum < "$H/$DATA/store/projects/notes/chain.tsv")" = "$chain" ] 181 check C-head-is-two [ "$(git --git-dir="$H/$DATA/store/projects/notes/repo.git" log -1 --format=%s main)" = two ] 182 183 # a landing that stops part-way is finished by the same command; a different head first finishes the old one 184 ( cd "$W" && ipc new notes2 >/dev/null && ipc get notes2 "$W/notes2" >/dev/null ) 185 commit "$W/notes2" one 186 env -i HOME="$H" PATH="$H/.local/bin:/usr/bin:/bin" IPL_TEST_STOP=after-record interplane land notes2 "$W/notes2" > "$W/land1.log" 2>&1; rc=$? 187 check LAND-stopped-exits-nonzero [ "$rc" != 0 ] 188 check LAND-stopped-says-how grep -q 'the landing stopped part-way; run the same command again to finish it' "$W/land1.log" 189 check LAND-stopped-left-its-request test -f "$H/$DATA/records/notes2.land-pending" 190 check LAND-same-command-finishes-it ipc land notes2 "$W/notes2" 191 check LAND-finished-verifies ipc verify notes2 192 check LAND-head-is-the-landed-commit [ "$(git --git-dir="$H/$DATA/store/projects/notes2/repo.git" rev-parse main)" = "$(git -C "$W/notes2" rev-parse HEAD)" ] 193 check LAND-request-is-gone none_of "$H/$DATA/records/notes2.land-pending" 194 commit "$W/notes2" two 195 env -i HOME="$H" PATH="$H/.local/bin:/usr/bin:/bin" IPL_TEST_STOP=after-record interplane land notes2 "$W/notes2" > "$W/land2.log" 2>&1; rc=$? 196 check LAND-second-stopped [ "$rc" != 0 ] 197 commit "$W/notes2" three 198 check LAND-another-head-finishes-the-old-one-first ipc land notes2 "$W/notes2" 199 check LAND-another-head-verifies ipc verify notes2 200 check LAND-another-head-is-in [ "$(git --git-dir="$H/$DATA/store/projects/notes2/repo.git" rev-parse main)" = "$(git -C "$W/notes2" rev-parse HEAD)" ] 201 check LAND-both-landings-recorded [ "$(grep -c " LAND " "$H/$DATA/store/projects/notes2/chain.tsv")" = 3 ] 202 # a new project that stops part-way is finished by the same command 203 env -i HOME="$H" PATH="$H/.local/bin:/usr/bin:/bin" IPL_TEST_STOP=after-record interplane new halfnew > "$W/new1.log" 2>&1; rc=$? 204 check NEW-stopped-exits-nonzero [ "$rc" != 0 ] 205 check NEW-stopped-says-how grep -q 'run the same command again' "$W/new1.log" 206 check NEW-same-command-finishes-it ipc new halfnew 207 check NEW-finished-verifies ipc verify halfnew 208 check NEW-finished-is-listed bash -c 'env -i HOME="$1" PATH="$1/.local/bin:/usr/bin:/bin" interplane list | grep -q "^halfnew "' _ "$H" 209 # leftovers of killed commands: a folder with only a half-made repository, one with a repository and no chain 210 mkdir -p "$H/$DATA/store/projects/leftover/repo.git.new" "$H/$DATA/store/projects/leftover2/repo.git" 211 check NEW-over-a-leftover ipc new leftover2 212 213 # --- D: import what you choose; share only what is public ----------------------------------------- 214 git init -q -b main "$W/mine" && commit "$W/mine" mine 215 check D-import-public ipc import "$W/mine" --public 216 ipc import "$W/mine" mine >/dev/null 2>&1; rc=$? 217 check D-import-same-name-refused [ "$rc" = 2 ] 218 check D-import-private ipc import "$W/mine" secret 219 # an address with a password in it: the password is not written into the signed evidence 220 printf '[url "%s"]\n\tinsteadOf = https://tok:%s@example.invalid/mine.git\n' "$W/mine" "$PWSEC" > "$H/.gitconfig" 221 check D-import-url-with-password ipc import "https://tok:$PWSEC@example.invalid/mine.git" withpw 222 check D-password-not-recorded bash -c '! grep -rqF -e "$2" -e "$3" "$1" && grep -q "^source https://example.invalid/mine.git$" "$1/withpw.import-evidence"' _ "$H/$DATA/records" "$PWHEAD" "$PWTAIL" 223 rm -f "$H/.gitconfig" 224 # an import that stops part-way is finished by the same command, and by nothing else 225 env -i HOME="$H" PATH="$H/.local/bin:/usr/bin:/bin" IPL_TEST_STOP=after-ref interplane import "$W/mine" halfway > "$W/half.log" 2>&1; rc=$? 226 check D-import-stopped-says-how bash -c '[ "$1" != 0 ] && grep -q "run the same command again" "$2"' _ "$rc" "$W/half.log" 227 ipc import "$W/notes" halfway >/dev/null 2>&1; rc=$? 228 check D-other-source-cannot-finish-it [ "$rc" = 2 ] 229 check D-same-command-finishes-it ipc import "$W/mine" halfway 230 check D-finished-import-verifies ipc verify halfway 231 # the same when it stopped before the first record was signed (inside ipl init), and a leftover folder does not stop an import 232 env -i HOME="$H" PATH="$H/.local/bin:/usr/bin:/bin" IPL_TEST_STOP=after-record interplane import "$W/mine" halfinit > "$W/half2.log" 2>&1; rc=$? 233 check D-import-stopped-in-init-says-how bash -c '[ "$1" != 0 ] && grep -q "run the same command again" "$2"' _ "$rc" "$W/half2.log" 234 check D-import-stopped-in-init-finishes ipc import "$W/mine" halfinit 235 check D-import-stopped-in-init-verifies ipc verify halfinit 236 check D-import-over-a-leftover ipc import "$W/mine" leftover 237 check D-import-over-a-leftover-verifies ipc verify leftover 238 # a private project that has a stray export mark is not served, and the mark is taken away 239 share_with_stray_mark "$H/.local/bin/interplane" secret 240 git clone -q "git://127.0.0.1:$port/mine/repo.git" "$W/got-mine" 2>/dev/null 241 check D-says-only-this-machine grep -q 'Only this machine can reach it' "$W/share-secret.log" 242 check D-stray-export-mark-is-removed none_of "$H/$DATA/store/projects/secret/repo.git/git-daemon-export-ok" 243 check D-public-is-served [ "$(git -C "$W/got-mine" log -1 --format=%s 2>/dev/null)" = mine ] 244 git clone -q "git://127.0.0.1:$port/secret/repo.git" "$W/got-secret" 2>/dev/null; rc=$? 245 check D-private-is-not-served [ "$rc" != 0 ] 246 git clone -q "git://127.0.0.1:$port/omega-mv/repo.git" "$W/got-omega" 2>/dev/null; rc=$? 247 check D-installed-private-is-not-served [ "$rc" != 0 ] 248 git push -q "git://127.0.0.1:$port/mine/repo.git" HEAD:refs/heads/x 2>/dev/null; rc=$? 249 check D-share-is-read-only [ "$rc" != 0 ] 250 stop_share 251 252 # --- E: one altered byte in a signed chain is caught ---------------------------------------------- 253 f=$H/$DATA/store/projects/mine/chain.tsv 254 cp "$f" "$W/chain.bak"; sed -i '1s/PROJECT/PROJECTX/' "$f" 255 ipc verify mine >/dev/null 2>&1; rc=$? 256 check E-tamper-caught [ "$rc" = 3 ] 257 cp "$W/chain.bak" "$f" 258 check E-restored-verifies ipc verify mine 259 260 # --- M: a run that was killed part-way is finished by the next run ---------------------------------- 261 home m 262 STOP=after-record inst --quick > "$W/m1.log" 2>&1; rc=$? # the first record is written, not yet signed 263 check M-stopped-run-fails [ "$rc" = 3 ] 264 mkdir -p "$H/$DATA/.stage.dead" "$H/$DATA/store/projects/interplane-forge/repo.git.new" "$H/$DATA/interplane.new" "$H/$DATA/install.new" # what a kill -9 leaves 265 printf 'half' > "$H/$DATA/records/omega-mv.import-evidence.new" 266 inst --quick > "$W/m2.log" 2>&1; rc=$? 267 check M-next-run-finishes [ "$rc" = 0 ] 268 check M-leftovers-removed none_of "$H/$DATA/.stage.dead" "$H/$DATA/store/projects/interplane-forge/repo.git.new" "$H/$DATA/interplane.new" "$H/$DATA/install.new" "$H/$DATA/records/omega-mv.import-evidence.new" 269 check M-verify-all ipc verify 270 check M-three-projects [ "$(wc -l < "$H/$DATA/store/catalog.tsv")" = 3 ] 271 home m2 272 STOP=after-ref inst --quick > "$W/m3.log" 2>&1; rc=$? # the first import is recorded and signed, then killed 273 check M2-stopped-run-fails [ "$rc" = 3 ] 274 inst --quick > "$W/m4.log" 2>&1; rc=$? 275 check M2-next-run-finishes [ "$rc" = 0 ] 276 check M2-verify-all ipc verify 277 278 # --- F: a machine that cannot run Omega gets a plain no, and nothing is written --------------------- 279 home f; mkdir -p "$W/fakebin"; printf '#!/bin/sh\n[ "$1" = -m ] && echo x86_64 || /usr/bin/uname "$@"\n' > "$W/fakebin/uname"; chmod +x "$W/fakebin/uname" 280 P="$W/fakebin:/usr/bin:/bin" inst > "$W/f.log" 2>&1; rc=$? 281 check F-other-cpu-refused [ "$rc" = 2 ] 282 check F-says-why grep -q '64-bit Arm Linux' "$W/f.log" 283 check F-wrote-nothing none_of "$H/.local" "$H/.config" 284 285 # --- G: a missing program is named, and nothing is written ------------------------------------------ 286 home g; mkdir -p "$W/nossh" 287 for t in /usr/bin/* /bin/*; do b=$(basename "$t"); [ "$b" = ssh-keygen ] || [ -e "$W/nossh/$b" ] || ln -s "$t" "$W/nossh/$b"; done 288 P="$W/nossh" inst > "$W/g.log" 2>&1; rc=$? 289 check G-missing-tool-refused [ "$rc" = 2 ] 290 check G-names-it grep -q 'missing: ssh-keygen' "$W/g.log" 291 check G-wrote-nothing none_of "$H/.local" "$H/.config" 292 293 # --- H: an omc that is already there is kept --------------------------------------------------------- 294 home h; mkdir -p "$H/.local/bin"; printf '#!/bin/sh\necho mine\n' > "$H/.local/bin/omc"; chmod +x "$H/.local/bin/omc" 295 cp "$H/.local/bin/omc" "$H/.local/bin/interplane" 296 inst --quick > "$W/h.log" 2>&1; rc=$? 297 check H-installs-exit-0 [ "$rc" = 0 ] 298 check H-existing-omc-kept [ "$("$H/.local/bin/omc")" = mine ] 299 check H-says-so grep -q 'kept your existing .*/omc' "$W/h.log" 300 check H-existing-interplane-kept [ "$("$H/.local/bin/interplane")" = mine ] 301 check H-says-that-too grep -q 'kept your existing .*/interplane' "$W/h.log" 302 303 # --- I: a source without the pinned commit is refused before anything is built or recorded ----------- 304 home i; mkdir -p "$W/badsrc/omega-mv" "$W/badsrc/interplane-forge" 305 git init -q -b main "$W/bad" && commit "$W/bad" impostor 306 git clone -q --bare "$W/bad" "$W/badsrc/omega-mv/repo.git" 307 git clone -q --bare "$SRC/interplane-forge/repo.git" "$W/badsrc/interplane-forge/repo.git" 308 env -i HOME="$H" PATH=/usr/bin:/bin INTERPLANE_SOURCE="$W/badsrc" sh "$HERE/install.sh" --quick > "$W/i.log" 2>&1; rc=$? 309 check I-impostor-source-refused [ "$rc" = 3 ] 310 check I-says-pinned grep -q 'pinned commit' "$W/i.log" 311 check I-recorded-nothing empty_store 312 check I-installed-no-compiler none_of "$H/.local/bin/omc" "$H/$DATA/lib/omc" "$H/$DATA/lib/omc-ipl" 313 # the same for an impostor Interplane beside the real Omega (the copy home a already holds) 314 home pp; mkdir -p "$W/badsrc2/omega-mv" "$W/badsrc2/interplane-forge" 315 git clone -q --bare "$W/a/$DATA/store/projects/omega-mv/repo.git" "$W/badsrc2/omega-mv/repo.git" 316 git clone -q --bare "$W/bad" "$W/badsrc2/interplane-forge/repo.git" 317 env -i HOME="$H" PATH=/usr/bin:/bin INTERPLANE_SOURCE="$W/badsrc2" sh "$HERE/install.sh" --quick > "$W/pp.log" 2>&1; rc=$? 318 check P-impostor-interplane-refused [ "$rc" = 3 ] 319 check P-says-which grep -q 'interplane-forge .* does not have the pinned commit' "$W/pp.log" 320 check P-recorded-nothing empty_store 321 check P-built-nothing none_of "$H/$DATA/interplane" "$H/.local/bin/omc" 322 323 # --- S: the source has a newer main of Omega; it is brought up, kept out when it is not a descendant, and an 324 # unreachable source does no harm (home a again: Omega and Interplane are installed there) 325 H=$W/a 326 src_update_run "$HERE" a 327 check S-newer-source-exit-0 [ "$SU_RC" = 0 ] 328 check S-store-has-the-new-main su_new_main 329 check S-two-more-chain-lines su_two_more_lines 330 check S-says-omega-was-brought-up grep -q "ok: omega-mv brought up to ${SU_NEW:0:12}" "$W/su-a.log" 331 check S-forge-is-up-to-date grep -q 'ok: interplane-forge is up to date' "$W/su-a.log" 332 check S-verify-all ipc verify 333 h0=$(store_hash) 334 SOURCE=$W/badsrc inst --quick > "$W/s2.log" 2>&1; rc=$? 335 check S-unrelated-source-exit-0 [ "$rc" = 0 ] 336 check S-unrelated-source-is-said grep -q 'main of omega-mv at the source does not descend from your copy; using your copy' "$W/s2.log" 337 check S-unrelated-source-changes-nothing [ "$(store_hash)" = "$h0" ] 338 check S-unrelated-source-keeps-main su_new_main 339 SOURCE=/nonexistent-source inst --quick > "$W/s3.log" 2>&1; rc=$? 340 check S-unreachable-source-exit-0 [ "$rc" = 0 ] 341 check S-unreachable-source-is-said grep -q 'could not reach /nonexistent-source/omega-mv/repo.git' "$W/s3.log" 342 check S-unreachable-source-changes-nothing [ "$(store_hash)" = "$h0" ] 343 check S-verify-all-after ipc verify 344 345 # --- T: checkouts that a kill left half-made (the store tool's tree, the command's tree) are made again 346 rm -rf "$H/$DATA/interplane/ipl" "$H/$DATA/interplane/.git/index" "$H/$DATA/install/bin" 347 inst --quick > "$W/t.log" 2>&1; rc=$? 348 check T-killed-checkouts-exit-0 [ "$rc" = 0 ] 349 check T-says-the-old-ones-are-kept grep -q 'was not as it should be; it is kept as' "$W/t.log" 350 check T-tool-is-whole test -f "$H/$DATA/interplane/ipl/ipl" 351 check T-command-is-whole test -f "$H/$DATA/install/bin/interplane" 352 check T-verify-all ipc verify 353 check T-list-works ipc list 354 355 # --- L: a newer installer brings an existing install up to date (home a again) ---------------------- 356 H=$W/a 357 git clone -q "$HERE" "$W/up"; printf '# upgraded\n' >> "$W/up/bin/interplane"; git -C "$W/up" -c user.name=t -c user.email=t@t commit -q -am newer 358 upnew=$(git -C "$W/up" rev-parse HEAD) 359 lines=$(wc -l < "$H/$DATA/store/projects/interplane-install/chain.tsv") 360 INSTALLER=$W/up inst --quick > "$W/l.log" 2>&1; rc=$? 361 check L-upgrade-exit-0 [ "$rc" = 0 ] 362 check L-store-has-new-head [ "$(git --git-dir="$H/$DATA/store/projects/interplane-install/repo.git" rev-parse main)" = "$upnew" ] 363 check L-new-head-is-a-signed-landing [ "$(wc -l < "$H/$DATA/store/projects/interplane-install/chain.tsv")" = $((lines + 2)) ] 364 check L-command-is-the-new-one grep -q '^# upgraded' "$H/$DATA/install/bin/interplane" 365 check L-others-untouched grep -q 'ok: omega-mv is up to date' "$W/l.log" 366 check L-final-line-names-the-checkout-head [ "$(grep '^Installer:' "$W/l.log" | tail -n 1)" = "Installer: interplane-install ${upnew:0:12}" ] 367 check L-verify-all ipc verify 368 # an older installer run afterwards is refused, and nothing is changed (it would put its older pins under a newer store) 369 h1=$(store_hash) 370 inst --quick > "$W/l2.log" 2>&1; rc=$? 371 check L-older-installer-refused [ "$rc" = 3 ] 372 check L-older-installer-says-the-newer-one-is-there grep -q 'your store already has a newer installer' "$W/l2.log" 373 check L-older-installer-changes-nothing [ "$(store_hash)" = "$h1" ] 374 check L-older-installer-keeps-new-head [ "$(git --git-dir="$H/$DATA/store/projects/interplane-install/repo.git" rev-parse main)" = "$upnew" ] 375 # an installer that neither contains nor continues the one in the store: its pins are installed, the store keeps its own installer, and the last lines say so 376 git clone -q "$HERE" "$W/ldiv"; printf '# sideways\n' >> "$W/ldiv/bin/interplane"; git -C "$W/ldiv" -c user.name=t -c user.email=t@t commit -q -am sideways 377 INSTALLER=$W/ldiv inst --quick > "$W/l3.log" 2>&1; rc=$? 378 check L-diverged-installer-exit-0 [ "$rc" = 0 ] 379 check L-diverged-installer-keeps-the-stores-head [ "$(git --git-dir="$H/$DATA/store/projects/interplane-install/repo.git" rev-parse main)" = "$upnew" ] 380 check L-diverged-installer-says-whose-pins-were-installed grep -q "^ (this run's compilers and store tool are the pins of installer $(git -C "$W/ldiv" rev-parse HEAD | cut -c1-12)," "$W/l3.log" 381 382 # --- J: an owner pin for another key is never overwritten ------------------------------------------- 383 home j; mkdir -p "$H/.config/interplane"; printf '* SHA256:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n' > "$H/.config/interplane/owner-pins" 384 pin=$(sha256sum < "$H/.config/interplane/owner-pins") 385 inst --quick > "$W/j.log" 2>&1; rc=$? 386 check J-other-owner-refused [ "$rc" = 3 ] 387 check J-pin-unchanged [ "$(sha256sum < "$H/.config/interplane/owner-pins")" = "$pin" ] 388 check J-recorded-nothing empty_store 389 390 # --- K: a compiler whose SHA-256 is not the pinned one is refused (mutant of this installer) --------- 391 home k; git clone -q "$HERE" "$W/mut" 392 sed -i 's/^OMEGA_RELEASE_OMC_SHA256=.*/OMEGA_RELEASE_OMC_SHA256=`0000000000000000000000000000000000000000000000000000000000000000`/' "$W/mut/install.sh" 393 check K-mutant-is-a-mutant bash -c '! cmp -s "$1" "$2"' _ "$HERE/install.sh" "$W/mut/install.sh" 394 git -C "$W/mut" -c user.name=t -c user.email=t@t commit -q -am mutant 395 INSTALLER=$W/mut inst --quick > "$W/k.log" 2>&1; rc=$? 396 check K-wrong-compiler-refused [ "$rc" = 3 ] 397 check K-says-sha grep -q "SHA-256 is not the pinned one" "$W/k.log" 398 check K-recorded-nothing empty_store 399 check K-installed-nothing none_of "$H/.local/bin/omc" "$H/$DATA/lib/omc" 400 401 # --- O: the same for the compiler the store tool is built with --------------------------------------- 402 home o; git clone -q "$HERE" "$W/mut2" 403 sed -i 's/IPL_OMC_SHA=\$(pin omc-sha256)/IPL_OMC_SHA=00/' "$W/mut2/install.sh" 404 check O-mutant-is-a-mutant grep -q 'IPL_OMC_SHA=00;' "$W/mut2/install.sh" 405 git -C "$W/mut2" -c user.name=t -c user.email=t@t commit -q -am mutant 406 INSTALLER=$W/mut2 inst --quick > "$W/o.log" 2>&1; rc=$? 407 check O-wrong-store-compiler-refused [ "$rc" = 3 ] 408 check O-says-which grep -q "store tool's compiler is not the one ipl/PIN names" "$W/o.log" 409 check O-recorded-nothing empty_store 410 check O-built-nothing none_of "$H/$DATA/interplane" "$H/$DATA/lib/omc-ipl" 411 412 # --- N: the piped form (no clone of this installer on the machine): it fetches itself ---------------- 413 home n 414 case $SRC in 415 /*) S3=$W/src3; mkdir -p "$S3/interplane-install"; ln -s "$SRC/omega-mv" "$S3/omega-mv"; ln -s "$SRC/interplane-forge" "$S3/interplane-forge" 416 git clone -q --bare "$HERE" "$S3/interplane-install/repo.git" ;; 417 *) S3=$SRC ;; 418 esac 419 ( cd "$H" && env -i HOME="$H" PATH=/usr/bin:/bin INTERPLANE_SOURCE="$S3" sh -s -- --quick < "$HERE/install.sh" ) > "$W/n.log" 2>&1; rc=$? 420 check N-piped-install-exit-0 [ "$rc" = 0 ] 421 check N-fetched-itself grep -q 'downloading interplane-install' "$W/n.log" 422 check N-verify-all ipc verify 423 invariants "$W/n.log" 424 425 # --- Q: a store where you say ------------------------------------------------------------------------ 426 home q 427 inst --quick --store "$H/mystore" > "$W/q.log" 2>&1; rc=$? 428 check Q-store-option-exit-0 [ "$rc" = 0 ] 429 check Q-store-is-there [ "$(wc -l < "$H/mystore/catalog.tsv")" = 3 ] 430 check Q-no-default-store none_of "$H/$DATA/store" 431 check Q-command-uses-it bash -c '[ "$(env -i HOME="$1" PATH="$1/.local/bin:/usr/bin:/bin" interplane where | sed -n "s/^store //p")" = "$1/mystore" ]' _ "$H" 432 inst --quick > "$W/q2.log" 2>&1; rc=$? 433 check Q-rerun-exit-0 [ "$rc" = 0 ] 434 check Q-rerun-remembers-it none_of "$H/$DATA/store" 435 inst --quick --store "$H/other" > "$W/q3.log" 2>&1; rc=$? 436 check Q-other-store-refused-exit-1 [ "$rc" = 1 ] 437 check Q-refusal-names-the-store grep -q "your store is already $H/mystore" "$W/q3.log" 438 check Q-other-store-not-made none_of "$H/other" "$H/$DATA/store" 439 check Q-config-unchanged [ "$(sed -n 's/^store=//p' "$H/.config/interplane/config")" = "$H/mystore" ] 440 # an existing folder given as the store is made private, and the run says so 441 home q2; mkdir -m 755 "$H/shared" 442 inst --quick --store "$H/shared" > "$W/q4.log" 2>&1; rc=$? 443 check Q-existing-folder-exit-0 [ "$rc" = 0 ] 444 check Q-existing-folder-made-private mode_is 700 "$H/shared" 445 check Q-existing-folder-says-so grep -q "^note: $H/shared already exists and was accessible to other accounts (mode 755)" "$W/q4.log" 446 # a folder that already has other files is not a store: refused, and left as it was 447 home q3; mkdir -m 755 "$H/docs"; printf 'mine\n' > "$H/docs/a.txt" 448 inst --quick --store "$H/docs" > "$W/q5.log" 2>&1; rc=$? 449 check Q-non-store-folder-refused-exit-1 [ "$rc" = 1 ] 450 check Q-non-store-folder-says-why grep -q 'already has files in it and is not an Interplane store' "$W/q5.log" 451 check Q-non-store-folder-unchanged mode_is 755 "$H/docs" 452 check Q-non-store-folder-gets-nothing none_of "$H/docs/projects" "$H/docs/catalog.tsv" "$H/.local" "$H/.config" 453 454 # --- R: a key you already have, even without its public half ----------------------------------------- 455 home r; mkdir -p "$H/.config/interplane"; ssh-keygen -q -t `ed25519` -N '' -f "$H/.config/interplane/owner-key" 456 fp=$(ssh-keygen -lf "$H/.config/interplane/owner-key.pub" | awk '{print $2}'); rm "$H/.config/interplane/owner-key.pub" 457 inst --quick > "$W/r.log" 2>&1; rc=$? 458 check R-existing-key-exit-0 [ "$rc" = 0 ] 459 check R-your-key-is-the-owner grep -qx "\* $fp" "$H/.config/interplane/owner-pins" 460 check R-verify-all ipc verify 461 462 # an owner key whose public half is empty (a kill, or a failed ssh-keygen -y) is made again 463 home r2; mkdir -p "$H/.config/interplane"; ssh-keygen -q -t `ed25519` -N '' -f "$H/.config/interplane/owner-key" 464 fp=$(ssh-keygen -lf "$H/.config/interplane/owner-key.pub" | awk '{print $2}'); : > "$H/.config/interplane/owner-key.pub" 465 inst --quick > "$W/r2.log" 2>&1; rc=$? 466 check R-empty-pub-exit-0 [ "$rc" = 0 ] 467 check R-empty-pub-is-made-again [ "$(ssh-keygen -lf "$H/.config/interplane/owner-key.pub" | awk '{print $2}')" = "$fp" ] 468 check R-empty-pub-leaves-no-new-file none_of "$H/.config/interplane/owner-key.pub.new" "$H/.config/interplane/owner-pins.new" 469 470 # --- U: the clone form installs exactly the commit that is checked out, not a branch, and says what it leaves out 471 home u; git clone -q "$HERE" "$W/det"; git -C "$W/det" checkout -q --detach; git -C "$W/det" branch -q -D main 472 printf '# detached\n' >> "$W/det/bin/interplane"; git -C "$W/det" -c user.name=t -c user.email=t@t commit -q -am detached 473 printf '# not committed\n' >> "$W/det/README.md" 474 INSTALLER=$W/det inst --quick > "$W/u.log" 2>&1; rc=$? 475 dethead=$(git -C "$W/det" rev-parse HEAD) 476 check U-detached-checkout-exit-0 [ "$rc" = 0 ] 477 check U-store-has-the-checkout-head [ "$(git --git-dir="$H/$DATA/store/projects/interplane-install/repo.git" rev-parse main)" = "$dethead" ] 478 check U-command-is-the-checkout-head [ "$(git -C "$H/$DATA/install" rev-parse HEAD)" = "$dethead" ] 479 check U-says-uncommitted-is-left-out grep -q 'uncommitted changes to tracked files; they are not installed' "$W/u.log" 480 check U-final-line-names-it [ "$(grep '^Installer:' "$W/u.log" | tail -n 1)" = "Installer: interplane-install ${dethead:0:12}" ] 481 check U-uncommitted-is-not-in-the-command bash -c '! grep -q "^# not committed" "$1/README.md"' _ "$H/$DATA/install" 482 483 # --- W: a password or token in the source address is never printed or written 484 home w 485 pw_run "$HERE" w 486 check W-password-source-exit-0 [ "$PW_RC" = 0 ] 487 check W-used-that-source grep -q '^downloading omega-mv from https://example.invalid ' "$W/$PW_LOG" 488 check W-evidence-holds-the-address-without-it grep -qx 'source https://example.invalid/omega-mv/repo.git' "$H/$DATA/records/omega-mv.import-evidence" 489 check W-no-password-anywhere pw_clean 490 check W-verify-all ipc verify 491 492 # --- X: the clone form through a symlinked workspace, from a pipe inside a clone, from a copy ----------- 493 # (review 3: a symlinked path turned the clone form into a download without a word) 494 home x 495 mkdir -p "$W/xreal" && ln -s "$W/xreal" "$W/xlink" && git clone -q "$HERE" "$W/xreal/inst" 496 SX=$W/srcx; mkdir -p "$SX/omega-mv" "$SX/interplane-forge" "$SX/interplane-install" 497 git clone -q --bare "$W/a/$DATA/store/projects/omega-mv/repo.git" "$SX/omega-mv/repo.git" 498 git clone -q --bare "$W/a/$DATA/store/projects/interplane-forge/repo.git" "$SX/interplane-forge/repo.git" 499 git clone -q "$HERE" "$W/xother"; printf '# the source serves another installer\n' >> "$W/xother/bin/interplane" 500 git -C "$W/xother" -c user.name=t -c user.email=t@t commit -q -am other 501 git clone -q --bare "$W/xother" "$SX/interplane-install/repo.git" 502 xhead=$(git -C "$W/xreal/inst" rev-parse HEAD); xother=$(git -C "$W/xother" rev-parse HEAD); xphys=$(cd "$W/xreal/inst" && pwd -P) 503 INSTALLER=$W/xlink/inst SOURCE=$SX inst --quick > "$W/x1.log" 2>&1; rc=$? 504 check X-symlinked-workspace-exit-0 [ "$rc" = 0 ] 505 check X-symlinked-workspace-installs-the-checkout [ "$(store_install_main)" = "$xhead" ] 506 check X-symlinked-workspace-is-the-clone-form grep -q "^ok: this installer is $xphys at ${xhead:0:12}" "$W/x1.log" 507 check X-symlinked-workspace-does-not-download bash -c '! grep -q "not run from a checkout" "$1"' _ "$W/x1.log" 508 # the same through a symlink to install.sh itself 509 home x1b; mkdir -p "$W/xfile"; ln -s "$W/xreal/inst/install.sh" "$W/xfile/install.sh" 510 INSTALLER=$W/xfile SOURCE=$SX inst --quick > "$W/x1b.log" 2>&1; rc=$? 511 check X-symlinked-file-exit-0 [ "$rc" = 0 ] 512 check X-symlinked-file-installs-the-checkout [ "$(store_install_main)" = "$xhead" ] 513 # piped from a folder that is a clone: the piped form, said so, and the source's installer is the one installed 514 home x2 515 ( cd "$W/xreal/inst" && env -i HOME="$H" PATH=/usr/bin:/bin INTERPLANE_SOURCE="$SX" sh -s -- --quick < install.sh ) > "$W/x2.log" 2>&1; rc=$? 516 check X-piped-in-a-clone-exit-0 [ "$rc" = 0 ] 517 check X-piped-in-a-clone-takes-the-sources-installer [ "$(store_install_main)" = "$xother" ] 518 check X-piped-in-a-clone-says-so grep -q 'not run from a checkout' "$W/x2.log" 519 invariants "$W/x2.log" 520 # a copy of the files with no Git checkout behind it is refused (never replaced by a download), and nothing is written 521 home x3; mkdir -p "$W/xcopy"; cp -R "$W/xreal/inst/." "$W/xcopy/"; rm -rf "$W/xcopy/.git" 522 INSTALLER=$W/xcopy SOURCE=$SX inst --quick > "$W/x3.log" 2>&1; rc=$? 523 check X-a-copy-is-refused [ "$rc" = 3 ] 524 check X-a-copy-says-why grep -q 'is not a Git checkout of it' "$W/x3.log" 525 check X-a-copy-does-not-download bash -c '! grep -q "downloading interplane-install" "$1"' _ "$W/x3.log" 526 check X-a-copy-wrote-nothing none_of "$H/.local" "$H/.config" 527 # a lone install.sh with no checkout beside it is the piped form: it says so and takes the source's installer 528 home x4; mkdir -p "$W/xlone"; cp "$W/xreal/inst/install.sh" "$W/xlone/install.sh" 529 INSTALLER=$W/xlone SOURCE=$SX inst --quick > "$W/x4.log" 2>&1; rc=$? 530 check X-a-lone-file-exit-0 [ "$rc" = 0 ] 531 check X-a-lone-file-takes-the-sources-installer [ "$(store_install_main)" = "$xother" ] 532 check X-a-lone-file-says-so grep -q 'not run from a checkout' "$W/x4.log" 533 534 # --- V: an install.sh with changes that are not committed decides what is installed, so it is refused --- 535 # edited_run BASE NAME: a clone of BASE with one uncommitted line added to install.sh, run in a fresh home (sets EV_RC) 536 edited_run() { home "$2"; rm -rf "$W/ev-$2"; git clone -q "$1" "$W/ev-$2"; printf '# my note\n' >> "$W/ev-$2/install.sh"; INSTALLER=$W/ev-$2 inst --quick > "$W/ev-$2.log" 2>&1; EV_RC=$?; } 537 edited_run "$HERE" v 538 check V-edited-install-is-refused [ "$EV_RC" = 3 ] 539 check V-says-what-to-do grep -q 'it has changes that are not committed' "$W/ev-v.log" 540 check V-edited-install-wrote-nothing none_of "$H/.local" "$H/.config" 541 git -C "$W/ev-v" -c user.name=t -c user.email=t@t commit -q -am note 542 INSTALLER=$W/ev-v inst --quick > "$W/v2.log" 2>&1; rc=$? 543 check V-committed-it-installs [ "$rc" = 0 ] 544 check V-committed-store-has-that-commit [ "$(store_install_main)" = "$(git -C "$W/ev-v" rev-parse HEAD)" ] 545 546 # --- Y: the next Omega release (review 3: a changed pin left the first omc in ~/.local/bin for good) ----- 547 # next_release: from the store of the home H, a source that serves the next Omega release (one more omega-mv 548 # commit whose seed/out/omc is one byte longer) and an installer, a child of this one, pinned to it. 549 # Sets NEXT_SRC, NEXT_INST, NEXT_COMMIT, NEXT_SHA. 550 next_release() { 551 local sp=$H/$DATA/store/projects g mode blob tree 552 NEXT_SRC=$W/srcy; rm -rf "$NEXT_SRC" "$W/ynext" "$W/idx-y"; mkdir -p "$NEXT_SRC/omega-mv" "$NEXT_SRC/interplane-forge" 553 git clone -q --bare "$sp/interplane-forge/repo.git" "$NEXT_SRC/interplane-forge/repo.git" 554 git clone -q --bare "$sp/omega-mv/repo.git" "$NEXT_SRC/omega-mv/repo.git" 555 g=$NEXT_SRC/omega-mv/repo.git 556 mode=$(git --git-dir="$g" ls-tree main seed/out/omc | cut -d' ' -f1) 557 { git --git-dir="$g" show main:seed/out/omc; printf x; } > "$W/omc-next" 558 NEXT_SHA=$(sha256sum < "$W/omc-next" | cut -d' ' -f1) 559 blob=$(git --git-dir="$g" hash-object -w "$W/omc-next") 560 GIT_INDEX_FILE=$W/idx-y git --git-dir="$g" read-tree main 561 GIT_INDEX_FILE=$W/idx-y git --git-dir="$g" update-index --add --cacheinfo "$mode,$blob,seed/out/omc" 562 tree=$(GIT_INDEX_FILE=$W/idx-y git --git-dir="$g" write-tree) 563 NEXT_COMMIT=$(git --git-dir="$g" -c user.name=t -c user.email=t@t commit-tree "$tree" -p main -m "next release") 564 git --git-dir="$g" update-ref refs/heads/main "$NEXT_COMMIT" 565 git clone -q "$HERE" "$W/ynext" 566 sed -i -e "s/^OMEGA_RELEASE=.*/OMEGA_RELEASE=$NEXT_COMMIT/" -e "s/^OMEGA_RELEASE_OMC_SHA256=.*/OMEGA_RELEASE_OMC_SHA256=$NEXT_SHA/" "$W/ynext/install.sh" 567 git -C "$W/ynext" -c user.name=t -c user.email=t@t commit -q -am "next Omega release" 568 NEXT_INST=$W/ynext 569 } 570 home y 571 inst --quick > "$W/y1.log" 2>&1; rc=$? 572 check Y-first-install-exit-0 [ "$rc" = 0 ] 573 next_release 574 INSTALLER=$NEXT_INST SOURCE=$NEXT_SRC inst --quick > "$W/y2.log" 2>&1; rc=$? 575 check Y-upgrade-exit-0 [ "$rc" = 0 ] 576 check Y-omc-in-bin-is-the-new-release [ "$(bin_omc_sha)" = "$NEXT_SHA" ] 577 check Y-says-it-updated grep -q "^updated $H/.local/bin/omc to the compiler of Omega $NEXT_COMMIT" "$W/y2.log" 578 check Y-final-line-names-the-new-omc grep -q "^Omega: $H/.local/bin/omc " "$W/y2.log" 579 check Y-store-has-the-new-omega [ "$(git --git-dir="$H/$DATA/store/projects/omega-mv/repo.git" rev-parse main)" = "$NEXT_COMMIT" ] 580 # the installer of the old release run again is refused: nothing goes back 581 h1=$(store_hash) 582 SOURCE=$NEXT_SRC inst --quick > "$W/y3.log" 2>&1; rc=$? 583 check Y-older-installer-refused [ "$rc" = 3 ] 584 check Y-older-installer-left-the-new-omc [ "$(bin_omc_sha)" = "$NEXT_SHA" ] 585 check Y-older-installer-left-the-new-compiler-in-lib [ "$(sha256sum < "$H/$DATA/lib/omc" | cut -d' ' -f1)" = "$NEXT_SHA" ] 586 check Y-older-installer-left-the-store [ "$(store_hash)" = "$h1" ] 587 # an omc of your own is kept through the upgrade: one that was there first, and one you put in place afterwards 588 home y2; mkdir -p "$H/.local/bin"; printf '#!/bin/sh\necho mine\n' > "$H/.local/bin/omc"; chmod +x "$H/.local/bin/omc" 589 inst --quick > /dev/null 2>&1 590 INSTALLER=$NEXT_INST SOURCE=$NEXT_SRC inst --quick > "$W/y4.log" 2>&1; rc=$? 591 check Y-own-omc-upgrade-exit-0 [ "$rc" = 0 ] 592 check Y-own-omc-is-kept [ "$("$H/.local/bin/omc")" = mine ] 593 check Y-own-omc-says-so grep -q '^kept your existing .*/omc' "$W/y4.log" 594 check Y-own-omc-final-line-says-so grep -q '^Omega: your own .*/omc is kept' "$W/y4.log" 595 home y3 596 inst --quick > /dev/null 2>&1 597 rm -f "$H/.local/bin/omc"; printf '#!/bin/sh\necho mine\n' > "$H/.local/bin/omc"; chmod +x "$H/.local/bin/omc" 598 INSTALLER=$NEXT_INST SOURCE=$NEXT_SRC inst --quick > "$W/y5.log" 2>&1; rc=$? 599 check Y-replaced-omc-upgrade-exit-0 [ "$rc" = 0 ] 600 check Y-replaced-omc-is-kept [ "$("$H/.local/bin/omc")" = mine ] 601 # a piped installer whose pins are not the pins of the installer the source serves is refused before anything is built or recorded 602 mkdir -p "$NEXT_SRC/interplane-install"; git clone -q --bare "$NEXT_INST" "$NEXT_SRC/interplane-install/repo.git" 603 home y4 604 ( cd "$H" && env -i HOME="$H" PATH=/usr/bin:/bin INTERPLANE_SOURCE="$NEXT_SRC" sh -s -- --quick < "$HERE/install.sh" ) > "$W/y6.log" 2>&1; rc=$? 605 check Y-piped-with-other-pins-is-refused [ "$rc" = 3 ] 606 check Y-piped-with-other-pins-says-why grep -q 'is not the one it would put in your store' "$W/y6.log" 607 check Y-piped-with-other-pins-built-and-recorded-nothing none_of "$H/$DATA/interplane" "$H/.local/bin/omc" "$H/$DATA/lib/omc" 608 check Y-piped-with-other-pins-recorded-no-project empty_store 609 610 # --- GV: a git that is too old is named, and nothing is written ----------------------------------------- 611 home gv; mkdir -p "$W/oldgit" 612 printf '#!/bin/sh\nif [ "$1" = --version ]; then echo "git version 2.25.1"; else exec /usr/bin/git "$@"; fi\n' > "$W/oldgit/git"; chmod +x "$W/oldgit/git" 613 P="$W/oldgit:/usr/bin:/bin" inst --quick > "$W/gv.log" 2>&1; rc=$? 614 check GV-old-git-refused [ "$rc" = 2 ] 615 check GV-names-the-version grep -q 'git 2.25 is too old: this installer needs git 2.29' "$W/gv.log" 616 check GV-wrote-nothing none_of "$H/.local" "$H/.config" 617 618 # --- GET: a working copy of a private project follows your umask and says when others can read it (home a) --- 619 H=$W/a 620 ( umask 022 && ipc get secret "$W/got-open" ) > "$W/get1.log" 2>&1 621 check GET-private-open-says-so grep -q '^note: secret is a private project, and .* is accessible to other accounts' "$W/get1.log" 622 check GET-private-open-follows-umask mode_is 755 "$W/got-open" 623 ( umask 077 && ipc get secret "$W/got-closed" ) > "$W/get2.log" 2>&1 624 check GET-private-closed-has-no-note bash -c '! grep -q "^note:" "$1"' _ "$W/get2.log" 625 check GET-private-closed-follows-umask mode_is 700 "$W/got-closed" 626 ( umask 022 && ipc get mine "$W/got-pub" ) > "$W/get3.log" 2>&1 627 check GET-public-has-no-note bash -c '! grep -q "^note:" "$1"' _ "$W/get3.log" 628 629 # --- mutants: the gate's own cases must fail against an installer with one fault each --------------- 630 # The invariants are not run on these (they are expected to be wrong). 631 INV=0 632 # mutate NAME FILE SED-EXPR: a copy of MUTBASE (this repository unless set) with that one edit, committed on its main (MUT) 633 MUTBASE=$HERE 634 mutate() { 635 MUT=$W/mut-$1 636 git clone -q "$MUTBASE" "$MUT" 637 sed -i "$3" "$MUT/$2" 638 check "MUT-$1-is-a-mutant" bash -c '! cmp -s "$1" "$2"' _ "$MUTBASE/$2" "$MUT/$2" 639 git -C "$MUT" -c user.name=t -c user.email=t@t commit -q -am "mutant $1" 640 nmut=$((nmut + 1)) 641 } 642 # (i) the update of main from the source removed: S must fail 643 mutate no-source-fetch install.sh 's#--no-write-fetch-head "\$SRC/\$1/repo.git" "+refs/heads/main:refs/heads/source"#--no-write-fetch-head "/nonexistent/\$1.git" "+refs/heads/main:refs/heads/source"#' 644 home mu1; inst --quick > /dev/null 2>&1 645 src_update_run "$MUT" mu1 646 check MUT-no-source-fetch-run-finished [ "$SU_RC" = 0 ] 647 kill_check MUT-no-source-fetch-fails-S-store-has-the-new-main su_new_main 648 # (ii) the removal of export marks in share removed: the stray-mark case must fail 649 mutate no-mark-removal bin/interplane 's#; rm -f "\$d/repo.git/git-daemon-export-ok"##' 650 home mu2; inst --quick > /dev/null 2>&1; ipc new pub --public > /dev/null 2>&1 651 share_with_stray_mark "$MUT/bin/interplane" omega-mv 652 stop_share 653 kill_check MUT-no-mark-removal-fails-D-stray-export-mark-is-removed none_of "$H/$DATA/store/projects/omega-mv/repo.git/git-daemon-export-ok" 654 # (iii) the removal of the password from the shown source removed: the password case must fail 655 mutate no-shown install.sh 's/^SHOWN=.*/SHOWN=$SRC/' 656 home mu3 657 pw_run "$MUT" mu3 658 check MUT-no-shown-run-finished [ "$PW_RC" = 0 ] 659 kill_check MUT-no-shown-fails-W-no-password-anywhere pw_clean 660 # (iv) an omc this installer put there earlier is never replaced: the next-release case must fail 661 MUTBASE=$W/ynext 662 mutate omc-never-replaced install.sh 's#elif \[ -n "\$OMCCUR" \] \&\& grep -qxF#elif false \&\& grep -qxF#' 663 MUTBASE=$HERE 664 home mu4; inst --quick > /dev/null 2>&1 665 INSTALLER=$MUT SOURCE=$NEXT_SRC inst --quick > "$W/mu4.log" 2>&1; rc=$? 666 check MUT-omc-never-replaced-run-finished [ "$rc" = 0 ] 667 kill_check MUT-omc-never-replaced-fails-Y-omc-in-bin-is-the-new-release [ "$(bin_omc_sha)" = "$NEXT_SHA" ] 668 # the invariants themselves catch it too (this is the tool broken once: they must say what is wrong) 669 INSTALLER=$MUT check INV-catches-an-omc-of-ours-left-stale not inv_holds "$W/mu4.log" 670 # (v) the checkout found by its logical path instead of its physical one: the symlinked workspace case must fail 671 mutate logical-path install.sh 's#ME=\$(dirname "\$(realpath "\$0")")#ME=$(cd "$(dirname "$0")" \&\& pwd)#' 672 rm -rf "$W/xreal/mutinst"; git clone -q "$MUT" "$W/xreal/mutinst" 673 home mu5; INSTALLER=$W/xlink/mutinst SOURCE=$SX inst --quick > "$W/mu5.log" 2>&1 674 kill_check MUT-logical-path-fails-X-symlinked-workspace-installs-the-checkout [ "$(store_install_main)" = "$(git -C "$W/xreal/mutinst" rev-parse HEAD)" ] 675 # (vi) an edited install.sh accepted: the edited-installer case must fail 676 mutate allow-edited-install install.sh 's#\[ -n "\$myblob" \] \&\& \[ "\$myblob" = "\$cblob" \] ||#true ||#' 677 edited_run "$MUT" mu6 678 kill_check MUT-allow-edited-install-fails-V-edited-install-is-refused [ "$EV_RC" = 3 ] 679 # (vii) an installer older than the one in the store accepted: the older-installer case must fail 680 mutate allow-older install.sh 's#if \[ -n "\$have" \] \&\&#if false \&\&#' 681 rm -rf "$W/mut7up"; git clone -q "$MUT" "$W/mut7up"; printf '# newer\n' >> "$W/mut7up/bin/interplane"; git -C "$W/mut7up" -c user.name=t -c user.email=t@t commit -q -am newer 682 home mu7; INSTALLER=$W/mut7up inst --quick > /dev/null 2>&1 683 INSTALLER=$MUT inst --quick > "$W/mu7.log" 2>&1; rc=$? 684 kill_check MUT-allow-older-fails-L-older-installer-refused [ "$rc" = 3 ] 685 # (viii) a password with an @ in it cut at the first @: the password case must fail 686 mutate first-at install.sh 's#\[^/\]\*@#[^/@]*@#' 687 home mu8 688 pw_run "$MUT" mu8 689 check MUT-first-at-run-finished [ "$PW_RC" = 0 ] 690 kill_check MUT-first-at-fails-W-no-password-anywhere pw_clean 691 # (ix) the installer that runs and the one recorded may have other pins: the other-pins case must fail 692 mutate allow-other-pins install.sh 's#\[ "\$STOREPINS" = #true || [ "$STOREPINS" = #' 693 home mu9 694 ( cd "$H" && env -i HOME="$H" PATH=/usr/bin:/bin INTERPLANE_SOURCE="$NEXT_SRC" sh -s -- --quick < "$MUT/install.sh" ) > "$W/mu9.log" 2>&1; rc=$? 695 kill_check MUT-allow-other-pins-fails-Y-piped-with-other-pins-is-refused [ "$rc" = 3 ] 696 echo "host: $(uname -sm), $(git --version), $(ssh -V 2>&1), $(bash --version | head -n 1)" 697 # every kind of defect in tests/LESSONS.tsv has at least one passing case of each name it lists 698 while IFS="$(printf '\t')" read -r kind what prefixes; do 699 case $kind in '' | '#'*) continue ;; esac 700 for p in $(printf '%s' "$prefixes" | tr ',' ' '); do 701 if grep -q "^$p" "$W/names"; then ok "LESSON-$kind-has-a-case-$p"; else no "LESSON-$kind-has-no-case-$p"; fi 702 done 703 done < "$HERE/tests/LESSONS.tsv" 704 if [ "$fail" = 0 ] && [ "$nmut" -gt 0 ] && [ "$killed" = "$nmut" ]; then echo "GATE PASS cases=$pass mutants_killed=$killed"; else echo "GATE FAIL pass=$pass fail=$fail mutants_killed=$killed of $nmut"; for l in "$W"/*.log; do echo "--- $l"; tail -n 5 "$l"; done; exit 1; fi