Skip to content

Commit 7c9a3e8

Browse files
committed
ci(test-convert): replace fixed 4-case matrix with 3-dimensional 12-case matrix
Replace the single `case` matrix dimension (uki-encrypted/uki-noenc/grub-encrypted/grub-noenc) with three independent dimensions: bootloader (uki|grub), rootfs_enc (enc|noenc), and delta_location (ram|disk|disk-persist), yielding 2×2×3=12 parallel test jobs. Update test-convert.sh to accept --bootloader, --rootfs-enc/--rootfs-noenc, and --delta-location flags instead of --case/--all. The delta_location value is now propagated into fde.toml rather than being hardcoded as "disk". Remove the now-redundant run-convert-test Makefile target; run-convert-test-case is updated to use BOOTLOADER, ROOTFS_ENC, and DELTA_LOCATION variables.
1 parent 4a78a04 commit 7c9a3e8

3 files changed

Lines changed: 71 additions & 74 deletions

File tree

.github/workflows/build-rpm.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,14 @@ jobs:
181181
cryptpilot-crypt --version
182182
cryptpilot-verity --version
183183
184-
# Integration tests for cryptpilot-convert (4 parallel jobs via matrix)
184+
# Integration tests for cryptpilot-convert (12 parallel jobs via matrix)
185185
test-convert:
186186
strategy:
187187
fail-fast: false
188188
matrix:
189-
case: [uki-encrypted, uki-noenc, grub-encrypted, grub-noenc]
189+
bootloader: [uki, grub]
190+
rootfs_enc: [enc, noenc]
191+
delta_location: [ram, disk, disk-persist]
190192
runs-on: ubuntu-latest
191193
needs: build
192194
env:
@@ -272,7 +274,7 @@ jobs:
272274
- name: Run convert test
273275
run: |
274276
docker exec -w /workspace/repo test-container bash -c "
275-
make run-convert-test-case CASE=${{ matrix.case }} INPUT_IMAGE=/workspace/test-images/test-image.qcow2 CRYPTPILOT_FDE_RPM=${{ steps.install-rpm.outputs.cryptpilot_fde_rpm_container }}
277+
make run-convert-test-case BOOTLOADER=${{ matrix.bootloader }} ROOTFS_ENC=${{ matrix.rootfs_enc }} DELTA_LOCATION=${{ matrix.delta_location }} INPUT_IMAGE=/workspace/test-images/test-image.qcow2 CRYPTPILOT_FDE_RPM=${{ steps.install-rpm.outputs.cryptpilot_fde_rpm_container }}
276278
"
277279
278280
- name: Cleanup

Makefile

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,13 +160,9 @@ install-convert-test-depend:
160160
yum install -y wget qemu-img cryptsetup lvm2 parted e2fsprogs util-linux libguestfs-tools-c
161161
which docker || { yum install -y docker ; }
162162

163-
.PHONY: run-convert-test
164-
run-convert-test: install-convert-test-depend
165-
bash tests/test-convert.sh --rpm $(CRYPTPILOT_FDE_RPM) --all $(if $(INPUT_IMAGE),--input $(INPUT_IMAGE),)
166-
167163
.PHONY: run-convert-test-case
168164
run-convert-test-case: install-convert-test-depend
169-
bash tests/test-convert.sh --rpm $(CRYPTPILOT_FDE_RPM) $(if $(CASE),--case $(CASE),--all) $(if $(INPUT_IMAGE),--input $(INPUT_IMAGE),)
165+
bash tests/test-convert.sh --rpm $(CRYPTPILOT_FDE_RPM) --bootloader $(BOOTLOADER) --rootfs-$(ROOTFS_ENC) --delta-location $(DELTA_LOCATION) $(if $(INPUT_IMAGE),--input $(INPUT_IMAGE),)
170166

171167
.PHONE: shellcheck
172168
shellcheck:

tests/test-convert.sh

Lines changed: 65 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,15 @@
22
#
33
# Integration tests for cryptpilot-convert
44
#
5-
# This script tests the cryptpilot-convert tool's disk conversion capability
6-
# with 4 test combinations:
7-
# - uki-encrypted: UKI mode with rootfs encryption
8-
# - uki-noenc: UKI mode without rootfs encryption
9-
# - grub-encrypted: GRUB mode with rootfs encryption
10-
# - grub-noenc: GRUB mode without rootfs encryption
5+
# This script tests the cryptpilot-convert tool's disk conversion capability.
6+
# A single test run is defined by three independent dimensions:
7+
# --bootloader uki | grub
8+
# --rootfs-enc (flag) rootfs encryption enabled
9+
# --rootfs-noenc (flag) rootfs encryption disabled
10+
# --delta-location ram | disk | disk-persist
1111
#
1212
# Usage:
13-
# ./tests/test-convert.sh --case <case-name> # Run specific test case
14-
# ./tests/test-convert.sh --all # Run all 4 test cases
13+
# ./tests/test-convert.sh --rpm <path> --bootloader <uki|grub> --rootfs-enc|--rootfs-noenc --delta-location <ram|disk|disk-persist>
1514
# ./tests/test-convert.sh --help # Show usage
1615
#
1716

