Add a new 'avocado' target to the test/ Makefile, which will install avocado into a Python venv, and run the Avocado based tests with it. Signed-off-by: David Gibson <david(a)gibson.dropbear.id.au> --- test/.gitignore | 1 + test/Makefile | 16 ++++++++++++++++ test/run_avocado | 9 +++++---- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/test/.gitignore b/test/.gitignore index 6dd4790b..a79d5b6f 100644 --- a/test/.gitignore +++ b/test/.gitignore @@ -10,3 +10,4 @@ QEMU_EFI.fd nstool guest-key guest-key.pub +/venv/ diff --git a/test/Makefile b/test/Makefile index 35a3b559..fda62984 100644 --- a/test/Makefile +++ b/test/Makefile @@ -63,6 +63,12 @@ LOCAL_ASSETS = mbuto.img mbuto.mem.img podman/bin/podman QEMU_EFI.fd \ ASSETS = $(DOWNLOAD_ASSETS) $(LOCAL_ASSETS) +SYSTEM_PYTHON = python3 +VENV = venv +PYTHON = $(VENV)/bin/python3 +PIP = $(VENV)/bin/pip3 +RUN_AVOCADO = cd .. && test/$(PYTHON) test/run_avocado + CFLAGS = -Wall -Werror -Wextra -pedantic -std=c99 assets: $(ASSETS) @@ -116,6 +122,15 @@ medium.bin: big.bin: dd if=/dev/urandom bs=1M count=10 of=$@ +.PHONY: venv +venv: + $(SYSTEM_PYTHON) -m venv $(VENV) + $(PIP) install avocado-framework + +.PHONY: avocado +avocado: venv + $(RUN_AVOCADO) avocado + check: assets ./run @@ -127,6 +142,7 @@ clean: rm -f $(LOCAL_ASSETS) rm -rf test_logs rm -f prepared-*.qcow2 prepared-*.img + rm -rf $(VENV) realclean: clean rm -rf $(DOWNLOAD_ASSETS) diff --git a/test/run_avocado b/test/run_avocado index 37db17c3..19a94a8f 100755 --- a/test/run_avocado +++ b/test/run_avocado @@ -32,12 +32,13 @@ from avocado.core.suite import TestSuite def main(): repo_root_path = os.path.abspath( - os.path.dirname(os.path.dirname(os.path.dirname(__file__))) + os.path.dirname(os.path.dirname(__file__)) ) + + references = [os.path.join(repo_root_path, 'test', x) for x in sys.argv[1:]] + config = { - "resolver.references": [ - os.path.join(repo_root_path, "test", "avocado", "static_checkers.json") - ], + "resolver.references": references, "runner.identifier_format": "{args[0]}", } suite = TestSuite.from_config(config, name="static_checkers") -- 2.45.2