Smoketest sibling projects on top of CoreDesktop

The scenario helpers now take a chain of projects from the driver
(SMOKETEST_CHAIN_FILE): CoreDesktop, then sibling projects such as HamPack.
Each gets a fake upstream in the VM; upstream_set and upstream_commit take
an optional project name; smoketest_prepare updates every project in the
installed image; and the new smoketest_build_layer, sibling_add and
install_chain install them. health also runs each installed sibling's
smoketest/health, and a sibling's smoketest/setup runs before each scenario.

Without a chain file, everything works as before, so older drivers and
CoreDesktop's own scenarios are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-26 10:15:10 -07:00
co-authored by Claude Opus 5.5
parent 4fb35397ee
commit 4f1e18200c
3 changed files with 439 additions and 52 deletions
+40 -3
View File
@@ -79,9 +79,13 @@ Helpers, from `lib/scenario.sh`:
| `cd_install` | Run install.sh as `wget ... \| bash` would, from the fake upstream's main | | `cd_install` | Run install.sh as `wget ... \| bash` would, from the fake upstream's main |
| `cd_update [VAR=value...]` | Run `update` | | `cd_update [VAR=value...]` | Run `update` |
| `run_in_vm NAME SCRIPT` | Run SCRIPT in the VM; sets `$OUTPUT` and `$STATUS`, logs to NAME.log | | `run_in_vm NAME SCRIPT` | Run SCRIPT in the VM; sets `$OUTPUT` and `$STATUS`, logs to NAME.log |
| `upstream_set REF` | Point the fake upstream's main at REF, a commit in this repo | | `upstream_set [PROJECT] REF` | Point the fake upstream's main at REF, a commit in the project's working copy (default: CoreDesktop) |
| `upstream_commit MESSAGE SCRIPT` | Run SCRIPT in a clone of the upstream (in the VM), commit, push | | `upstream_commit [PROJECT] MESSAGE SCRIPT` | Run SCRIPT in a clone of the project's upstream (in the VM), commit, push |
| `fingerprint FILE` / `health` | Save the fingerprint / run the health checks | | `sibling_add PROJECT` | Run `sibling add` with the sibling project's URL |
| `install_chain` | Install CoreDesktop and every sibling in the run, rebooting as the READMEs say |
| `fingerprint FILE` | Save the fingerprint |
| `health [PROJECT...]` | Run the health checks: by default CoreDesktop's, and those of each sibling in the run that's installed |
| `in_run PROJECT` | True if the sibling project is in this run |
| `assert_status N`, `assert_output TEXT`, `refute_output TEXT` | Check the last `run_in_vm` | | `assert_status N`, `assert_output TEXT`, `refute_output TEXT` | Check the last `run_in_vm` |
| `assert_vm DESCRIPTION SCRIPT` | SCRIPT must succeed in the VM | | `assert_vm DESCRIPTION SCRIPT` | SCRIPT must succeed in the VM |
| `assert_same_fingerprint EXPECTED ACTUAL` | The two must match; saves the diff | | `assert_same_fingerprint EXPECTED ACTUAL` | The two must match; saves the diff |
@@ -101,9 +105,42 @@ Helpers, from `lib/scenario.sh`:
| `SMOKETEST_RESULTS` | This scenario's folder for logs and fingerprints | | `SMOKETEST_RESULTS` | This scenario's folder for logs and fingerprints |
| `SMOKETEST_SHARED` | A folder shared by all scenarios in the run | | `SMOKETEST_SHARED` | A folder shared by all scenarios in the run |
| `IMAGE_REF` | For the installed image, the commit it was installed at | | `IMAGE_REF` | For the installed image, the commit it was installed at |
| `SMOKETEST_CHAIN_FILE` | Optional: the projects in the run (below). Without it, the run is CoreDesktop alone, at `SMOKETEST_REF`, in an image at `IMAGE_REF` |
To build the installed image, the driver calls `smoketest_build_layer CoreDesktop
SHA` on the base image instead of `smoketest_prepare`; and for a sibling's
image layer, `smoketest_build_layer NAME SHA` on the image below it.
Anything that boots a VM can drive these scenarios, e.g. a CI runner with KVM. Anything that boots a VM can drive these scenarios, e.g. a CI runner with KVM.
## Sibling projects
A sibling project (HamPack, say) can have scenarios of its own, run on top of
CoreDesktop's: `coredesktop-dev smoketest run --with HamPack`. Its working copy,
beside CoreDesktop's, has a `smoketest/project.conf`:
```
NAME=HamPack
PARENT=CoreDesktop # or a sibling it's built on
URLS=(https://gitea.young.computer/david/HamPack.git)
```
and its scenarios in `smoketest/scenarios/`, written like CoreDesktop's with
these helpers. Optionally, it has `smoketest/health`, run by `health`, and
`smoketest/setup`, run in the VM before every scenario and image build of a
run it's in, for what it needs on any machine it's tested on.
The run includes CoreDesktop's scenarios too, so it also checks the sibling
doesn't break CoreDesktop. Each sibling gets a fake upstream in the VM like
CoreDesktop's, and the installed image is layered: `installed+HamPack` is
installed after `sibling add HamPack`. Scenarios on it start by updating every
project to its commit under test.
The driver describes the run in `SMOKETEST_CHAIN_FILE`, one line per project,
CoreDesktop first, tab-separated: name, working copy, commit under test, commit
in the image (empty if none), and its URLs, separated by spaces (none for
CoreDesktop, whose are `COREDESKTOP_URLS`).
## Not covered ## Not covered
NVIDIA drivers, firmware updates (`updates.d/90-firmware.sh`), and anything that NVIDIA drivers, firmware updates (`updates.d/90-firmware.sh`), and anything that
+256 -49
View File
@@ -3,17 +3,30 @@
# Purpose : Helpers and assertions for smoketest scenarios (see ../README.md). # Purpose : Helpers and assertions for smoketest scenarios (see ../README.md).
# Sourced by the driver after it defines vm_exec, vm_put and # Sourced by the driver after it defines vm_exec, vm_put and
# vm_reboot. # vm_reboot.
#
# A run tests a chain of projects: CoreDesktop, then any sibling projects
# (HamPack, say) the driver was asked for. The driver describes the chain in
# the file SMOKETEST_CHAIN_FILE, one line per project, tab-separated:
#
# name working copy commit under test commit in the image URLs (by spaces)
#
# CoreDesktop comes first, with no URLs: it has COREDESKTOP_URLS. Without a
# chain file, the chain is CoreDesktop alone, at SMOKETEST_REF, in an image at
# IMAGE_REF, as drivers before sibling projects described it.
SMOKETEST_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" SMOKETEST_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
# The CoreDesktop repo whose commits are tested. Overridable for the tests. # The CoreDesktop repo whose commits are tested. Overridable for the tests.
SMOKETEST_REPO="${SMOKETEST_REPO:-$(cd "$SMOKETEST_DIR/.." && pwd)}" SMOKETEST_REPO="${SMOKETEST_REPO:-$(cd "$SMOKETEST_DIR/.." && pwd)}"
# In the VM: the fake upstream, the scratch clone upstream_commit works in, and # In the VM: the fake upstreams, the scratch clone upstream_commit works in, and
# where the fingerprint and health scripts are copied to # where the fingerprint, health and setup scripts are copied to
SMOKETEST_VM_DIR="${SMOKETEST_VM_DIR:-/srv/smoketest}" SMOKETEST_VM_DIR="${SMOKETEST_VM_DIR:-/srv/smoketest}"
UPSTREAM="$SMOKETEST_VM_DIR/coredesktop.git" UPSTREAM="$SMOKETEST_VM_DIR/coredesktop.git"
WORK="$SMOKETEST_VM_DIR/work" WORK="$SMOKETEST_VM_DIR/work"
# The chain's first project
ROOT_PROJECT=CoreDesktop
# Every URL CoreDesktop has been cloned from, so install.sh at any baseline # Every URL CoreDesktop has been cloned from, so install.sh at any baseline
# clones the fake upstream instead # clones the fake upstream instead
COREDESKTOP_URLS=( COREDESKTOP_URLS=(
@@ -46,6 +59,82 @@ skip() {
exit "$SKIP_STATUS" exit "$SKIP_STATUS"
} }
# --- The chain ---------------------------------------------------------------
# The chain file's lines, or CoreDesktop's alone without one
chain_lines() {
if [ -n "${SMOKETEST_CHAIN_FILE:-}" ]; then
cat "$SMOKETEST_CHAIN_FILE"
else
printf '%s\t%s\t%s\t%s\t\n' "$ROOT_PROJECT" "$SMOKETEST_REPO" "${SMOKETEST_REF:-}" "${IMAGE_REF:-}"
fi
}
# The projects in the chain, CoreDesktop first, one per line
chain_names() {
chain_lines | cut -f1
}
# The sibling projects in the chain, one per line
chain_siblings() {
chain_names | tail -n +2
}
# chain_field NAME COLUMN: 2 working copy, 3 commit under test, 4 commit in
# the image, 5 URLs
chain_field() {
chain_lines | awk -F'\t' -v n="$1" -v c="$2" '$1 == n { print $c }'
}
project_dir() { chain_field "$1" 2; }
project_sha() { chain_field "$1" 3; }
image_sha() { chain_field "$1" 4; }
# project_urls NAME: the URLs project NAME is cloned from, one per line
project_urls() {
if [ "$1" = "$ROOT_PROJECT" ]; then
printf '%s\n' "${COREDESKTOP_URLS[@]}"
else
chain_field "$1" 5 | tr ' ' '\n' | grep .
fi
}
# The URL a sibling project is added from (its first)
project_url() {
project_urls "$1" | head -n 1
}
# True if project NAME is in this run's chain
in_run() {
chain_names | grep -qxF "$1"
}
# upstream NAME: the project's fake upstream in the VM
upstream() {
if [ "$1" = "$ROOT_PROJECT" ]; then
echo "$UPSTREAM"
else
echo "$SMOKETEST_VM_DIR/$1.git"
fi
}
# sibling_name NAME: the folder in ~/.local/share/siblings that `sibling add`
# clones project NAME into: its URL's last part, without .git
sibling_name() {
local name
name="$(project_url "$1")"
name="${name%/}"
name="${name##*/}"
echo "${name%.git}"
}
# True if sibling project NAME is installed in the VM
sibling_installed() {
vm_exec "test -d ~/.local/share/siblings/$(q "$(sibling_name "$1")")" > /dev/null 2>&1
}
# --- Running things in the VM ------------------------------------------------
# run_in_vm NAME SCRIPT: run SCRIPT in the VM, keeping its output in $OUTPUT, # run_in_vm NAME SCRIPT: run SCRIPT in the VM, keeping its output in $OUTPUT,
# its exit status in $STATUS, and both in NN-NAME.log. Doesn't fail on its own: # its exit status in $STATUS, and both in NN-NAME.log. Doesn't fail on its own:
# check with assert_status. The log is written as SCRIPT runs, so a long one # check with assert_status. The log is written as SCRIPT runs, so a long one
@@ -79,58 +168,67 @@ progress_ticker() {
done done
} }
# Called by the driver once the VM is up, before the scenario # --- Fake upstreams ----------------------------------------------------------
smoketest_prepare() {
local urls="" url # Make a bare repo in the VM for each project in the chain, and have git send
for url in "${COREDESKTOP_URLS[@]}"; do # the project's real URLs there, so install.sh, sibling add and update run
urls+=" $(q "$url")" # unchanged
done setup_upstreams() {
vm_exec "set -e local script="set -e
[ -d $(q "$UPSTREAM") ] || git init -q --bare --initial-branch=main $(q "$UPSTREAM")
git config --global user.name 'CoreDesktop Smoketest' git config --global user.name 'CoreDesktop Smoketest'
git config --global user.email smoketest@localhost git config --global user.email smoketest@localhost" name url up
git config --global --unset-all url.$(q "$UPSTREAM").insteadOf || true while read -r name; do
for url in $urls; do up="$(q "$(upstream "$name")")"
git config --global --add url.$(q "$UPSTREAM").insteadOf \"\$url\" script+="
done" || fail "couldn't set up the fake upstream in the VM" [ -d $up ] || git init -q --bare --initial-branch=main $up
git config --global --unset-all url.$up.insteadOf || true"
if [ "${IMAGE:-}" = installed ]; then while read -r url; do
git -C "$SMOKETEST_REPO" merge-base --is-ancestor "$IMAGE_REF" "$SMOKETEST_REF" \ script+="
|| fail "the installed image is at $IMAGE_REF, which isn't in the history of" \ git config --global --add url.$up.insteadOf $(q "$url")"
"the commit under test. Rebuild it: coredesktop-dev smoketest images --installed" # A sibling may be added by its URL with or without .git; each is matched
upstream_set "$SMOKETEST_REF" # as a prefix, and the longer wins
cd_update if [ "$name" != "$ROOT_PROJECT" ] && [[ "$url" == *.git ]]; then
assert_status 0 script+="
else git config --global --add url.$up.insteadOf $(q "${url%.git}")"
upstream_set "$SMOKETEST_REF" fi
fi done < <(project_urls "$name")
done < <(chain_names)
vm_exec "$script" || fail "couldn't set up the fake upstreams in the VM"
} }
# Called by the driver to make the installed image from the base image # upstream_set [NAME] REF: point project NAME's (default CoreDesktop's) fake
smoketest_install_image() { # upstream main at REF, a commit in its working copy
smoketest_prepare
upstream_set "$1"
cd_install
assert_status 0
}
# upstream_set REF: point the fake upstream's main at REF, a commit in this repo
upstream_set() { upstream_set() {
local sha local name="$ROOT_PROJECT" dir sha
sha="$(git -C "$SMOKETEST_REPO" rev-parse --verify --quiet "$1^{commit}")" \ if (( $# > 1 )); then
|| fail "no such commit: $1" name="$1"
shift
fi
dir="$(project_dir "$name")"
[ -n "$dir" ] || fail "$name isn't in this run's chain"
if ! sha="$(git -C "$dir" rev-parse --verify --quiet "$1^{commit}")"; then
[ "$name" = "$ROOT_PROJECT" ] && fail "no such commit: $1"
fail "no such commit in $name: $1"
fi
# --no-verify: a pre-push hook in the working copy (coredesktop-dev's runs # --no-verify: a pre-push hook in the working copy (coredesktop-dev's runs
# make check) is for pushes to the real upstream, not to the VM # make check) is for pushes to the real upstream, not to the VM
GIT_SSH_COMMAND="${VM_GIT_SSH:-ssh}" git -C "$SMOKETEST_REPO" push --quiet --force --no-verify \ GIT_SSH_COMMAND="${VM_GIT_SSH:-ssh}" git -C "$dir" push --quiet --force --no-verify \
"${VM_GIT_URL:-}$UPSTREAM" "$sha:refs/heads/main" || fail "couldn't push $1 to the VM" "${VM_GIT_URL:-}$(upstream "$name")" "$sha:refs/heads/main" || fail "couldn't push $name $1 to the VM"
} }
# upstream_commit MESSAGE SCRIPT: release a new commit, made by running SCRIPT # upstream_commit [NAME] MESSAGE SCRIPT: release a new commit of project NAME
# (in the VM) in a clone of the fake upstream's main # (default CoreDesktop), made by running SCRIPT (in the VM) in a clone of its
# fake upstream's main
upstream_commit() { upstream_commit() {
local name="$ROOT_PROJECT"
if (( $# > 2 )); then
name="$1"
shift
fi
in_run "$name" || fail "$name isn't in this run's chain"
run_in_vm commit "set -e run_in_vm commit "set -e
rm -rf $(q "$WORK") rm -rf $(q "$WORK")
git clone -q $(q "$UPSTREAM") $(q "$WORK") git clone -q $(q "$(upstream "$name")") $(q "$WORK")
cd $(q "$WORK") cd $(q "$WORK")
$2 $2
git add -A git add -A
@@ -139,6 +237,75 @@ upstream_commit() {
assert_status 0 assert_status 0
} }
# Run each project's smoketest/setup in the VM, if it has one: what a project
# needs set up on any machine it's tested on (HamPack's turns off its Windows
# installers, which wait for clicks no one makes)
run_setup_scripts() {
local name script
while read -r name; do
script="$(project_dir "$name")/smoketest/setup"
[ -f "$script" ] || continue
vm_put "$script" "$SMOKETEST_VM_DIR/setup-$name" || fail "couldn't copy $name's setup script to the VM"
run_in_vm "setup-$name" "bash $(q "$SMOKETEST_VM_DIR/setup-$name")"
assert_status 0
done < <(chain_names)
}
# --- Called by the driver ----------------------------------------------------
# Once the VM is up, before the scenario: point each fake upstream at the
# commit under test. On the installed image, update to it.
smoketest_prepare() {
local name image
setup_upstreams
run_setup_scripts
while read -r name; do
if [ "${IMAGE:-}" = installed ]; then
image="$(image_sha "$name")"
git -C "$(project_dir "$name")" merge-base --is-ancestor "$image" "$(project_sha "$name")" \
|| fail "the installed image has $name at $image, which isn't in the history of the" \
"commit under test. Rebuild it: coredesktop-dev smoketest images installed" \
"(with the same --with options)"
fi
upstream_set "$name" "$(project_sha "$name")"
done < <(chain_names)
if [ "${IMAGE:-}" = installed ]; then
cd_update
assert_status 0
fi
}
# To build an image layer: install project NAME at SHA on a machine that has
# the projects before it in the chain, then reboot, as the READMEs say to
smoketest_build_layer() {
local name="$1" sha="$2" other
setup_upstreams
run_setup_scripts
while read -r other; do
upstream_set "$other" "$(image_sha "$other")"
done < <(chain_names | grep -vxF "$name")
upstream_set "$name" "$sha"
if [ "$name" = "$ROOT_PROJECT" ]; then
cd_install
else
sibling_add "$name"
fi
assert_status 0
vm_reboot
}
# For drivers from before smoketest_build_layer: the installed image from the
# base image
smoketest_install_image() {
smoketest_prepare
upstream_set "$1"
cd_install
assert_status 0
}
# --- What a person would run -------------------------------------------------
# Run install.sh the way the README's wget ... | bash does: main's install.sh, # Run install.sh the way the README's wget ... | bash does: main's install.sh,
# with no terminal to ask questions on # with no terminal to ask questions on
cd_install() { cd_install() {
@@ -157,6 +324,28 @@ cd_update() {
run_in_vm update "TERM=dumb env$vars ~/.local/bin/update" run_in_vm update "TERM=dumb env$vars ~/.local/bin/update"
} }
# sibling_add NAME: add sibling project NAME from its (real) URL, as its README
# says to
sibling_add() {
in_run "$1" || fail "$1 isn't in this run's chain"
run_in_vm "sibling-add-$1" "TERM=dumb ~/.local/bin/sibling add $(q "$(project_url "$1")")"
}
# Install CoreDesktop and every sibling in the chain at the commits under test,
# as a person would on a fresh machine, rebooting where the READMEs say to
install_chain() {
local name added=0
cd_install
assert_status 0
vm_reboot
while read -r name; do
sibling_add "$name"
assert_status 0
added=1
done < <(chain_siblings)
(( added == 0 )) || vm_reboot
}
# fingerprint FILE: save the machine's fingerprint to FILE # fingerprint FILE: save the machine's fingerprint to FILE
fingerprint() { fingerprint() {
vm_put "$SMOKETEST_DIR/fingerprint" "$SMOKETEST_VM_DIR/fingerprint" \ vm_put "$SMOKETEST_DIR/fingerprint" "$SMOKETEST_VM_DIR/fingerprint" \
@@ -170,13 +359,31 @@ reference_fingerprint() {
echo "$SMOKETEST_SHARED/fresh-install.fingerprint" echo "$SMOKETEST_SHARED/fresh-install.fingerprint"
} }
# Run the health checks; fail the scenario if any fails # health [NAME...]: run the health checks of the projects named (default:
# CoreDesktop, and each sibling in the chain that's installed in the VM and has
# a smoketest/health); fail the scenario if any fails
health() { health() {
vm_put "$SMOKETEST_DIR/health" "$SMOKETEST_VM_DIR/health" \ local names=("$@") name script dest log failed=()
|| fail "couldn't copy the health script to the VM" if (( ${#names[@]} == 0 )); then
run_in_vm health "bash $(q "$SMOKETEST_VM_DIR/health")" names=("$ROOT_PROJECT")
printf '%s\n' "$OUTPUT" while read -r name; do
[ "$STATUS" -eq 0 ] || fail "the health checks failed" [ -f "$(project_dir "$name")/smoketest/health" ] && sibling_installed "$name" && names+=("$name")
done < <(chain_siblings)
fi
for name in "${names[@]}"; do
if [ "$name" = "$ROOT_PROJECT" ]; then
script="$SMOKETEST_DIR/health" dest="$SMOKETEST_VM_DIR/health" log=health
else
script="$(project_dir "$name")/smoketest/health"
dest="$SMOKETEST_VM_DIR/health-$name" log="health-$name"
[ -f "$script" ] || fail "$name has no smoketest/health"
fi
vm_put "$script" "$dest" || fail "couldn't copy $name's health script to the VM"
run_in_vm "$log" "bash $(q "$dest")"
printf '%s\n' "$OUTPUT"
[ "$STATUS" -eq 0 ] || failed+=("$name")
done
(( ${#failed[@]} == 0 )) || fail "the health checks failed for: ${failed[*]}"
} }
assert_status() { assert_status() {
+143
View File
@@ -238,3 +238,146 @@ upstream_main() {
git -C "$REPO" rev-parse --verify --quiet "$ref^{commit}" > /dev/null || { echo "unknown: $ref"; exit 1; } git -C "$REPO" rev-parse --verify --quiet "$ref^{commit}" > /dev/null || { echo "unknown: $ref"; exit 1; }
done done
} }
# --- Sibling projects ---
# A sibling project, HamPack, with two commits, and a chain file with
# CoreDesktop and it: CoreDesktop at V1 in the image and V2 under test,
# HamPack likewise at S1 and S2
chain_with_sibling() {
SIB="$BATS_TEST_TMPDIR/HamPack"
git init -q "$SIB"
echo s1 > "$SIB/version"
git -C "$SIB" add version
git -C "$SIB" commit -qm s1
S1="$(git -C "$SIB" rev-parse HEAD)"
echo s2 > "$SIB/version"
git -C "$SIB" commit -qam s2
S2="$(git -C "$SIB" rev-parse HEAD)"
export SMOKETEST_CHAIN_FILE="$BATS_TEST_TMPDIR/chain"
printf 'CoreDesktop\t%s\t%s\t%s\t\n' "$SMOKETEST_REPO" "$V2" "$V1" > "$SMOKETEST_CHAIN_FILE"
printf 'HamPack\t%s\t%s\t%s\t%s\n' "$SIB" "$S2" "$S1" \
"https://example.com/david/HamPack.git https://example.org/HamPack.git" >> "$SMOKETEST_CHAIN_FILE"
SIB_UPSTREAM="$SMOKETEST_VM_DIR/HamPack.git"
# A fake `sibling add`, which clones like the real one, and update and reboot
mkdir -p "$HOME/.local/bin"
printf '%s\n' '#!/bin/bash' 'echo "sibling $*" >> ~/vm.log' \
'git clone -q "$2" ~/.local/share/siblings/"$(basename "${2%.git}")"' > "$HOME/.local/bin/sibling"
printf '%s\n' '#!/bin/bash' 'echo update >> ~/vm.log' > "$HOME/.local/bin/update"
chmod +x "$HOME/.local/bin/sibling" "$HOME/.local/bin/update"
vm_reboot() { echo reboot >> "$HOME/vm.log"; }
}
@test "without a chain file, the chain is CoreDesktop at the commit under test" {
[ "$(chain_names)" = CoreDesktop ]
[ "$(project_sha CoreDesktop)" = "$V2" ]
[ -z "$(chain_siblings)" ]
}
@test "prepare makes a fake upstream for each project, and sends its URLs there" {
chain_with_sibling
smoketest_prepare
[ "$(upstream_main)" = "$V2" ]
[ "$(git --git-dir="$SIB_UPSTREAM" rev-parse main)" = "$S2" ]
for url in https://example.com/david/HamPack.git https://example.com/david/HamPack https://example.org/HamPack.git; do
git clone -q "$url" "$BATS_TEST_TMPDIR/clone"
[ "$(cat "$BATS_TEST_TMPDIR/clone/version")" = s2 ]
rm -rf "$BATS_TEST_TMPDIR/clone"
done
}
@test "prepare on the installed image checks every project's image commit, then updates once" {
chain_with_sibling
export IMAGE=installed
run smoketest_prepare
[ "$status" -eq 0 ]
[ "$(cat "$HOME/vm.log")" = update ]
printf 'HamPack\t%s\t%s\t%s\t%s\n' "$SIB" "$S1" "$S2" https://example.com/HamPack.git \
> "$BATS_TEST_TMPDIR/hampack-line"
sed -i '2d' "$SMOKETEST_CHAIN_FILE"
cat "$BATS_TEST_TMPDIR/hampack-line" >> "$SMOKETEST_CHAIN_FILE"
run smoketest_prepare
[ "$status" -eq 1 ]
[[ "$output" == *"the installed image has HamPack at $S2, which isn't in the history"* ]]
}
@test "upstream_set and upstream_commit take a project's name" {
chain_with_sibling
smoketest_prepare
upstream_set HamPack "$S1"
[ "$(git --git-dir="$SIB_UPSTREAM" rev-parse main)" = "$S1" ]
[ "$(upstream_main)" = "$V2" ]
upstream_commit HamPack "Bump" 'echo s3 > version'
[ "$(git --git-dir="$SIB_UPSTREAM" show main:version)" = s3 ]
[ "$(upstream_main)" = "$V2" ]
run upstream_set HamPack nosuchcommit
[[ "$output" == *"no such commit in HamPack: nosuchcommit"* ]]
run upstream_commit Nope "x" true
[ "$status" -eq 1 ]
[[ "$output" == *"Nope isn't in this run's chain"* ]]
}
@test "building a sibling's layer adds it at its commit, over the others at their image's, and reboots" {
chain_with_sibling
smoketest_build_layer HamPack "$S2"
[ "$(upstream_main)" = "$V1" ]
[ "$(cat "$HOME/.local/share/siblings/HamPack/version")" = s2 ]
[ "$(cat "$HOME/vm.log")" = "$(printf 'sibling add https://example.com/david/HamPack.git\nreboot')" ]
}
@test "building CoreDesktop's layer runs install.sh at its commit" {
vm_reboot() { echo reboot >> "$HOME/vm.log"; }
smoketest_build_layer CoreDesktop "$V1"
[ "$(cat "$HOME/vm.log")" = reboot ]
[ "$(head -n 1 "$HOME/installed")" = v1 ]
}
@test "install_chain installs CoreDesktop, reboots, adds each sibling and reboots again" {
chain_with_sibling
smoketest_prepare
install_chain
[ "$(cat "$HOME/vm.log")" = "$(printf 'reboot\nsibling add https://example.com/david/HamPack.git\nreboot')" ]
[ "$(head -n 1 "$HOME/installed")" = v2 ]
}
@test "a project's setup script runs in the VM before the scenario" {
chain_with_sibling
mkdir -p "$SIB/smoketest"
echo 'echo set up > ~/setup-ran' > "$SIB/smoketest/setup"
smoketest_prepare
[ "$(cat "$HOME/setup-ran")" = "set up" ]
echo 'exit 1' > "$SIB/smoketest/setup"
run smoketest_prepare
[ "$status" -eq 1 ]
[[ "$output" == *"setup-HamPack exited 1"* ]]
}
@test "health checks CoreDesktop, and each sibling that's installed and has health checks" {
chain_with_sibling
mkdir -p "$SIB/smoketest"
echo 'echo hampack healthy' > "$SIB/smoketest/health"
SMOKETEST_DIR="$BATS_TEST_TMPDIR/cd-smoketest"
mkdir -p "$SMOKETEST_DIR"
echo 'echo coredesktop healthy' > "$SMOKETEST_DIR/health"
run health
[ "$status" -eq 0 ]
[[ "$output" == *"coredesktop healthy"* ]]
[[ "$output" != *"hampack healthy"* ]]
mkdir -p "$HOME/.local/share/siblings/HamPack"
run health
[[ "$output" == *"coredesktop healthy"*"hampack healthy"* ]]
echo 'exit 1' > "$SIB/smoketest/health"
run health
[ "$status" -eq 1 ]
[[ "$output" == *"the health checks failed for: HamPack"* ]]
run health CoreDesktop
[ "$status" -eq 0 ]
}