mirror of
https://github.com/JasonN3/build-container-installer.git
synced 2025-12-25 02:47:56 +01:00
Add tests (#76)
This commit is contained in:
parent
3dc05c0efc
commit
3d85c93010
12 changed files with 458 additions and 43 deletions
51
Makefile
51
Makefile
|
|
@ -20,9 +20,12 @@ FLATPAK_REMOTE_REFS_DIR =
|
|||
# Secure boot
|
||||
ENROLLMENT_PASSWORD =
|
||||
SECURE_BOOT_KEY_URL =
|
||||
|
||||
###################
|
||||
# Hidden vars
|
||||
|
||||
# Cache
|
||||
DNF_CACHE =
|
||||
|
||||
PACKAGE_MANAGER = dnf
|
||||
|
||||
# Functions
|
||||
|
|
@ -32,6 +35,20 @@ PACKAGE_MANAGER = dnf
|
|||
get_templates = $(shell ls lorax_templates/$(1)_*.tmpl) \
|
||||
$(foreach file,$(notdir $(shell ls lorax_templates/scripts/post/$(1)_*)),lorax_templates/post_$(file).tmpl)
|
||||
|
||||
# Get a list of tests for the feature
|
||||
# $1 = test type
|
||||
# $2 = feature
|
||||
run_tests = tests="$(shell ls tests/$(1)/$(2)_*)"; \
|
||||
if [ -n "$$tests" ]; \
|
||||
then \
|
||||
chmod +x $$tests; \
|
||||
for test in $$tests; \
|
||||
do \
|
||||
$(foreach var,$(_VARS),$(var)=$($(var))) ./$${test}; \
|
||||
RC=$$?; if [ $$RC != 0 ]; then exit $$RC; fi; \
|
||||
done; \
|
||||
fi
|
||||
|
||||
# Converts a post script to a template
|
||||
# $1 = script to convert
|
||||
# $2 = file on ISO to write
|
||||
|
|
@ -217,8 +234,10 @@ install-test-deps:
|
|||
|
||||
test: test-iso test-vm
|
||||
|
||||
test-repo:
|
||||
bash tests/repo/vars.sh
|
||||
|
||||
test-iso:
|
||||
$(eval _TESTS = $(filter-out README.md,$(shell ls tests/iso)))
|
||||
$(eval _VARS = VERSION FLATPAK_REMOTE_NAME _FLATPAK_REPO_URL)
|
||||
|
||||
sudo modprobe loop
|
||||
|
|
@ -227,21 +246,10 @@ test-iso:
|
|||
sudo mount -t squashfs -o loop /mnt/iso/images/install.img /mnt/install
|
||||
|
||||
# install tests
|
||||
chmod +x $(foreach test,$(filter install_%,$(_TESTS)),tests/iso/$(test))
|
||||
for test in $(_TESTS); \
|
||||
do \
|
||||
$(foreach var,$(_VARS),$(var)=$($(var))) ./tests/iso/$${test}; \
|
||||
done
|
||||
|
||||
$(call run_tests,iso,install)
|
||||
|
||||
# flapak tests
|
||||
if [ -n "$(FLATPAK_REMOTE_REFS)" ]; \
|
||||
then \
|
||||
chmod +x $(foreach test,$(filter flatpak_%,$(_TESTS)),tests/iso/$(test)); \
|
||||
for test in $(_TESTS); \
|
||||
do \
|
||||
$(foreach var,$(_VARS),$(var)=$($(var))) ./tests/iso/$${test}; \
|
||||
done; \
|
||||
fi
|
||||
if [ -n "$(FLATPAK_REMOTE_REFS)" ]; then $(call run_tests,iso,flatpak); fi
|
||||
|
||||
# Cleanup
|
||||
sudo umount /mnt/install
|
||||
|
|
@ -259,9 +267,14 @@ ansible_inventory:
|
|||
echo " ansible_ssh_common_args: '-o StrictHostKeyChecking=no'" >> ansible_inventory
|
||||
|
||||
test-vm: ansible_inventory
|
||||
$(eval _VARS = IMAGE_REPO IMAGE_NAME IMAGE_TAG)
|
||||
|
||||
ansible -i ansible_inventory -m ansible.builtin.wait_for_connection vm
|
||||
$(eval _TESTS = $(filter-out README.md,$(shell ls tests/vm)))
|
||||
chmod +x $(foreach test,$(_TESTS),tests/vm/$(test))
|
||||
for test in $(_TESTS); do ./tests/vm/$${test}; done
|
||||
|
||||
# install tests
|
||||
$(call run_tests,vm,install)
|
||||
|
||||
# flapak tests
|
||||
if [ -n "$(FLATPAK_REMOTE_REFS)" ]; then $(call run_tests,vm,flatpak); fi
|
||||
|
||||
.PHONY: clean install-deps install-test-deps test test-iso test-vm
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue