mirror of
https://github.com/kernelkit/infix.git
synced 2026-08-02 13:53:01 +02:00
test: enable running infix tests from external projects
Minor adjustments have been made to enable calling infix tests from an external project (i.e. 'make test' target). This essentially allows running any external test (or a group of tests) using the infix-9pm tool.
This commit is contained in:
committed by
Mattias Walström
parent
b76904c0e6
commit
8227f1bcde
@@ -1,4 +1,4 @@
|
||||
export BR2_EXTERNAL := $(CURDIR)
|
||||
export BR2_EXTERNAL ?= $(CURDIR)
|
||||
export PATH := $(CURDIR)/bin:$(PATH)
|
||||
|
||||
ARCH ?= $(shell uname -m)
|
||||
|
||||
@@ -15,6 +15,10 @@ usage: test/env [<OPTS>] -f <IMAGE> -q <QENETH-DIR> <COMMAND> [<ARGS>...]
|
||||
|
||||
Options:
|
||||
|
||||
-b <BASE-DIR>
|
||||
Use this directory as the top-level bind mount inside the container.
|
||||
If not specified, Infix's top directory is used.
|
||||
|
||||
-c
|
||||
Clean up cruft, lingering images, old containers, unused volumes.
|
||||
Used by GitHub action to prevent issues with running tests.
|
||||
@@ -126,9 +130,13 @@ name()
|
||||
containerize=yes
|
||||
[ -c /dev/kvm ] && kvm="--device=/dev/kvm"
|
||||
files=
|
||||
basedir="$ixdir"
|
||||
|
||||
while getopts "cCDf:hiKp:q:rt:" opt; do
|
||||
while getopts "b:cCDf:hiKp:q:rt:" opt; do
|
||||
case ${opt} in
|
||||
b)
|
||||
basedir="$OPTARG"
|
||||
;;
|
||||
c)
|
||||
$(runner) image prune -af
|
||||
$(runner) volume prune -f
|
||||
@@ -177,7 +185,7 @@ while getopts "cCDf:hiKp:q:rt:" opt; do
|
||||
done
|
||||
|
||||
if [ "$containerize" ]; then
|
||||
volumes="--volume $ixdir:$ixdir --workdir=$ixdir/test"
|
||||
volumes="--volume $basedir:$basedir --workdir=$ixdir/test"
|
||||
case "$(runner)" in
|
||||
docker)
|
||||
volumes="$volumes --env HOST_CHOWN_PATH=$ixdir/test"
|
||||
|
||||
+13
-6
@@ -1,28 +1,35 @@
|
||||
base-dir := $(lastword $(subst :, ,$(BR2_EXTERNAL)))
|
||||
test-dir := $(BR2_EXTERNAL_INFIX_PATH)/test
|
||||
ninepm := $(BR2_EXTERNAL_INFIX_PATH)/test/9pm/9pm.py
|
||||
|
||||
UNIT_TESTS ?= $(test-dir)/case/all-repo.yaml $(test-dir)/case/all-unit.yaml
|
||||
INFIX_TESTS ?= $(test-dir)/case/all.yaml
|
||||
TESTS ?= $(test-dir)/case/all.yaml
|
||||
|
||||
IMAGE ?= infix
|
||||
TOPOLOGY-DIR ?= $(test-dir)/virt/quad
|
||||
|
||||
base := -b $(base-dir)
|
||||
|
||||
TEST_MODE ?= qeneth
|
||||
mode-qeneth := -q $(test-dir)/virt/quad
|
||||
mode-qeneth := -q $(TOPOLOGY-DIR)
|
||||
mode-host := -t $(or $(TOPOLOGY),/etc/infamy.dot)
|
||||
mode-run := -t $(BINARIES_DIR)/qemu.dot
|
||||
mode := $(mode-$(TEST_MODE))
|
||||
|
||||
binaries-$(ARCH) := $(addprefix infix-$(ARCH),.img -disk.img .pkg)
|
||||
|
||||
binaries-$(ARCH) := $(addprefix $(IMAGE)-$(ARCH),.img -disk.img .pkg)
|
||||
binaries-x86_64 += OVMF.fd
|
||||
binaries := $(foreach bin,$(binaries-$(ARCH)),-f $(BINARIES_DIR)/$(bin))
|
||||
|
||||
test:
|
||||
$(test-dir)/env -r $(mode) $(binaries) $(ninepm) $(INFIX_TESTS)
|
||||
$(test-dir)/env -r $(base) $(mode) $(binaries) $(ninepm) $(TESTS)
|
||||
|
||||
test-sh:
|
||||
$(test-dir)/env $(mode) $(binaries) -i /bin/sh
|
||||
$(test-dir)/env $(base) $(mode) $(binaries) -i /bin/sh
|
||||
|
||||
# Unit tests run with random (-r) hostname and container name to
|
||||
# prevent race conditions when running in CI environments.
|
||||
test-unit:
|
||||
$(test-dir)/env -r $(ninepm) $(UNIT_TESTS)
|
||||
$(test-dir)/env -r $(base) $(ninepm) $(UNIT_TESTS)
|
||||
|
||||
.PHONY: test test-sh test-unit
|
||||
|
||||
Reference in New Issue
Block a user