@@ -255,14 +254,15 @@ download_test_image() {
255254
create_test_config() {
256255
local config_dir="$1"
257256
local use_encryption="$2"
257+
local delta_location="$3"
258258
mkdir -p "${config_dir}"
259259

260260
# Create fde.toml with OTP provider (simplest, no external dependencies)
261261
if [[ "${use_encryption}" == "true" ]]; then
262262
cat > "${config_dir}/fde.toml" <<EOF
263263
# Test configuration for cryptpilot-convert integration tests
264264
[rootfs]
265-
delta_location = "disk"
265+
delta_location = "${delta_location}"
266266
267267
[rootfs.encrypt.exec]
268268
command = "echo"
@@ -274,10 +274,10 @@ integrity = false
274274
[delta.encrypt.otp]
275275
EOF
276276
else
277-
cat > "${config_dir}/fde.toml" <<'EOF'
277+
cat > "${config_dir}/fde.toml" <<EOF
278278
# Test configuration for cryptpilot-convert integration tests (no encryption)
279279
[rootfs]
280-
delta_location = "disk"
280+
delta_location = "${delta_location}"
281281
282282
[delta]
283283
integrity = false
@@ -589,11 +589,13 @@ run_test_case() {
589589
local test_name="$1"
590590
local use_uki="$2"
591591
local use_encryption="$3"
592+
local delta_location="$4"
592593

593594
log::step "=========================================="
594595
log::step "Running test case: ${test_name}"
595596
log::step " UKI mode: ${use_uki}"
596597
log::step " Encryption: ${use_encryption}"
598+
log::step " Delta location: ${delta_location}"
597599
log::step "=========================================="
598600

599601
local test_workdir="${WORKDIR}/${test_name}"
@@ -612,7 +614,7 @@ run_test_case() {
612614
fi
613615

614616
# Create test configuration
615-
create_test_config "${config_dir}" "${use_encryption}"
617+
create_test_config "${config_dir}" "${use_encryption}" "${delta_location}"
616618

617619
# Run enhancement (hardens the image before conversion)
618620
if ! run_enhance "${test_name}" "${input_image}"; then
@@ -654,33 +656,31 @@ run_test_case() {
654656

655657
show_help() {
656658
cat <<EOF
657-
Usage: $(basename "$0") --rpm <path> [OPTIONS]
659+
Usage: $(basename "$0") --rpm <path> --bootloader <uki|grub> --rootfs-enc|--rootfs-noenc --delta-location <ram|disk|disk-persist> [OPTIONS]
658660
659661
Integration tests for cryptpilot-convert
660662
661663
Required:
662-
--rpm <path> Path to cryptpilot-fde RPM package
664+
--rpm <path> Path to cryptpilot-fde RPM package
665+
--bootloader <uki|grub> Boot mode
666+
--rootfs-enc Enable rootfs encryption
667+
--rootfs-noenc Disable rootfs encryption
668+
--delta-location <value> Delta partition location: ram | disk | disk-persist
663669
664670
Options:
665-
--case <name> Run a specific test case. Valid cases:
666-
uki-encrypted - UKI mode with rootfs encryption
667-
uki-noenc - UKI mode without rootfs encryption
668-
grub-encrypted - GRUB mode with rootfs encryption
669-
grub-noenc - GRUB mode without rootfs encryption
670-
--all Run all 4 test cases
671671
--input <path> Use specified qcow2 image instead of downloading
672672
--help Show this help message
673673
674674
Examples:
675-
$(basename "$0") --rpm ./cryptpilot-fde-*.rpm --case uki-encrypted
676-
$(basename "$0") --rpm ./cryptpilot-fde-*.rpm --all
677-
$(basename "$0") --rpm ./cryptpilot-fde-*.rpm --case grub-noenc --input /path/to/image.qcow2
675+
$(basename "$0") --rpm ./cryptpilot-fde-*.rpm --bootloader uki --rootfs-enc --delta-location ram
676+
$(basename "$0") --rpm ./cryptpilot-fde-*.rpm --bootloader grub --rootfs-noenc --delta-location disk --input /path/to/image.qcow2
678677
EOF
679678
}
680679

681680
main() {
682-
local test_case=""
683-
local run_all=false
681+
local bootloader=""
682+
local rootfs_enc=""
683+
local delta_location=""
684684
local custom_input=""
685685

686686
# Parse arguments
@@ -690,14 +690,22 @@ main() {
690690
CRYPTPILOT_FDE_RPM="$2"
691691
shift 2
692692
;;
693-
--case)
694-
test_case="$2"
693+
--bootloader)
694+
bootloader="$2"
695695
shift 2
696696
;;
697-
--all)
698-
run_all=true
697+
--rootfs-enc)
698+
rootfs_enc="enc"
699+
shift
700+
;;
701+
--rootfs-noenc)
702+
rootfs_enc="noenc"
699703
shift
700704
;;
705+
--delta-location)
706+
delta_location="$2"
707+
shift 2
708+
;;
701709
--input)
702710
custom_input="$2"
703711
shift 2
@@ -722,6 +730,24 @@ main() {
722730
fi
723731
log::info "Using cryptpilot-fde RPM: ${CRYPTPILOT_FDE_RPM}"
724732

733+
# Validate --bootloader
734+
if [[ "${bootloader}" != "uki" && "${bootloader}" != "grub" ]]; then
735+
show_help
736+
fatal "Invalid or missing --bootloader: must be 'uki' or 'grub'"
737+
fi
738+
739+
# Validate --rootfs-enc / --rootfs-noenc
740+
if [[ -z "${rootfs_enc}" ]]; then
741+
show_help
742+
fatal "Must specify --rootfs-enc or --rootfs-noenc"
743+
fi
744+
745+
# Validate --delta-location
746+
if [[ "${delta_location}" != "ram" && "${delta_location}" != "disk" && "${delta_location}" != "disk-persist" ]]; then
747+
show_help
748+
fatal "Invalid or missing --delta-location: must be 'ram', 'disk', or 'disk-persist'"
749+
fi
750+
725751
# Validate custom input if provided
726752
if [[ -n "${custom_input}" ]]; then
727753
if [[ ! -f "${custom_input}" ]]; then
@@ -730,21 +756,12 @@ main() {
730756
log::info "Using custom input image: ${custom_input}"
731757
fi
732758

733-
# Validate arguments
734-
if [[ -z "${test_case}" ]] && [[ "${run_all}" == "false" ]]; then
735-
show_help
736-
fatal "Must specify --case <name> or --all"
737-
fi
738-
739-
if [[ -n "${test_case}" ]]; then
740-
case "${test_case}" in
741-
uki-encrypted|uki-noenc|grub-encrypted|grub-noenc)
742-
;;
743-
*)
744-
fatal "Invalid test case: ${test_case}. Valid cases: uki-encrypted, uki-noenc, grub-encrypted, grub-noenc"
745-
;;
746-
esac
747-
fi
759+
# Derive test parameters
760+
local use_uki="false"
761+
local use_encryption="false"
762+
[[ "${bootloader}" == "uki" ]] && use_uki="true"
763+
[[ "${rootfs_enc}" == "enc" ]] && use_encryption="true"
764+
local test_name="${bootloader}-${rootfs_enc}-${delta_location}"
748765

