buninu-linux 0.5.1 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,49 @@
1
+ #!/usr/bin/env bash
2
+ # Builds and boots both guests on a fresh Debian 13 host of either CPU, in
3
+ # Docker:
4
+ #
5
+ # test/host/host-test.sh [amd64|arm64]
6
+ #
7
+ # The platform defaults to this machine's own CPU; the other one runs
8
+ # emulated and takes a few times longer. The container (./Dockerfile) has the
9
+ # README's build packages and QEMU. It clones the committed HEAD of this
10
+ # checkout, so uncommitted changes to the project are not tested, then builds
11
+ # with the host toolchain rather than --docker and boots each guest through
12
+ # boot-test.exp. The exit status is 0 only when every step passed.
13
+ #
14
+ # GUESTS="aarch64" which guests to test (default: x86_64 aarch64)
15
+ # BUILD_FLAGS=--linux-lts extra flags for the build stage
16
+ # BOOT_TIMEOUT=900 seconds to wait for the REPL
17
+ # ALPINE_MIRROR=... passed through to the fetch stage
18
+ #
19
+ # downloads/ is mounted read-only as a cache; running `./index.js -f --arch
20
+ # <arch>` here first saves the container from downloading.
21
+ set -euo pipefail
22
+
23
+ cd "$(dirname "$0")/../.."
24
+
25
+ case "${1:-$(uname -m)}" in
26
+ amd64 | x86_64) platform=amd64 ;;
27
+ arm64 | aarch64) platform=arm64 ;;
28
+ *)
29
+ echo "usage: $0 [amd64|arm64]" >&2
30
+ exit 2
31
+ ;;
32
+ esac
33
+
34
+ image="buninu-linux-hosttest:$platform"
35
+ echo "### building $image (the first build takes a few minutes)"
36
+ docker build --quiet --platform "linux/$platform" --tag "$image" test/host > /dev/null
37
+
38
+ # A Linux host's KVM reaches the container too, so a guest that matches the
39
+ # platform runs accelerated. Docker Desktop on macOS exposes no /dev/kvm.
40
+ kvm_device=
41
+ if [ -e /dev/kvm ]; then kvm_device=--device=/dev/kvm; fi
42
+
43
+ mkdir -p downloads
44
+ # $kvm_device is empty or a single word.
45
+ exec docker run --rm --platform "linux/$platform" $kvm_device \
46
+ --mount "type=bind,src=$PWD,dst=/repo,readonly" \
47
+ --mount "type=bind,src=$PWD/downloads,dst=/cache,readonly" \
48
+ --env GUESTS --env BUILD_FLAGS --env BOOT_TIMEOUT --env ALPINE_MIRROR \
49
+ "$image" /repo/test/host/in-container.sh
@@ -0,0 +1,58 @@
1
+ #!/usr/bin/env bash
2
+ # Runs inside the container host-test.sh starts: an ordinary Debian 13 machine
3
+ # of the chosen CPU. Clones the committed HEAD of the checkout mounted at
4
+ # /repo, builds each guest with the host toolchain (no --docker), boots it
5
+ # through boot-test.exp, and checks that the builds leave git status clean.
6
+ set -euo pipefail
7
+
8
+ here=$(cd "$(dirname "$0")" && pwd)
9
+ guests=${GUESTS:-x86_64 aarch64}
10
+ kvm=no
11
+ if [ -r /dev/kvm ] && [ -w /dev/kvm ]; then kvm=yes; fi
12
+ echo "### host: $(uname -sm), node $(node --version), /dev/kvm: $kvm"
13
+
14
+ git config --global --add safe.directory '*'
15
+ git clone --quiet /repo /work
16
+ echo "### testing $(git -C /work log -1 --format='%h %s')"
17
+ # /cache is the host's downloads/, read-only; every file in it is still
18
+ # checked against its pinned SHA-256, and anything missing is fetched.
19
+ mkdir -p /work/downloads
20
+ cp -R /cache/. /work/downloads/
21
+ cd /work
22
+
23
+ strip_ansi() { sed 's/\x1b\[[0-9;?]*[a-zA-Z]//g' | tr -d '\r'; }
24
+
25
+ status=0
26
+ for guest in $guests; do
27
+ echo "### $guest: fetch + build ${BUILD_FLAGS:-}"
28
+ log=/tmp/build-$guest.log
29
+ # BUILD_FLAGS is split on purpose: it holds flags such as --linux-lts.
30
+ if node ./index.js -fb --arch "$guest" ${BUILD_FLAGS:-} > "$log" 2>&1; then
31
+ grep -E '^==>|^Fetched|^Built|^Packed|^note' "$log" || true
32
+ else
33
+ echo "### FAIL: $guest build; last lines:"
34
+ tail -n 30 "$log"
35
+ status=1
36
+ continue
37
+ fi
38
+
39
+ echo "### $guest: boot"
40
+ log=/tmp/boot-$guest.log
41
+ if expect "$here/boot-test.exp" /work "$guest" "${BOOT_TIMEOUT:-900}" > "$log" 2>&1; then
42
+ strip_ansi < "$log" | grep -a -E '^run-qemu.sh:|^network: eth0|^fetch example|^### ' || true
43
+ else
44
+ strip_ansi < "$log" | grep -a -E '^run-qemu.sh:|^### ok' || true
45
+ echo "### FAIL: $guest boot; last lines:"
46
+ strip_ansi < "$log" | tail -n 40
47
+ status=1
48
+ fi
49
+ done
50
+
51
+ echo "### git status after the builds (should be empty):"
52
+ if [ -n "$(git status --porcelain)" ]; then
53
+ git status --short
54
+ status=1
55
+ fi
56
+
57
+ if [ "$status" = 0 ]; then echo "### PASS"; else echo "### FAIL"; fi
58
+ exit "$status"
File without changes
File without changes