Skip to content

Commit

Permalink
(Makefile) add tools
Browse files Browse the repository at this point in the history
Adds a `make tools` to build associated tooling.
Namely, just litmus-toml-translator for now.

Also adds a `translate-toml-tests` target to run the translator over the
litmus-tests-armv8a-system-vmsa repo to produce generated versions of all
the tests.
  • Loading branch information
bensimner committed May 19, 2024
1 parent 46f1d02 commit b991613
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 10 deletions.
45 changes: 37 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
define USAGE
Simple Usage:
make build builds qemu and kvm targets
make check runs the compiler warning checks but doesn't compile
make docker builds docker container and runs the unittests
make clean remove built files in bin/
make deepclean clean everything. No really.
make publish publish doc/ folder to gh-pages
make build builds qemu and kvm targets
make check runs the compiler warning checks but doesn't compile
make docker builds docker container and runs the unittests
make clean remove built files in bin/
make deepclean clean everything. No really.
make publish publish doc/ folder to gh-pages
make hw-results collect hardware results from known sources
make test run the unittests in QEMU
make run run the litmus tests in QEMU
make test run the unittests in QEMU
make run run the litmus tests in QEMU
make tools build supporting tooling
endef

define ADV_USAGE
Expand All @@ -19,6 +20,10 @@ Advanced Usage:
Runs qemu_unittests.exe in the background and attaches gdb
make build-unittests
Builds the unittests and generates qemu_unittests.exe
make tools
Builds associated tooling
make translate-toml-tests
Runs the automated TOML test translator
make lint
Runs automated linter against all litmus test C files and quits
See LINTER option below
Expand All @@ -27,6 +32,8 @@ Advanced Usage:
See LITMUS_TESTS and MAKE_TEST_LIST_CMD options below
make cleanlibs
remove built harness objects but leave compiled tests alone
make cleantools
remove built tool files
make cleantests
remove auto-generated test files in litmus/
make docker-interact
Expand Down Expand Up @@ -112,6 +119,12 @@ OBJDUMP = $(PREFIX)objdump
QEMU = qemu-system-aarch64
GDB = $(PREFIX)gdb

# dependency roots
# by default we assume rems-project/ repos are siblings to this one
# and litmus-tests/ org repos are a sibling to rems-project
REMSORGDIR = ../
LITMUSORGDIR = ../../litmus-tests/

# use `taskset` to force QEMU to exist only on some cores
# e.g. for big.LITTLE implementations
#
Expand Down Expand Up @@ -215,6 +228,16 @@ LINTER_ARGS = $(foreach e,$(LINTER_EXCLUDES),-e $(e))

NO_LINT = 0

# toml-translator arguments:
# TOML_TESTS: list of tests or @all file to translate.
# TOML_TRANSLATOR_ISLA_CONFIG: isla architecture config toml file.
# TOML_TRANSLATOR_ISLA_ARCH: isla architecture ir (or irx) file.
# TOML_TRANSLATOR_IGNORE_LIST: txt file with list of toml tests to ignore.
TOML_TESTS = $(LITMUSORGDIR)/litmus-tests-armv8a-system-vmsa/tests/@all
TOML_TRANSLATOR_ISLA_CONFIG = $(REMSORGDIR)/isla/configs/armv8p5.toml
TOML_TRANSLATOR_ISLA_ARCH = $(REMSORGDIR)/isla-snapshots/armv8p5.ir
TOML_TRANSLATOR_IGNORE_LIST = ./tools/litmus-toml-translator/toml-tests-ignore.txt

ifneq ($(findstring help,$(filter-out --%,$(MAKECMDGOALS))),)
TARGET_HELP = 1
endif
Expand All @@ -231,6 +254,7 @@ include mk/docs.mk
include mk/qemu.mk
include mk/build.mk
include mk/docker.mk
include mk/tools.mk

define INSTALL
$(call run_cmd,INSTALL,./$(2),\
Expand Down Expand Up @@ -267,6 +291,7 @@ cleantests:
$(call CLEAN,-f,litmus/test_list.txt)
$(call CLEAN,-f,litmus/group_list.txt)
$(call CLEAN,-f,litmus/linter.log)
$(call CLEAN,-rf,litmus/litmus_tests/generated)

# list of PHONY targets that will need
# files in the litmus/litmus_tests/ dir
Expand Down Expand Up @@ -434,6 +459,10 @@ LITMUS_TARGETS += run
include mk/litmus.mk
include mk/unittests.mk

# target populated by mk/tools.mk
.PHONY: tools
tools:

# provide a list of all the potential build- targets
.PHONY: list
list:
Expand Down
2 changes: 1 addition & 1 deletion mk/deepclean.mk
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
.PHONY: deepclean
deepclean: clean cleanlibs cleantests
deepclean: clean cleanlibs cleantests cleantools
18 changes: 17 additions & 1 deletion mk/litmus.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
.PHONY: debug-litmus
.PHONY: collect-litmus
.PHONY: count-litmus-tests
.PHONY: translate-toml-tests

LITMUS_TARGETS += lint collect-litmus debug-litmus count-litmus-tests check

Expand Down Expand Up @@ -141,4 +142,19 @@ debug-litmus: qemu_litmus

count-litmus-tests:
@echo Found `cat litmus/test_list.txt | wc -l` tests
@echo With `cat litmus/test_list.txt | awk '{print gensub(/^(.+\/)+(.+)\+(.+)$$/,"\\\\2","g",$$2)}' | sort | uniq | wc -l` unique shapes
@echo With `cat litmus/test_list.txt | awk '{print gensub(/^(.+\/)+(.+)\+(.+)$$/,"\\\\2","g",$$2)}' | sort | uniq | wc -l` unique shapes

TOML_TRANSLATOR_ARGS = \
-A $(TOML_TRANSLATOR_ISLA_ARCH) \
-C $(TOML_TRANSLATOR_ISLA_CONFIG) \
-o litmus/litmus_tests/generated

ifneq ($(TOML_TRANSLATOR_IGNORE_LIST),)
TOML_TRANSLATOR_ARGS += -x $(TOML_TRANSLATOR_IGNORE_LIST)
endif

translate-toml-tests: $(TOML_TRANSLATOR)
@mkdir -p litmus/litmus_tests/generated
$(call run_cmd,TOML_TRANSLATE,$(TOML_TESTS),\
$(TOML_TRANSLATOR) $(TOML_TRANSLATOR_ARGS) $(TOML_TESTS) \
)
16 changes: 16 additions & 0 deletions mk/tools.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.PHONY: cleantools

TOOLS_DIR = tools/

TOML_TRANSLATOR_ROOT = ./tools/litmus-toml-translator
TOML_TRANSLATOR = $(TOML_TRANSLATOR_ROOT)/target/release/litmus-toml-translator

$(TOML_TRANSLATOR):
$(call run_cmd,CARGO,tools/litmus-toml-translator,cd tools/litmus-toml-translator && cargo build --profile=release)
TOOLS += $(TOML_TRANSLATOR)
.PHONY: $(TOML_TRANSLATOR)

cleantools:
$(call run_cmd,CLEAN,tools/litmus-toml-translator,cd tools/litmus-toml-translator && cargo clean)

tools: $(TOOLS)

0 comments on commit b991613

Please sign in to comment.