From f426506e70807bf38b05fee342a7d3cc3a31a44d Mon Sep 17 00:00:00 2001 From: Andrew Cooper Date: Mon, 22 Feb 2016 12:43:51 +0000 Subject: [PATCH] Introduce test categories and create a test-info.json for each test test-info.json will accumulate relevant test metadata. Signed-off-by: Andrew Cooper --- Makefile | 3 ++- build/common.mk | 2 ++ build/gen.mk | 17 ++++++++++++++++- build/mkinfo.py | 15 +++++++++++++++ docs/mainpage.dox | 1 + tests/example/Makefile | 1 + tests/selftest/Makefile | 1 + tests/swint-emulation/Makefile | 1 + 8 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 build/mkinfo.py diff --git a/Makefile b/Makefile index 54cf8e1..7657e19 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,8 @@ cscope: .PHONY: clean clean: find . \( -name "*.o" -o -name "*.d" -o -name "*.lds" \) -delete - find tests/ \( -executable -name "test-*" -o -name "test-*.cfg" \) -delete + find tests/ \( -executable -name "test-*" -o -name "test-*.cfg" \ + -o -name "test-info.json" \) -delete .PHONY: distclean distclean: clean diff --git a/build/common.mk b/build/common.mk index 6971cd1..227e909 100644 --- a/build/common.mk +++ b/build/common.mk @@ -3,6 +3,8 @@ DESTDIR ?= $(ROOT)/dist PREFIX ?= $(ROOT) CC = gcc +ALL_CATEGORIES := special functional + ALL_ENVIRONMENTS := pv64 pv32pae hvm64 hvm32pae hvm32 PV_ENVIRONMENTS := $(filter pv%,$(ALL_ENVIRONMENTS)) diff --git a/build/gen.mk b/build/gen.mk index 5d8170c..a7b759d 100644 --- a/build/gen.mk +++ b/build/gen.mk @@ -13,11 +13,26 @@ ifneq ($(filter-out $(ALL_ENVIRONMENTS),$(TEST-ENVS)),) $(error Unrecognised environments '$(filter-out $(ALL_ENVIRONMENTS),$(TEST-ENVS))') endif +ifeq ($(CATEGORY),) +$(error CATEGORY should not be empty) +endif + +ifneq ($(filter-out $(ALL_CATEGORIES),$(CATEGORY)),) +$(error Unrecognised category '$(filter-out $(ALL_CATEGORIES),$(CATEGORY))') +endif + .PHONY: build build: $(foreach env,$(TEST-ENVS),test-$(env)-$(NAME) test-$(env)-$(NAME).cfg) +build: test-info.json + +test-info.json: $(ROOT)/build/mkinfo.py FORCE + @python $< $@.tmp "$(NAME)" "$(CATEGORY)" "$(TEST-ENVS)" + @if ! cmp -s $@ $@.tmp; then mv -f $@.tmp $@; else rm -f $@.tmp; fi .PHONY: install install-each-env -install: install-each-env +install: install-each-env test-info.json + @mkdir -p $(DESTDIR)/tests/$(NAME) + install -m664 -p test-info.json $(DESTDIR)/tests/$(NAME) define PERENV_build diff --git a/build/mkinfo.py b/build/mkinfo.py new file mode 100644 index 0000000..4b4dc22 --- /dev/null +++ b/build/mkinfo.py @@ -0,0 +1,15 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import sys, os, json + +template = { + "name": sys.argv[2], + "category": sys.argv[3], + "environments": sys.argv[4].split(" "), + } + +open(sys.argv[1], "w").write( + json.dumps(template, indent=4, separators=(',', ': ')) + + "\n" + ) diff --git a/docs/mainpage.dox b/docs/mainpage.dox index ddc8995..a44f536 100644 --- a/docs/mainpage.dox +++ b/docs/mainpage.dox @@ -35,6 +35,7 @@ Requirements: - GNU Make >= 3.81 - GNU comaptible toolchain, capable of `-std=gnu99`, `-m64`, and `-m32` - Clang may be used, via `CC="clang -no-integrated-as"` +- Python To obtain and build: diff --git a/tests/example/Makefile b/tests/example/Makefile index e4878bc..872769d 100644 --- a/tests/example/Makefile +++ b/tests/example/Makefile @@ -4,6 +4,7 @@ ROOT := $(abspath $(CURDIR)/../..) include $(ROOT)/build/common.mk NAME := example +CATEGORY := special TEST-ENVS := $(ALL_ENVIRONMENTS) obj-perenv += main.o diff --git a/tests/selftest/Makefile b/tests/selftest/Makefile index 22079fb..fc249d7 100644 --- a/tests/selftest/Makefile +++ b/tests/selftest/Makefile @@ -4,6 +4,7 @@ ROOT := $(abspath $(CURDIR)/../..) include $(ROOT)/build/common.mk NAME := selftest +CATEGORY := special TEST-ENVS := $(ALL_ENVIRONMENTS) obj-perenv += main.o diff --git a/tests/swint-emulation/Makefile b/tests/swint-emulation/Makefile index 59a3226..246afb3 100644 --- a/tests/swint-emulation/Makefile +++ b/tests/swint-emulation/Makefile @@ -4,6 +4,7 @@ ROOT := $(abspath $(CURDIR)/../..) include $(ROOT)/build/common.mk NAME := swint-emulation +CATEGORY := functional TEST-ENVS := $(HVM_ENVIRONMENTS) obj-perenv += main.o lowlevel.o -- 2.39.5