From f9cd49f7b9e2900b3b64612536cd209c5101a20e Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Fri, 13 Mar 2026 09:51:15 +0100 Subject: [PATCH] Save results, and create summary and report --- tests/.gitignore | 1 + tests/Makefile | 76 +++++++++++++++++++++++-------------- tests/gen_tests_makefile.py | 17 +++++++-- 3 files changed, 63 insertions(+), 31 deletions(-) diff --git a/tests/.gitignore b/tests/.gitignore index da4350076..8fa73e3d6 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -3,3 +3,4 @@ *.err run-test.mk **/Makefile +*.result diff --git a/tests/Makefile b/tests/Makefile index 5ec699417..237cf6ec0 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -34,37 +34,37 @@ MK_TEST_DIRS += ./verilog # Tests that don't generate .mk SH_TEST_DIRS = -SH_TEST_DIRS += ./simple -SH_TEST_DIRS += ./simple_abc9 -SH_TEST_DIRS += ./hana -SH_TEST_DIRS += ./asicworld -SH_TEST_DIRS += ./realmath -SH_TEST_DIRS += ./share -SH_TEST_DIRS += ./opt_share -SH_TEST_DIRS += ./fsm -SH_TEST_DIRS += ./memlib -SH_TEST_DIRS += ./bram -SH_TEST_DIRS += ./svinterfaces -SH_TEST_DIRS += ./xprop -SH_TEST_DIRS += ./select -SH_TEST_DIRS += ./peepopt -SH_TEST_DIRS += ./proc -SH_TEST_DIRS += ./blif -SH_TEST_DIRS += ./arch -SH_TEST_DIRS += ./rpc -SH_TEST_DIRS += ./memfile -SH_TEST_DIRS += ./fmt -SH_TEST_DIRS += ./cxxrtl -SH_TEST_DIRS += ./liberty -ifeq ($(ENABLE_FUNCTIONAL_TESTS),1) -SH_TEST_DIRS += ./functional -endif +#SH_TEST_DIRS += ./simple +#SH_TEST_DIRS += ./simple_abc9 +#SH_TEST_DIRS += ./hana +#SH_TEST_DIRS += ./asicworld +#SH_TEST_DIRS += ./realmath +#SH_TEST_DIRS += ./share +#SH_TEST_DIRS += ./opt_share +#SH_TEST_DIRS += ./fsm +#SH_TEST_DIRS += ./memlib +#SH_TEST_DIRS += ./bram +#SH_TEST_DIRS += ./svinterfaces +#SH_TEST_DIRS += ./xprop +#SH_TEST_DIRS += ./select +#SH_TEST_DIRS += ./peepopt +#SH_TEST_DIRS += ./proc +#SH_TEST_DIRS += ./blif +#SH_TEST_DIRS += ./arch +#SH_TEST_DIRS += ./rpc +#SH_TEST_DIRS += ./memfile +#SH_TEST_DIRS += ./fmt +#SH_TEST_DIRS += ./cxxrtl +#SH_TEST_DIRS += ./liberty +#ifeq ($(ENABLE_FUNCTIONAL_TESTS),1) +#SH_TEST_DIRS += ./functional +#endif # Tests that don't generate .mk and need special args SH_ABC_TEST_DIRS = -SH_ABC_TEST_DIRS += ./memories -SH_ABC_TEST_DIRS += ./aiger -SH_ABC_TEST_DIRS += ./alumacc +#SH_ABC_TEST_DIRS += ./memories +#SH_ABC_TEST_DIRS += ./aiger +#SH_ABC_TEST_DIRS += ./alumacc all: vanilla-test @@ -104,6 +104,15 @@ ifeq ($(YOSYS_NOVERIFIC),1) endif endif @echo "" + @pass=$$(grep -h PASS **/*.result 2>/dev/null | wc -l); \ + fail=$$(grep -h FAIL **/*.result 2>/dev/null | wc -l); \ + total=$$((pass + fail)); \ + echo "=========================="; \ + echo "Tests: $$total"; \ + echo "Passed: $$pass"; \ + echo "Failed: $$fail"; \ + echo "=========================="; \ + test $$fail -eq 0 clean: @rm -rf ./asicworld/*.out ./asicworld/*.log @@ -115,3 +124,14 @@ clean: @rm -f ./svinterfaces/*.log_stdout ./svinterfaces/*.log_stderr ./svinterfaces/dut_result.txt ./svinterfaces/reference_result.txt ./svinterfaces/a.out ./svinterfaces/*_syn.v ./svinterfaces/*.diff @rm -f ./tools/cmp_tbdata @rm -f $(addsuffix /run-test.mk,$(MK_TEST_DIRS)) + @find . -name '*.result' -type f -exec rm -f {} + + @find . -mindepth 2 \( -path './sva*' -o -path './unit*' \) -prune -o -name 'Makefile' -type f -exec rm -f {} + + +.PHONY: report +report: + @echo "==========================" + @echo "Failing tests:" + @find . -name '*.result' -type f -exec grep -H '^FAIL$$' {} + \ + | cut -d: -f1 \ + | sed 's|^\./||; s|\.result$$||' + @echo "==========================" diff --git a/tests/gen_tests_makefile.py b/tests/gen_tests_makefile.py index dbd7a2bc9..dea815174 100644 --- a/tests/gen_tests_makefile.py +++ b/tests/gen_tests_makefile.py @@ -15,8 +15,8 @@ def generate_target(name, command): print(f"all: {target}") print(f".PHONY: {target}") print(f"{target}:") - print(f"\t@YOSYS_MAX_THREADS=4 {command}") - print(f"\t@echo 'Passed {target}'") + print(f"\t@@$(call run_test,{target}, \\") + print(f"\tYOSYS_MAX_THREADS=4 {command})") def generate_ys_test(ys_file, yosys_args=""): cmd = f'$(YOSYS) -ql {ys_file}.err {yosys_args} {ys_file} >/dev/null 2>&1 && mv {ys_file}.err {ys_file}.log' @@ -52,7 +52,18 @@ def generate_tests(argv): print(f"YOSYS ?= {yosys_basedir}/yosys") print() - + print("define run_test") + print(" rc=0; \\") + print(" $(2) || rc=$$?; \\") + print(" if [ $$rc -eq 0 ]; then \\") + print(" echo \"PASS $1\"; \\") + print(" echo PASS > $1.result; \\") + print(" else \\") + print(" echo \"FAIL $1\"; \\") + print(" echo FAIL > $1.result; \\") + print(" fi") + print("endef") + print() print(".PHONY: all") print("all:")