Boot Fruix from distinct FreeBSD source revisions
This commit is contained in:
194
tests/system/run-phase17-source-revisions-qemu.sh
Executable file
194
tests/system/run-phase17-source-revisions-qemu.sh
Executable file
@@ -0,0 +1,194 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
repo_root=${PROJECT_ROOT:-$(pwd)}
|
||||
script_dir=$(CDPATH= cd -- "$(dirname "$0")" && pwd)
|
||||
git_template=${GIT_TEMPLATE:-$script_dir/phase17-git-source-operating-system.scm.in}
|
||||
txz_template=${TXZ_TEMPLATE:-$script_dir/phase17-txz-source-operating-system.scm.in}
|
||||
system_name=${SYSTEM_NAME:-phase17-operating-system}
|
||||
disk_capacity=${DISK_CAPACITY:-12g}
|
||||
root_size=${ROOT_SIZE:-10g}
|
||||
base_name=${BASE_NAME:-source-side-by-side}
|
||||
base_version_label=${BASE_VERSION_LABEL:-15.0-source-side-by-side}
|
||||
git_base_release=${GIT_BASE_RELEASE:-15.0-STABLE}
|
||||
git_base_branch=${GIT_BASE_BRANCH:-stable/15}
|
||||
git_source_name=${GIT_SOURCE_NAME:-stable15-side-a}
|
||||
git_source_ref=${GIT_SOURCE_REF:-stable/15}
|
||||
git_source_commit=${GIT_SOURCE_COMMIT:-332708a606f6bf0841c1d4a74c0d067f5640fe89}
|
||||
git_declared_source_root=${GIT_DECLARED_SOURCE_ROOT:-/var/empty/fruix-unused-source-root-git}
|
||||
txz_base_release=${TXZ_BASE_RELEASE:-15.0-RELEASE}
|
||||
txz_base_branch=${TXZ_BASE_BRANCH:-releng/15.0}
|
||||
txz_source_name=${TXZ_SOURCE_NAME:-release15-side-b}
|
||||
txz_source_url=${TXZ_SOURCE_URL:-https://download.freebsd.org/releases/amd64/15.0-RELEASE/src.txz}
|
||||
txz_source_sha256=${TXZ_SOURCE_SHA256:-83c3e8157b6d7afcae57167fda75693bf1e5f581ca149a6ecb2d398b71bdfab0}
|
||||
txz_declared_source_root=${TXZ_DECLARED_SOURCE_ROOT:-/var/empty/fruix-unused-source-root-txz}
|
||||
metadata_target=${METADATA_OUT:-}
|
||||
cleanup=0
|
||||
|
||||
if [ -n "${WORKDIR:-}" ]; then
|
||||
workdir=$WORKDIR
|
||||
mkdir -p "$workdir"
|
||||
else
|
||||
workdir=$(mktemp -d /tmp/fruix-phase17-source-qemu.XXXXXX)
|
||||
cleanup=1
|
||||
fi
|
||||
if [ "${KEEP_WORKDIR:-0}" -eq 1 ]; then
|
||||
cleanup=0
|
||||
fi
|
||||
|
||||
metadata_file=$workdir/phase17-source-revisions-qemu-metadata.txt
|
||||
git_rendered_template=$workdir/git-template.scm.in
|
||||
txz_rendered_template=$workdir/txz-template.scm.in
|
||||
|
||||
tidy() {
|
||||
if [ "$cleanup" -eq 1 ]; then
|
||||
rm -rf "$workdir" 2>/dev/null || sudo rm -rf "$workdir"
|
||||
fi
|
||||
}
|
||||
trap tidy EXIT INT TERM
|
||||
|
||||
[ -f "$git_template" ] || { echo "missing git template: $git_template" >&2; exit 1; }
|
||||
[ -f "$txz_template" ] || { echo "missing txz template: $txz_template" >&2; exit 1; }
|
||||
|
||||
sed \
|
||||
-e "s|__BASE_NAME__|$base_name|g" \
|
||||
-e "s|__BASE_VERSION_LABEL__|$base_version_label|g" \
|
||||
-e "s|__BASE_RELEASE__|$git_base_release|g" \
|
||||
-e "s|__BASE_BRANCH__|$git_base_branch|g" \
|
||||
-e "s|__SOURCE_NAME__|$git_source_name|g" \
|
||||
-e "s|__SOURCE_REF__|$git_source_ref|g" \
|
||||
-e "s|__SOURCE_COMMIT__|$git_source_commit|g" \
|
||||
-e "s|__DECLARED_SOURCE_ROOT__|$git_declared_source_root|g" \
|
||||
"$git_template" > "$git_rendered_template"
|
||||
|
||||
sed \
|
||||
-e "s|__BASE_NAME__|$base_name|g" \
|
||||
-e "s|__BASE_VERSION_LABEL__|$base_version_label|g" \
|
||||
-e "s|__BASE_RELEASE__|$txz_base_release|g" \
|
||||
-e "s|__BASE_BRANCH__|$txz_base_branch|g" \
|
||||
-e "s|__SOURCE_NAME__|$txz_source_name|g" \
|
||||
-e "s|__SOURCE_URL__|$txz_source_url|g" \
|
||||
-e "s|__SOURCE_SHA256__|$txz_source_sha256|g" \
|
||||
-e "s|__DECLARED_SOURCE_ROOT__|$txz_declared_source_root|g" \
|
||||
"$txz_template" > "$txz_rendered_template"
|
||||
|
||||
run_boot() {
|
||||
name=$1
|
||||
template=$2
|
||||
metadata_out=$3
|
||||
qemu_port=$4
|
||||
KEEP_WORKDIR=1 WORKDIR="$workdir/$name" METADATA_OUT="$metadata_out" \
|
||||
OS_TEMPLATE="$template" SYSTEM_NAME="$system_name" DISK_CAPACITY="$disk_capacity" ROOT_SIZE="$root_size" \
|
||||
QEMU_SSH_PORT="$qemu_port" "$repo_root/tests/system/run-phase11-shepherd-pid1-qemu.sh" >/dev/null
|
||||
}
|
||||
|
||||
git_metadata=$workdir/git-metadata.txt
|
||||
txz_metadata=$workdir/txz-metadata.txt
|
||||
run_boot git "$git_rendered_template" "$git_metadata" 10022
|
||||
run_boot txz "$txz_rendered_template" "$txz_metadata" 10023
|
||||
|
||||
field() {
|
||||
key=$1
|
||||
file=$2
|
||||
sed -n "s/^$key=//p" "$file" | tail -n 1
|
||||
}
|
||||
|
||||
git_phase8=$(field phase8_metadata "$git_metadata")
|
||||
txz_phase8=$(field phase8_metadata "$txz_metadata")
|
||||
|
||||
[ -f "$git_phase8" ] || { echo "missing git phase8 metadata: $git_phase8" >&2; exit 1; }
|
||||
[ -f "$txz_phase8" ] || { echo "missing txz phase8 metadata: $txz_phase8" >&2; exit 1; }
|
||||
|
||||
git_phase8_build=$(field build_metadata "$git_phase8")
|
||||
txz_phase8_build=$(field build_metadata "$txz_phase8")
|
||||
[ -f "$git_phase8_build" ] || { echo "missing git phase8 build metadata: $git_phase8_build" >&2; exit 1; }
|
||||
[ -f "$txz_phase8_build" ] || { echo "missing txz phase8 build metadata: $txz_phase8_build" >&2; exit 1; }
|
||||
|
||||
git_closure=$(field closure_path "$git_metadata")
|
||||
txz_closure=$(field closure_path "$txz_metadata")
|
||||
git_shepherd_pid=$(field shepherd_pid "$git_metadata")
|
||||
txz_shepherd_pid=$(field shepherd_pid "$txz_metadata")
|
||||
git_sshd=$(field sshd_status "$git_metadata")
|
||||
txz_sshd=$(field sshd_status "$txz_metadata")
|
||||
git_serial_log=$(field serial_log "$git_metadata")
|
||||
txz_serial_log=$(field serial_log "$txz_metadata")
|
||||
|
||||
git_source_kind=$(field freebsd_source_kind "$git_phase8_build")
|
||||
txz_source_kind=$(field freebsd_source_kind "$txz_phase8_build")
|
||||
git_source_ref_out=$(field freebsd_source_ref "$git_phase8_build")
|
||||
git_source_commit_out=$(field freebsd_source_commit "$git_phase8_build")
|
||||
txz_source_url_out=$(field freebsd_source_url "$txz_phase8_build")
|
||||
txz_source_sha256_out=$(field freebsd_source_sha256 "$txz_phase8_build")
|
||||
git_materialized_count=$(field materialized_source_store_count "$git_phase8_build")
|
||||
txz_materialized_count=$(field materialized_source_store_count "$txz_phase8_build")
|
||||
git_materialized_store=$(field materialized_source_stores "$git_phase8_build")
|
||||
txz_materialized_store=$(field materialized_source_stores "$txz_phase8_build")
|
||||
git_native_stores=$(field native_base_stores "$git_phase8_build")
|
||||
txz_native_stores=$(field native_base_stores "$txz_phase8_build")
|
||||
|
||||
[ "$git_shepherd_pid" = 1 ] || { echo "git boot did not run Shepherd as PID 1" >&2; exit 1; }
|
||||
[ "$txz_shepherd_pid" = 1 ] || { echo "txz boot did not run Shepherd as PID 1" >&2; exit 1; }
|
||||
[ "$git_sshd" = running ] || { echo "git boot does not have sshd running" >&2; exit 1; }
|
||||
[ "$txz_sshd" = running ] || { echo "txz boot does not have sshd running" >&2; exit 1; }
|
||||
[ "$git_closure" != "$txz_closure" ] || { echo "git and txz boot closures unexpectedly match" >&2; exit 1; }
|
||||
[ "$git_source_kind" = git ] || { echo "unexpected git boot source kind: $git_source_kind" >&2; exit 1; }
|
||||
[ "$txz_source_kind" = src-txz ] || { echo "unexpected txz boot source kind: $txz_source_kind" >&2; exit 1; }
|
||||
[ "$git_source_ref_out" = "$git_source_ref" ] || { echo "unexpected git boot source ref: $git_source_ref_out" >&2; exit 1; }
|
||||
[ "$git_source_commit_out" = "$git_source_commit" ] || { echo "unexpected git boot source commit: $git_source_commit_out" >&2; exit 1; }
|
||||
[ "$txz_source_url_out" = "$txz_source_url" ] || { echo "unexpected txz boot source URL: $txz_source_url_out" >&2; exit 1; }
|
||||
[ "$txz_source_sha256_out" = "$txz_source_sha256" ] || { echo "unexpected txz boot source sha256: $txz_source_sha256_out" >&2; exit 1; }
|
||||
[ "$git_materialized_count" = 1 ] || { echo "unexpected git materialized source count: $git_materialized_count" >&2; exit 1; }
|
||||
[ "$txz_materialized_count" = 1 ] || { echo "unexpected txz materialized source count: $txz_materialized_count" >&2; exit 1; }
|
||||
[ "$git_materialized_store" != "$txz_materialized_store" ] || { echo "git and txz materialized source stores unexpectedly match" >&2; exit 1; }
|
||||
[ "$git_native_stores" != "$txz_native_stores" ] || { echo "git and txz native base stores unexpectedly match" >&2; exit 1; }
|
||||
|
||||
case "$git_materialized_store" in
|
||||
/frx/store/*-freebsd-source-$git_source_name) : ;;
|
||||
*) echo "unexpected git materialized source store: $git_materialized_store" >&2; exit 1 ;;
|
||||
esac
|
||||
case "$txz_materialized_store" in
|
||||
/frx/store/*-freebsd-source-$txz_source_name) : ;;
|
||||
*) echo "unexpected txz materialized source store: $txz_materialized_store" >&2; exit 1 ;;
|
||||
esac
|
||||
|
||||
cat >"$metadata_file" <<EOF
|
||||
workdir=$workdir
|
||||
git_metadata=$git_metadata
|
||||
txz_metadata=$txz_metadata
|
||||
git_phase8_metadata=$git_phase8
|
||||
txz_phase8_metadata=$txz_phase8
|
||||
git_phase8_build_metadata=$git_phase8_build
|
||||
txz_phase8_build_metadata=$txz_phase8_build
|
||||
git_closure=$git_closure
|
||||
txz_closure=$txz_closure
|
||||
git_source_kind=$git_source_kind
|
||||
git_source_ref=$git_source_ref_out
|
||||
git_source_commit=$git_source_commit_out
|
||||
git_materialized_source_store=$git_materialized_store
|
||||
git_native_base_stores=$git_native_stores
|
||||
git_serial_log=$git_serial_log
|
||||
txz_source_kind=$txz_source_kind
|
||||
txz_source_url=$txz_source_url_out
|
||||
txz_source_sha256=$txz_source_sha256_out
|
||||
txz_materialized_source_store=$txz_materialized_store
|
||||
txz_native_base_stores=$txz_native_stores
|
||||
txz_serial_log=$txz_serial_log
|
||||
disk_capacity=$disk_capacity
|
||||
root_size=$root_size
|
||||
boot_backend=qemu-uefi-tcg
|
||||
source_revision_boots=ok
|
||||
EOF
|
||||
|
||||
if [ -n "$metadata_target" ]; then
|
||||
mkdir -p "$(dirname "$metadata_target")"
|
||||
cp "$metadata_file" "$metadata_target"
|
||||
fi
|
||||
|
||||
printf 'PASS phase17-source-revisions-qemu\n'
|
||||
printf 'Work directory: %s\n' "$workdir"
|
||||
printf 'Metadata file: %s\n' "$metadata_file"
|
||||
if [ -n "$metadata_target" ]; then
|
||||
printf 'Copied metadata to: %s\n' "$metadata_target"
|
||||
fi
|
||||
printf '%s\n' '--- metadata ---'
|
||||
cat "$metadata_file"
|
||||
Reference in New Issue
Block a user