Rebrand to boco
CI / build (push) Successful in 13s

This commit is contained in:
2026-09-11 17:56:38 +02:00
parent 8782baa705
commit a24e1efe31
12 changed files with 142 additions and 142 deletions
+56 -56
View File
@@ -1,12 +1,12 @@
#!/bin/bash
# Test script for slim - boots containers and verifies CMD inference/override.
# Test script for boco - boots containers and verifies CMD inference/override.
# Requires: podman, qemu-system-x86_64, KVM, curl, and a kernel at
# $XDG_DATA_HOME/slim-rs/registry/vmlinuz.
# $XDG_DATA_HOME/boco/registry/vmlinuz.
set -u
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
TARGET_DIR="${CARGO_TARGET_DIR:-$SCRIPT_DIR/../target}"
SLIM_BIN="$TARGET_DIR/debug/slim"
BOCO_BIN="$TARGET_DIR/debug/boco"
TIMEOUT=120
pass=0
@@ -34,7 +34,7 @@ check_output() {
}
cleanup() {
"$SLIM_BIN" image rm "$1" >/dev/null 2>&1 || true
"$BOCO_BIN" image rm "$1" >/dev/null 2>&1 || true
podman image rm "$2" >/dev/null 2>&1 || true
}
@@ -54,10 +54,10 @@ FROM $from
$extra_setup
CMD ["/bin/sh", "-c", "echo CMD_INFERRED_OK; wget -q -O /dev/null http://1.1.1.1 2>/dev/null && echo CONN_OK; wget -q -O /dev/null http://example.org 2>/dev/null && echo DNS_OK; poweroff -f"]
EOF
img="slim-test-$distro-infer"
img="boco-test-$distro-infer"
if podman build -t "$img" -f "$work/Containerfile.infer" >/dev/null 2>&1; then
"$SLIM_BIN" build qcow2 "$img" >/dev/null 2>&1
output=$(timeout "$TIMEOUT" "$SLIM_BIN" run "$img" 2>&1 || true)
"$BOCO_BIN" build qcow2 "$img" >/dev/null 2>&1
output=$(timeout "$TIMEOUT" "$BOCO_BIN" boot "$img" 2>&1 || true)
check_output "$output" "CMD_INFERRED_OK" "$distro CMD-inferred"
check_output "$output" "CONN_OK" "$distro connect to 1.1.1.1"
check_output "$output" "DNS_OK" "$distro DNS lookup"
@@ -66,34 +66,34 @@ EOF
fi
cleanup "$img" "$img"
# === Test 2: slim run --cmd override ===
echo "-- Test 2: slim run --cmd override"
# === Test 2: boco boot --cmd override ===
echo "-- Test 2: boco boot --cmd override"
cat > "$work/Containerfile.run" <<EOF
FROM $from
$extra_setup
CMD ["/bin/sh", "-c", "echo SHOULD_NOT_APPEAR; poweroff -f"]
EOF
img="slim-test-$distro-run"
img="boco-test-$distro-run"
if podman build -t "$img" -f "$work/Containerfile.run" >/dev/null 2>&1; then
"$SLIM_BIN" build qcow2 "$img" >/dev/null 2>&1
output=$(timeout "$TIMEOUT" "$SLIM_BIN" run "$img" --cmd 'echo RUN_OVERRIDE_OK; poweroff -f' 2>&1 || true)
check_output "$output" "RUN_OVERRIDE_OK" "$distro run --cmd override"
"$BOCO_BIN" build qcow2 "$img" >/dev/null 2>&1
output=$(timeout "$TIMEOUT" "$BOCO_BIN" boot "$img" --cmd 'echo RUN_OVERRIDE_OK; poweroff -f' 2>&1 || true)
check_output "$output" "RUN_OVERRIDE_OK" "$distro boot --cmd override"
else
report fail "$distro run --cmd override (podman build failed)"
report fail "$distro boot --cmd override (podman build failed)"
fi
cleanup "$img" "$img"
# === Test 3: slim build --cmd override ===
echo "-- Test 3: slim build --cmd override"
# === Test 3: boco build --cmd override ===
echo "-- Test 3: boco build --cmd override"
cat > "$work/Containerfile.build" <<EOF
FROM $from
$extra_setup
CMD ["/bin/sh", "-c", "echo SHOULD_NOT_APPEAR; poweroff -f"]
EOF
img="slim-test-$distro-build"
img="boco-test-$distro-build"
if podman build -t "$img" -f "$work/Containerfile.build" >/dev/null 2>&1; then
"$SLIM_BIN" build qcow2 "$img" --cmd 'echo BUILD_OVERRIDE_OK; poweroff -f' >/dev/null 2>&1
output=$(timeout "$TIMEOUT" "$SLIM_BIN" run "$img" 2>&1 || true)
"$BOCO_BIN" build qcow2 "$img" --cmd 'echo BUILD_OVERRIDE_OK; poweroff -f' >/dev/null 2>&1
output=$(timeout "$TIMEOUT" "$BOCO_BIN" boot "$img" 2>&1 || true)
check_output "$output" "BUILD_OVERRIDE_OK" "$distro build --cmd override"
else
report fail "$distro build --cmd override (podman build failed)"
@@ -107,7 +107,7 @@ test_user() {
echo "=== Testing USER directive ==="
work="$(mktemp -d)"
img="slim-test-user"
img="boco-test-user"
cat > "$work/Containerfile" <<'EOF'
FROM alpine:latest
@@ -124,13 +124,13 @@ EOF
fi
echo "-- Test 1: build-time CMD runs as USER"
"$SLIM_BIN" build qcow2 "$img" >/dev/null 2>&1
output=$(timeout "$TIMEOUT" "$SLIM_BIN" run "$img" 2>&1 || true)
"$BOCO_BIN" build qcow2 "$img" >/dev/null 2>&1
output=$(timeout "$TIMEOUT" "$BOCO_BIN" boot "$img" 2>&1 || true)
check_output "$output" "USER_BUILD_OK:1500:testuser" "USER build-time CMD runs as testuser"
echo "-- Test 2: run --cmd override runs as USER"
output=$(timeout "$TIMEOUT" "$SLIM_BIN" run "$img" --cmd 'echo USER_RUN_OK:$(id -u):$(whoami); poweroff -f' 2>&1 || true)
check_output "$output" "USER_RUN_OK:1500:testuser" "USER run --cmd override runs as testuser"
echo "-- Test 2: boot --cmd override runs as USER"
output=$(timeout "$TIMEOUT" "$BOCO_BIN" boot "$img" --cmd 'echo USER_RUN_OK:$(id -u):$(whoami); poweroff -f' 2>&1 || true)
check_output "$output" "USER_RUN_OK:1500:testuser" "USER boot --cmd override runs as testuser"
cleanup "$img" "$img"
rm -rf "$work"
@@ -142,7 +142,7 @@ test_mount() {
work="$(mktemp -d)"
# --- Image 1: no WORKINGDIR, test host:guest and multi-mount ---
img="slim-test-mount"
img="boco-test-mount"
share_dir="$work/share"
share_dir2="$work/share2"
guest_dir="/mnt/guest"
@@ -164,9 +164,9 @@ EOF
return
fi
echo "-- Building slim VM..."
if ! "$SLIM_BIN" build qcow2 "$img" >/dev/null 2>&1; then
report fail "--mount (slim build failed)"
echo "-- Building boco VM..."
if ! "$BOCO_BIN" build qcow2 "$img" >/dev/null 2>&1; then
report fail "--mount (boco build failed)"
cleanup "$img" "$img"
rm -rf "$work"
return
@@ -176,14 +176,14 @@ EOF
share_canon2=$(readlink -f "$share_dir2")
echo "-- Test 1: --mount host:guest (absolute guest path, multi-mount)..."
output=$(timeout "$TIMEOUT" "$SLIM_BIN" run "$img" \
output=$(timeout "$TIMEOUT" "$BOCO_BIN" boot "$img" \
--mount "${share_dir}:${guest_dir}" \
--mount "${share_dir2}:${guest_dir2}" \
--cmd "for f in /sys/bus/virtio/drivers/9pnet_virtio/virtio*/mount_tag; do [ -f \"\$f\" ] && echo \"\$f: \$(tr -d '\\0' < \"\$f\")\"; done; mount -v; cat ${guest_dir}/testfile.txt 2>/dev/null || echo NO_FILE; cat ${guest_dir2}/testfile2.txt 2>/dev/null || echo NO_FILE2; echo MOUNT_VERIFY_DONE; poweroff -f" \
2>&1 || true)
check_output "$output" "mount_tag: slim0" "--mount 9p share detected"
check_output "$output" "mount_tag: slim1" "--mount second 9p share detected"
check_output "$output" "mount_tag: boco0" "--mount 9p share detected"
check_output "$output" "mount_tag: boco1" "--mount second 9p share detected"
check_output "$output" "type 9p" "--mount 9p filesystem in mount list"
check_output "$output" "hello from host" "--mount file accessible at guest path"
check_output "$output" "second share" "--mount second file accessible at guest path"
@@ -192,7 +192,7 @@ EOF
cleanup "$img" "$img"
# --- Image 2: with WORKINGDIR, test relative guest path ---
img="slim-test-mount-wd"
img="boco-test-mount-wd"
share_dir3="$work/share3"
mkdir -p "$share_dir3"
@@ -211,16 +211,16 @@ EOF
return
fi
echo "-- Building slim VM..."
if ! "$SLIM_BIN" build qcow2 "$img" >/dev/null 2>&1; then
report fail "--mount relative (slim build failed)"
echo "-- Building boco VM..."
if ! "$BOCO_BIN" build qcow2 "$img" >/dev/null 2>&1; then
report fail "--mount relative (boco build failed)"
cleanup "$img" "$img"
rm -rf "$work"
return
fi
echo "-- Test 2: --mount host:relative-guest (resolved against WORKINGDIR)..."
output=$(timeout "$TIMEOUT" "$SLIM_BIN" run "$img" \
output=$(timeout "$TIMEOUT" "$BOCO_BIN" boot "$img" \
--mount "${share_dir3}:data" \
--cmd "mount -v; cat /app/data/relfile.txt 2>/dev/null || echo NO_REL_FILE; echo REL_VERIFY_DONE; poweroff -f" \
2>&1 || true)
@@ -236,7 +236,7 @@ EOF
test_service() {
echo "=== Testing nextcloud service ==="
img="slim-test-nextcloud"
img="boco-test-nextcloud"
host_port=18080
work="$(mktemp -d)"
@@ -252,16 +252,16 @@ EOF
return
fi
echo "-- Building slim VM..."
if ! "$SLIM_BIN" build qcow2 "$img" >/dev/null 2>&1; then
report fail "nextcloud service (slim build failed)"
echo "-- Building boco VM..."
if ! "$BOCO_BIN" build qcow2 "$img" >/dev/null 2>&1; then
report fail "nextcloud service (boco build failed)"
cleanup "$img" "$img"
rm -rf "$work"
return
fi
echo "-- Booting VM with port forward (host :${host_port} -> guest :80)..."
setsid timeout 300 "$SLIM_BIN" run "$img" \
setsid timeout 300 "$BOCO_BIN" boot "$img" \
--forward "tcp:0.0.0.0:${host_port}-:80" \
--memory 2048M >/dev/null 2>&1 &
vm_pid=$!
@@ -299,11 +299,11 @@ test_systemd() {
echo "=== Testing systemd as init ==="
work="$(mktemp -d)"
img="slim-test-systemd"
img="boco-test-systemd"
cat > "$work/slim-test.service" <<'SVC'
cat > "$work/boco-test.service" <<'SVC'
[Unit]
Description=slim systemd test
Description=boco systemd test
After=multi-user.target
[Service]
@@ -316,10 +316,10 @@ SVC
cat > "$work/Containerfile" <<EOF
FROM archlinux:latest
COPY slim-test.service /etc/systemd/system/slim-test.service
COPY boco-test.service /etc/systemd/system/boco-test.service
RUN mkdir -p /etc/systemd/system/multi-user.target.wants && \
ln -sf /etc/systemd/system/slim-test.service \
/etc/systemd/system/multi-user.target.wants/slim-test.service
ln -sf /etc/systemd/system/boco-test.service \
/etc/systemd/system/multi-user.target.wants/boco-test.service
CMD ["/sbin/init"]
EOF
@@ -330,16 +330,16 @@ EOF
return
fi
echo "-- Building slim VM..."
if ! "$SLIM_BIN" build qcow2 "$img" >/dev/null 2>&1; then
report fail "systemd as init (slim build failed)"
echo "-- Building boco VM..."
if ! "$BOCO_BIN" build qcow2 "$img" >/dev/null 2>&1; then
report fail "systemd as init (boco build failed)"
cleanup "$img" "$img"
rm -rf "$work"
return
fi
echo "-- Booting VM (systemd as PID 1)..."
output=$(timeout "$TIMEOUT" "$SLIM_BIN" run "$img" 2>&1 || true)
output=$(timeout "$TIMEOUT" "$BOCO_BIN" boot "$img" 2>&1 || true)
check_output "$output" "SYSTEMD_TEST_OK" "systemd boots and runs service"
check_output "$output" "reboot: Power down" "systemd shuts down cleanly"
@@ -347,11 +347,11 @@ EOF
rm -rf "$work"
}
echo "Building slim..."
echo "Building boco..."
cargo build 2>&1
cargo build --release -p slim-init --target x86_64-unknown-linux-musl 2>&1
cp target/x86_64-unknown-linux-musl/release/slim-init \
"${XDG_DATA_HOME:-$HOME/.local/share}/slim-rs/slim-init"
cargo build --release -p boco-init --target x86_64-unknown-linux-musl 2>&1
cp "$TARGET_DIR/x86_64-unknown-linux-musl/release/boco-init" \
"${XDG_DATA_HOME:-$HOME/.local/share}/boco/boco-init"
test_distro "alpine" "alpine:latest" ""
test_distro "archlinux" "archlinux:latest" "RUN pacman -Sy --noconfirm iproute2 wget; pacman -Sc --noconfirm"