mirror of
https://github.com/YosysHQ/yosys
synced 2026-05-30 21:57:47 +00:00
Add common.mk
This commit is contained in:
parent
c04d724337
commit
336a06d091
3 changed files with 53 additions and 38 deletions
|
|
@ -1,3 +1,10 @@
|
||||||
|
ifneq ($(wildcard ../Makefile.conf),)
|
||||||
|
include ../Makefile.conf
|
||||||
|
endif
|
||||||
|
|
||||||
|
OVERRIDE_MAIN=1
|
||||||
|
include ./common.mk
|
||||||
|
|
||||||
# Tests that generate Makefile with gen_tests_makefile.py
|
# Tests that generate Makefile with gen_tests_makefile.py
|
||||||
MK_TEST_DIRS =
|
MK_TEST_DIRS =
|
||||||
MK_TEST_DIRS += ./arch/analogdevices
|
MK_TEST_DIRS += ./arch/analogdevices
|
||||||
|
|
@ -106,22 +113,6 @@ endif
|
||||||
@echo ""
|
@echo ""
|
||||||
-@$(MAKE) --no-print-directory summary
|
-@$(MAKE) --no-print-directory summary
|
||||||
|
|
||||||
.PHONY: summary
|
|
||||||
summary:
|
|
||||||
@pass=$$(find . -type f -name '*.result' -exec grep '^PASS$$' {} + | wc -l); \
|
|
||||||
fail=$$(find . -type f -name '*.result' -exec grep '^FAIL$$' {} + | wc -l); \
|
|
||||||
total=$$((pass + fail)); \
|
|
||||||
echo "=========================="; \
|
|
||||||
echo "Tests: $$total"; \
|
|
||||||
echo "Passed: $$pass"; \
|
|
||||||
echo "Failed: $$fail"; \
|
|
||||||
echo "=========================="; \
|
|
||||||
if [ $$fail -ne 0 ]; then \
|
|
||||||
echo; \
|
|
||||||
$(MAKE) --no-print-directory report; \
|
|
||||||
fi; \
|
|
||||||
test $$fail -eq 0
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@rm -rf ./asicworld/*.out ./asicworld/*.log
|
@rm -rf ./asicworld/*.out ./asicworld/*.log
|
||||||
@rm -rf ./hana/*.out ./hana/*.log
|
@rm -rf ./hana/*.out ./hana/*.log
|
||||||
|
|
@ -134,12 +125,3 @@ clean:
|
||||||
@rm -f $(addsuffix /run-test.mk,$(MK_TEST_DIRS))
|
@rm -f $(addsuffix /run-test.mk,$(MK_TEST_DIRS))
|
||||||
@find . -name '*.result' -type f -exec rm -f {} +
|
@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 {} +
|
@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 "=========================="
|
|
||||||
|
|
|
||||||
43
tests/common.mk
Normal file
43
tests/common.mk
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
all:
|
||||||
|
|
||||||
|
ifndef OVERRIDE_MAIN
|
||||||
|
clean:
|
||||||
|
@rm -f *.log *.result
|
||||||
|
endif
|
||||||
|
|
||||||
|
define run_test
|
||||||
|
rc=0; \
|
||||||
|
$(2) || rc=$$?; \
|
||||||
|
if [ $$rc -eq 0 ]; then \
|
||||||
|
echo "PASS $1"; \
|
||||||
|
echo PASS > $1.result; \
|
||||||
|
else \
|
||||||
|
echo "FAIL $1"; \
|
||||||
|
echo FAIL > $1.result; \
|
||||||
|
fi
|
||||||
|
endef
|
||||||
|
|
||||||
|
.PHONY: summary
|
||||||
|
summary:
|
||||||
|
@pass=$$(find . -type f -name '*.result' -exec grep '^PASS$$' {} + | wc -l); \
|
||||||
|
fail=$$(find . -type f -name '*.result' -exec grep '^FAIL$$' {} + | wc -l); \
|
||||||
|
total=$$((pass + fail)); \
|
||||||
|
echo "=========================="; \
|
||||||
|
echo "Tests: $$total"; \
|
||||||
|
echo "Passed: $$pass"; \
|
||||||
|
echo "Failed: $$fail"; \
|
||||||
|
echo "=========================="; \
|
||||||
|
if [ $$fail -ne 0 ]; then \
|
||||||
|
echo; \
|
||||||
|
$(MAKE) --no-print-directory report; \
|
||||||
|
fi; \
|
||||||
|
test $$fail -eq 0
|
||||||
|
|
||||||
|
.PHONY: report
|
||||||
|
report:
|
||||||
|
@echo "=========================="
|
||||||
|
@echo "Failing tests:"
|
||||||
|
@find . -name '*.result' -type f -exec grep -H '^FAIL$$' {} + \
|
||||||
|
| cut -d: -f1 \
|
||||||
|
| sed 's|^\./||; s|\.result$$||'
|
||||||
|
@echo "=========================="
|
||||||
|
|
@ -5,7 +5,8 @@ import os
|
||||||
import sys
|
import sys
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
yosys_basedir = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
|
yosys_basedir = os.path.relpath(os.path.join(os.path.dirname(__file__), ".."))
|
||||||
|
common_mk = os.path.relpath(os.path.join(os.path.dirname(__file__), "common.mk"))
|
||||||
|
|
||||||
def _cwd_base():
|
def _cwd_base():
|
||||||
return os.path.basename(os.getcwd())
|
return os.path.basename(os.getcwd())
|
||||||
|
|
@ -50,20 +51,9 @@ def generate_tests(argv):
|
||||||
if not (args.yosys_scripts or args.tcl_scripts or args.prove_sv or args.bash):
|
if not (args.yosys_scripts or args.tcl_scripts or args.prove_sv or args.bash):
|
||||||
raise RuntimeError("No file types selected")
|
raise RuntimeError("No file types selected")
|
||||||
|
|
||||||
|
print(f"include {common_mk}")
|
||||||
print(f"YOSYS ?= {yosys_basedir}/yosys")
|
print(f"YOSYS ?= {yosys_basedir}/yosys")
|
||||||
print()
|
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(".PHONY: all")
|
||||||
print("all:")
|
print("all:")
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue