Initial public import of the proven Bash installer (installer/) and the production Rust workspace (installer-rs/). The reference ISO, build output and local agent transcripts are gitignored. Verified: installer/tests/run_tests.sh and cargo test --workspace both pass.
57 lines
1.8 KiB
Bash
57 lines
1.8 KiB
Bash
#!/usr/bin/env bash
|
|
# shellcheck shell=bash
|
|
#
|
|
# Regression test: subvolumes must be created before any subvol=@ mount is
|
|
# attempted. The first VM install failed because the layout was mounted before
|
|
# the subvolumes existed (mount exit 32).
|
|
source "$(dirname "${BASH_SOURCE[0]}")/lib.sh"
|
|
TEST_NAME="test_btrfs_order"
|
|
phoebus_test_setup
|
|
source "$PHOEBUS_ROOT/lib/confirm.sh"
|
|
|
|
# Authorize destructive pseudo-commands for the fake environment.
|
|
PHOEBUS_DESTRUCTIVE_AUTHORIZED="yes"
|
|
config_set DRY_RUN "no"
|
|
|
|
fakebin="$STATE_DIR/bin"
|
|
mkdir -p "$fakebin"
|
|
export FAKE_LOG="$STATE_DIR/calls.log"
|
|
: >"$FAKE_LOG"
|
|
|
|
cat >"$fakebin/mount" <<'EOF'
|
|
#!/usr/bin/env bash
|
|
printf 'mount %s\n' "$*" >>"$FAKE_LOG"
|
|
exit 0
|
|
EOF
|
|
cat >"$fakebin/umount" <<'EOF'
|
|
#!/usr/bin/env bash
|
|
printf 'umount %s\n' "$*" >>"$FAKE_LOG"
|
|
exit 0
|
|
EOF
|
|
cat >"$fakebin/btrfs" <<'EOF'
|
|
#!/usr/bin/env bash
|
|
printf 'btrfs %s\n' "$*" >>"$FAKE_LOG"
|
|
exit 0
|
|
EOF
|
|
chmod +x "$fakebin/mount" "$fakebin/umount" "$fakebin/btrfs"
|
|
PATH="$fakebin:$PATH"
|
|
|
|
config_set BTRFS_SUBVOLS "@ @home @var @snapshots @swap"
|
|
btrfs_create_layout /dev/fake "$STATE_DIR/root" >/dev/null 2>&1
|
|
rc=$?
|
|
|
|
assert_eq "0" "$rc" "btrfs_create_layout succeeds with fake tools"
|
|
|
|
# The first subvolume creation must precede the first subvol=@ mount.
|
|
create_line="$(grep -n 'btrfs subvolume create' "$FAKE_LOG" | head -n1 | cut -d: -f1)"
|
|
mount_line="$(grep -n 'subvol=@ ' "$FAKE_LOG" | head -n1 | cut -d: -f1)"
|
|
assert_success "subvolume create recorded" test -n "$create_line"
|
|
assert_success "subvol=@ mount recorded" test -n "$mount_line"
|
|
if [[ -n "$create_line" && -n "$mount_line" ]]; then
|
|
assert_success "subvolumes created before mounting @" test "$create_line" -lt "$mount_line"
|
|
fi
|
|
|
|
# All five subvolumes are created.
|
|
assert_eq "5" "$(grep -c 'btrfs subvolume create' "$FAKE_LOG")" "all subvolumes created"
|
|
|
|
phoebus_test_report
|