Add tools test

Signed-off-by: Tomasz Michalak <tmichalak@antmicro.com>
This commit is contained in:
Tomasz Michalak 2020-11-18 15:01:31 +01:00
parent 5b7d782737
commit f283ac921b
3 changed files with 51 additions and 3 deletions

View File

@ -61,7 +61,10 @@ test-cpp:
cd build && ctest --no-compress-output -T Test -C RelWithDebInfo --output-on-failure
xsltproc .github/kokoro/ctest2junit.xsl build/Testing/*/Test.xml > build/cpp_test_results.xml
.PHONY: test test-py test-cpp
test-tools:
$(MAKE) -f Makefile.tools_tests
.PHONY: test test-py test-cpp test-tools
# Run HTML test
# ------------------------
@ -73,7 +76,7 @@ test-htmlgen:
# Auto formatting of code.
# ------------------------
FORMAT_EXCLUDE = $(foreach x,$(ALL_EXCLUDE),-and -not -path './$(x)/*') -and -not -name *.bit
FORMAT_EXCLUDE = $(foreach x,$(ALL_EXCLUDE),-and -not -path './$(x)/*') -and -not -name *.bit -and -not -name *.tar.gz
CLANG_FORMAT ?= clang-format-5.0
format-cpp:
@ -100,7 +103,7 @@ WS_CMD = sed -i '\''s@\s\+$$@@g'\''
# xargs later) is a file, and not a directory or link. Also filters out .bit
# files as these are the only binary files currently tracked by Git and we don't
# want to inadvertently change these at all.
WS_FILTER = [ -f {} -a ! -L {} ] && [[ {} != *.bit ]]
WS_FILTER = [ -f {} -a ! -L {} ] && [[ {} != *.bit ]] && [[ {} != *.tar.gz ]]
# For every file piped to $(WS_FORMAT) apply the filter and perform the command,
# if a file does not match the filter, just returns true.

45
Makefile.tools_tests Normal file
View File

@ -0,0 +1,45 @@
SHELL=/bin/bash
BITREAD = build/tools/bitread
BITS2RBT = build/tools/bits2rbt/bits2rbt
TEST_DATA_PATH = lib/test_data
#FIXME Uncomment bits2rbt_bram_xc7 once https://github.com/SymbiFlow/prjxray/issues/1285 is fixed
BITS2RBT_TESTS = bits2rbt_xc7 bits2rbt_bram_xc7
TESTS = $(BITS2RBT_TESTS)
bits2rbt_xc7_ARGS_1 = -part_file build/Series7/part.yaml -architecture Series7 -y -o build/xc7.bits -aux build/xc7.aux build/Series7/design.bit
bits2rbt_xc7_ARGS_2 = -arch Series7 -aux build/xc7.aux -o build/xc7.rbt build/xc7.bits
bits2rbt_xc7_TEST = diff <(tail -n +8 build/Series7/design.rbt) <(tail -n +8 build/xc7.rbt)
bits2rbt_bram_xc7_ARGS_1 = -part_file build/Series7/part.yaml -architecture Series7 -y -o build/bram_xc7.bits -aux build/bram_xc7.aux build/Series7/bram.bit
bits2rbt_bram_xc7_ARGS_2 = -arch Series7 -aux build/bram_xc7.aux -o build/bram_xc7.rbt build/bram_xc7.bits
bits2rbt_bram_xc7_TEST = diff <(tail -n +8 build/Series7/bram.rbt) <(tail -n +8 build/bram_xc7.rbt)
all: $(TESTS)
test_data: $(TEST_DATA_PATH)/ToolsTestData.tar.gz
@echo "Unpacking test data"
tar -zxf $< -C build
define bitread_test_tpl =
$(1): $(2) $(3) test_data
@echo "Started test $(1)"
$(2) $$($(1)_ARGS_1) > /dev/null && $(3) $$($(1)_ARGS_2) > /dev/null && $$($(1)_TEST); \
RETVAL=$$$$? ; \
if [ $$$$RETVAL -eq 0 ]; then \
echo "$(1) PASS"; \
true; \
else \
echo "$(1) FAIL"; \
false; \
fi
$(1)_clean:
rm -rf build/*.frm build/*.aux build/*.bits build/*.rbt
endef
$(foreach test,$(BITS2RBT_TESTS),$(eval $(call bitread_test_tpl,$(test),$(BITREAD),$(BITS2RBT))))
clean: $(foreach test,$(TESTS),$(test)_clean)
@true

Binary file not shown.