From 548178e343fd0081af8a712cd017e223e909a52a Mon Sep 17 00:00:00 2001 From: mrg Date: Fri, 4 Feb 2022 14:38:35 -0800 Subject: [PATCH] Change Makefile to use docker in parallel instead of regress.py --- compiler/tests/Makefile | 88 ++++++++++++++++++++--------------------- 1 file changed, 43 insertions(+), 45 deletions(-) diff --git a/compiler/tests/Makefile b/compiler/tests/Makefile index 6933f165..30e0c044 100644 --- a/compiler/tests/Makefile +++ b/compiler/tests/Makefile @@ -1,14 +1,20 @@ TOP_DIR := $(realpath $(dir $(lastword $(MAKEFILE_LIST)))../..) include $(TOP_DIR)/openram.mk -.DEFAULT_GOAL := regress +.DEFAULT_GOAL := all -ARGS ?= "-k" +ARGS ?= +TECH ?= scn4m_subm +TECHS := scn4m_subm freepdk45 +# sky130 -TEST_DIR = $(TOP_DIR)/compiler/tests -TEST_SRCS=$(sort $(notdir $(wildcard $(TEST_DIR)/*_test.py))) -TEST_DIRS=$(basename $(TEST_SRCS)) -TEST_STAMPS=$(addsuffix .ok,$(TEST_DIRS)) +TEST_DIR = $(TOP_DIR)/compiler/tests +TEST_SRCS = $(sort $(notdir $(wildcard $(TEST_DIR)/*_test.py))) +TEST_BASES = $(basename $(TEST_SRCS)) +TEST_STAMPS= $(addsuffix .ok,$(TEST_BASES)) + +OPENRAM_DIR := /openram/compiler/tests +RESULTS_DIR := $(OPENRAM_DIR)/results TEST_BROKEN := \ 50_riscv_1k_1rw1r_func_test.py \ @@ -29,55 +35,48 @@ TEST_BROKEN := \ WORKING_TEST_STAMPS=$(filter-out $(addsuffix .ok, (TEST_BROKEN)), $(TEST_STAMPS)) -$(TEST_DIRS): + +$(TEST_BASES): @$(MAKE) --no-print-directory $@.ok -tests: - @echo "Running the following tests" - @for S in $(WORKING_TEST_STAMPS); do echo " - $$S"; done - @sleep 5 - @$(MAKE) $(WORKING_TEST_STAMPS) -.PHONY: +gettech = $(word 1,$(subst /, ,$*)) +getfile = $(word 2,$(subst /, ,$*)) +WORKING_TECH_TEST_STAMPS=$(foreach T, $(TECHS),$(addprefix $T/,$(WORKING_TEST_STAMPS))) +all: $(WORKING_TECH_TEST_STAMPS) + +# To run individual tests %.ok: %.py - @echo "Running $*" - @mkdir -p $(TOP_DIR)/compiler/tests/results/$* + @$(MAKE) --no-print-directory $(TECH)/$*.ok + +# To run a test in a given technology +%.ok: +# @echo "Running $(gettech) $(getfile) ... " + @mkdir -p results/$* @docker run \ -v $(TOP_DIR):/openram \ -v $(FREEPDK45):/pdk/freepdk45\ -v $(PDK_ROOT):/pdk \ --user $(UID):$(GID) \ + -e OPENRAM_TMP=$(OPENRAM_DIR)/results/$* \ vlsida/openram-ubuntu:latest \ - sh -c ". ~/.bashrc && python3 -u /openram/compiler/tests/$*.py $(ARGS) && touch $@" - + sh -c ". ~/.bashrc && python3 -u $(OPENRAM_DIR)/$(getfile).py -t $(gettech) -k $(ARGS) > $(OPENRAM_DIR)/results/$*.out 2>&1 && touch $(OPENRAM_DIR)/results/$*.ok" + @test -f $(TOP_DIR)/compiler/tests/results/$*.ok && echo "$* ... PASS!" || echo "$* ... FAIL!" .DELETE_ON_ERROR: $(TEST_STAMPS) -TECHS := scn4m_subm freepdk45 -#sky130 - -$(TECHS): - docker run \ - -v $(TOP_DIR):/openram \ - -v $(FREEPDK45):/pdk/freepdk45 \ - -v $(PDK_ROOT):/pdk \ - --user $(UID):$(GID) \ - -e OPENRAM_TMP=/openram/compiler/tests/tmp_$@/$* \ - vlsida/openram-ubuntu:latest \ - sh -c ". ~/.bashrc && python3 -u /openram/compiler/tests/regress.py $(ARGS) -t $@" -.PHONY: $(TECHS) - -regress: $(TECHS) -.PHONY: regress - -foo: - docker run \ - -v $(TOP_DIR):/openram \ - -v $(FREEPDK45):/pdk/freepdk45 \ - -v $(PDK_ROOT):/pdk \ - --user $(UID):$(GID) \ - vlsida/openram-ubuntu:latest \ - sh -c ". ~/.bashrc && env" -.PHONY: foo +#$(TECHS): +# @echo "Running $*" +# docker run \ +# -v $(TOP_DIR):/openram \ +# -v $(FREEPDK45):/pdk/freepdk45 \ +# -v $(PDK_ROOT):/pdk \ +# --user $(UID):$(GID) \ +# -e OPENRAM_TMP=$(OPENRAM_DIR)/results/$@ \ +# vlsida/openram-ubuntu:latest \ +# sh -c ". ~/.bashrc && python3 -u $(OPENRAM_DIR)/regress.py -t $@ $(ARGS)" +#.PHONY: $(TECHS) +#regress: $(TECHS) +#.PHONY: regress mount: docker run -it \ @@ -89,6 +88,5 @@ mount: .PHONY: mount clean: - @rm -rf $(TEST_STAMPS) - @rm -rf $(TEST_DIRS) + @rm -rf $(TOP_DIR)/compiler/tests/results .PHONE: clean