tests: introduce post synthesis simulation infrastructure Signed-off-by: Paweł Czarnecki <pczarnecki@antmicro.com>
diff --git a/Makefile_test.common b/Makefile_test.common index db3cc3c..ca6ec18 100644 --- a/Makefile_test.common +++ b/Makefile_test.common
@@ -95,6 +95,47 @@ endef +define test_post_synth_sim_tpl = +$(1): $(1)/ok + @printf "Test %-18s \e[32mPASSED\e[0m @ %s\n" $(1) $(CURDIR); + +$(1)/ok: $(1)/synth + @make -C $(1)/sim sim; \ + if [ $$$$? -ne 0 ]; then \ + printf "Test %-18s \e[31;1mFAILED\e[0m @ %s\n" $(1) $(CURDIR); \ + false; \ + else \ + touch $$@; \ + true; \ + fi + +$(1)/synth: $(1)/$$(notdir $(1).v) + @set +e; \ + cd $(1); \ + echo "source $(TEST_UTILS)" > run-$$(notdir $(1)).tcl ;\ + echo "source $$(notdir $(1)).tcl" >> run-$$(notdir $(1)).tcl ;\ + DESIGN_TOP=$$(notdir $(1)) TEST_OUTPUT_PREFIX=./ \ + yosys -c "run-$$(notdir $(1)).tcl" -q -q -l $$(notdir $(1)).log; \ + RETVAL=$$$$?; \ + rm -f run-$$(notdir $(1)).tcl; \ + if [ ! -z "$$($(1)_negative)" ] && [ $$($(1)_negative) -eq 1 ]; then \ + if [ $$$$RETVAL -ne 0 ]; then \ + printf "Negative test %-20s \e[32mPASSED\e[0m @ %s\n" $(1) $(CURDIR); \ + true; \ + else \ + printf "Negative test %-20s \e[31;1mFAILED\e[0m @ %s\n" $(1) $(CURDIR); \ + false; \ + fi \ + else \ + if [ $$$$RETVAL -ne 0 ]; then \ + echo "Unexpected runtime error"; \ + printf "Test %-20s \e[31;1mFAILED\e[0m @ %s\n" $(1) $(CURDIR); \ + false; \ + fi \ + fi + +endef + define unit_test_tpl = $(1): $(1)/$(1).test @$$< @@ -109,7 +150,7 @@ diff_test = diff $(1)/$(1).golden.$(2) $(1)/$(1).$(2) -all: $(TESTS) $(SIM_TESTS) $(UNIT_TESTS) +all: $(TESTS) $(SIM_TESTS) $(POST_SYNTH_SIM_TESTS) $(UNIT_TESTS) $(GTEST_DIR)/build/lib/libgtest.a $(GTEST_DIR)/build/lib/libgtest_main.a: @mkdir -p $(GTEST_DIR)/build @@ -121,10 +162,12 @@ $(foreach test,$(TESTS),$(eval $(call test_tpl,$(test)))) $(foreach test,$(SIM_TESTS),$(eval $(call test_sim_tpl,$(test)))) +$(foreach test,$(POST_SYNTH_SIM_TESTS),$(eval $(call test_post_synth_sim_tpl,$(test)))) $(foreach test,$(UNIT_TESTS),$(eval $(call unit_test_tpl,$(test)))) clean: @rm -rf $(foreach test,$(TESTS),$(test)/$(test).sdc $(test)/$(test)_[0-9].sdc $(test)/$(test).txt $(test)/$(test).eblif $(test)/$(test).json) @rm -rf $(foreach test,$(SIM_TESTS),$(test)/*.vvp $(test)/*.vcd) + @rm -rf $(foreach test,$(POST_SYNTH_SIM_TESTS),$(test)/sim/*.vvp $(test)/sim/*.vcd $(test)/sim/*post_synth.v) @rm -rf $(foreach test,$(UNIT_TESTS),$(test)/$(test).test.o $(test)/$(test).test.d $(test)/$(test).test) @find . -name "ok" -or -name "*.log" | xargs rm -rf