summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authortranch <tranch.xiao@gmail.com>2026-08-26 10:41:01 +0800
committertranch <tranch.xiao@gmail.com>2026-08-26 10:41:01 +0800
commit6cb356d3837ef5a9637c2f6df1de7ef85196c280 (patch)
tree2c4cb3d437f311e3f0256540af735709a77e5990 /tests
parent0a25c4e957f98df15c5e914fd647c3cd6de54456 (diff)
downloadAeroCore-OS-6cb356d3837ef5a9637c2f6df1de7ef85196c280.tar.gz
AeroCore-OS-6cb356d3837ef5a9637c2f6df1de7ef85196c280.zip
fix(installer): configure the GPT auto-root type
Resolve Anaconda target mounts to their backing partition before marking it as the bootc GPT auto-root partition.
Diffstat (limited to 'tests')
-rwxr-xr-xtests/test-configure-target-gpt-root.sh51
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/test-configure-target-gpt-root.sh b/tests/test-configure-target-gpt-root.sh
new file mode 100755
index 0000000..ed5e33e
--- /dev/null
+++ b/tests/test-configure-target-gpt-root.sh
@@ -0,0 +1,51 @@
+#!/usr/bin/env bash
+
+set -euo pipefail
+
+project_root="$(git rev-parse --show-toplevel)"
+tmp_dir="$(mktemp -d)"
+trap 'rm -rf "${tmp_dir}"' EXIT
+mkdir -p "${tmp_dir}/bin"
+
+# shellcheck disable=SC2016 # The generated fixture expands this in its own process.
+printf '%s\n' \
+ '#!/usr/bin/env bash' \
+ 'if [[ " $* " == *" -no SOURCE "* ]]; then' \
+ ' [[ " $* " == *" --nofsroot "* ]] || exit 97' \
+ ' printf "%s\\n" "${TEST_FINDMNT_SOURCE:?}"' \
+ 'else' \
+ " printf '252:3\\n'" \
+ 'fi' > "${tmp_dir}/bin/findmnt"
+
+printf '%s\n' \
+ '#!/usr/bin/env bash' \
+ 'case " $* " in' \
+ " *\" PKNAME \"*) printf 'vda\\n' ;;" \
+ " *\" PARTN \"*) printf '3\\n' ;;" \
+ " *\" PARTNUM \"*) exit 98 ;;" \
+ " *) printf '/dev/vda3 252:3\\n' ;;" \
+ 'esac' > "${tmp_dir}/bin/lsblk"
+
+# shellcheck disable=SC2016 # The generated fixture expands TEST_OUTPUT itself.
+printf '%s\n' \
+ '#!/usr/bin/env bash' \
+ 'printf "%s\\n" "$*" > "${TEST_OUTPUT:?}"' > "${tmp_dir}/bin/sgdisk"
+
+printf '%s\n' '#!/usr/bin/env bash' 'exit 0' > "${tmp_dir}/bin/partprobe"
+
+chmod +x "${tmp_dir}/bin/"*
+
+run_fixture() {
+ local findmnt_source=$1
+
+ TEST_FINDMNT_SOURCE="${findmnt_source}" TEST_OUTPUT="${tmp_dir}/sgdisk.args" \
+ PATH="${tmp_dir}/bin:${PATH}" \
+ bash "${project_root}/installer/configure-target-gpt-root.sh" /mnt/sysroot
+
+ grep -qx -- '--typecode=3:4f68bce3-e8cd-4db1-96e7-fbcaf984b709 /dev/vda' \
+ "${tmp_dir}/sgdisk.args"
+}
+
+run_fixture root
+run_fixture '/dev/vda3[/root]'
+printf 'GPT root bind-mount and Btrfs subvolume fixtures passed\n'