749766
# Pre-flight checks
750767
log::step "Running pre-flight checks..."
@@ -770,32 +787,14 @@ main() {
770787
SOURCE_IMAGE="${TEST_IMAGE_CACHE}"
771788
fi
772789

773-
# Run tests
790+
# Run test
774791
local failed_tests=()
775792
local passed_tests=()
776793

777-
if [[ "${run_all}" == "true" ]]; then
778-
local all_cases=("uki-encrypted" "uki-noenc" "grub-encrypted" "grub-noenc")
779-
for case_name in "${all_cases[@]}"; do
780-
if run_test_case "${case_name}" \
781-
"$( [[ "${case_name}" == uki-* ]] && echo true || echo false )" \
782-
"$( [[ "${case_name}" == *-encrypted ]] && echo true || echo false )"; then
783-
passed_tests+=("${case_name}")
784-
else
785-
failed_tests+=("${case_name}")
786-
fi
787-
done
794+
if run_test_case "${test_name}" "${use_uki}" "${use_encryption}" "${delta_location}"; then
795+
passed_tests+=("${test_name}")
788796
else
789-
local use_uki="false"
790-
local use_encryption="false"
791-
[[ "${test_case}" == uki-* ]] && use_uki="true"
792-
[[ "${test_case}" == *-encrypted ]] && use_encryption="true"
793-
794-
if run_test_case "${test_case}" "${use_uki}" "${use_encryption}"; then
795-
passed_tests+=("${test_case}")
796-
else
797-
failed_tests+=("${test_case}")
798-
fi
797+
failed_tests+=("${test_name}")
799798
fi
800799

801800
# Report results

0 commit comments

Comments
 (0)