From 5cbb0c91a4ff81d989218afdf8b62f2e70df78d2 Mon Sep 17 00:00:00 2001 From: Bernhard Nortmann Date: Fri, 3 Jun 2016 10:03:37 +0200 Subject: [PATCH] tests: Introduce a basic testing framework All tests should go into the new "tests" subdirectory. The idea is that the separate Makefile in that directory will get invoked via a top-level "make check". The tests/Makefile should then take care of running all available tests, returning an appropriate exit status. Future tests may be functional, examine code metrics (coverage analysis), or both. For a start, I'd simply like to check that sunxi-fexc is able to properly compile all the .fex files from linux-sunxi/sunxi-boards. (Note: This currently FAILS and will probably require adjustments to both sunxi-tools and the .fex repository. To work around this, for now I'm applying patches to fix sunxi-boards.) Signed-off-by: Bernhard Nortmann --- Makefile | 5 +++ tests/Makefile | 24 ++++++++++++++ tests/fextest.sh | 8 +++++ tests/patches/a-star_kv49l.patch | 55 ++++++++++++++++++++++++++++++++ tests/test_all_fex.sh | 7 ++++ 5 files changed, 99 insertions(+) create mode 100644 tests/Makefile create mode 100755 tests/fextest.sh create mode 100644 tests/patches/a-star_kv49l.patch create mode 100755 tests/test_all_fex.sh diff --git a/Makefile b/Makefile index 65bdcdc..75fc27b 100644 --- a/Makefile +++ b/Makefile @@ -58,6 +58,7 @@ PREFIX ?= /usr/local BINDIR ?= $(PREFIX)/bin .PHONY: all clean tools target-tools install install-tools install-target-tools +.PHONY: check tools: $(TOOLS) $(FEXC_LINKS) target-tools: $(TARGET_TOOLS) @@ -94,6 +95,7 @@ install-misc: $(MISC_TOOLS) clean: + make -C tests/ clean @rm -vf $(TOOLS) $(FEXC_LINKS) $(TARGET_TOOLS) $(MISC_TOOLS) @rm -vf version.h *.o *.elf *.sunxi *.bin *.nm *.orig @@ -186,3 +188,6 @@ version.h: @for x in $(TOOLS) $(FEXC_LINKS) $(TARGET_TOOLS) version.h '*.o' '*.swp'; do \ echo "$$x"; \ done | sort -V > $@ + +check: $(FEXC_LINKS) + make -C tests/ diff --git a/tests/Makefile b/tests/Makefile new file mode 100644 index 0000000..de9960c --- /dev/null +++ b/tests/Makefile @@ -0,0 +1,24 @@ +# +# tests/Makefile +# + +BOARDS_URL := https://github.com/linux-sunxi/sunxi-boards/archive/master.zip +BOARDS_DIR := sunxi-boards + +check: check_all_fex + +check_all_fex: $(BOARDS_DIR)/README + ./test_all_fex.sh $(BOARDS_DIR) + +# Retrieve and extract sunxi-boards archive (containing all .fex) +$(BOARDS_DIR).zip: + curl -fLsS -o $@ $(BOARDS_URL) +$(BOARDS_DIR)/README: $(BOARDS_DIR).zip + @echo Extracting $< ... + unzip -q $< + mv sunxi-boards-master $(BOARDS_DIR) + touch -r $(BOARDS_DIR) $< + cat patches/*.patch | patch -p1 + +clean: + rm -rf $(BOARDS_DIR).zip $(BOARDS_DIR) diff --git a/tests/fextest.sh b/tests/fextest.sh new file mode 100755 index 0000000..05f7b82 --- /dev/null +++ b/tests/fextest.sh @@ -0,0 +1,8 @@ +#!/bin/bash +echo $0 $* +FEX2BIN=../fex2bin +BIN2FEX=../bin2fex +FEX=$1 +BIN=${FEX/%.fex/.bin} +REVERSE=${FEX/%.fex/.new} +${FEX2BIN} ${FEX} ${BIN} diff --git a/tests/patches/a-star_kv49l.patch b/tests/patches/a-star_kv49l.patch new file mode 100644 index 0000000..799ae1a --- /dev/null +++ b/tests/patches/a-star_kv49l.patch @@ -0,0 +1,55 @@ +See https://github.com/linux-sunxi/sunxi-boards/issues/51 + +--- orig/sunxi-boards/sys_config/a33/a-star_kv49l.fex ++++ new/sunxi-boards/sys_config/a33/a-star_kv49l.fex +@@ -830,25 +830,25 @@ + + [Vdevice] + Vdevice_used = 0 +-Vdevice_0 = port:P@00<0><0><0><0> +-Vdevice_1 = port:P@00<0><0><0><0> ++;Vdevice_0 = port:P@00<0><0><0><0> ++;Vdevice_1 = port:P@00<0><0><0><0> + + [s_uart0] + s_uart_used = 0 +-s_uart_tx = port:P@00<0><0><0><0> +-s_uart_rx = port:P@00<0><0><0><0> ++;s_uart_tx = port:P@00<0><0><0><0> ++;s_uart_rx = port:P@00<0><0><0><0> + + [s_rsb0] + s_rsb_used = 0 +-s_rsb_sck = port:P@00<0><0><0><0> +-s_rsb_sda = port:P@00<0><0><0><0> ++;s_rsb_sck = port:P@00<0><0><0><0> ++;s_rsb_sda = port:P@00<0><0><0><0> + + [s_jtag0] + s_jtag_used = 0 +-s_jtag_tms = port:P@00<0><0><0><0> +-s_jtag_tck = port:P@00<0><0><0><0> +-s_jtag_tdo = port:P@00<0><0><0><0> +-s_jtag_tdi = port:P@00<0><0><0><0> ++;s_jtag_tms = port:P@00<0><0><0><0> ++;s_jtag_tck = port:P@00<0><0><0><0> ++;s_jtag_tdo = port:P@00<0><0><0><0> ++;s_jtag_tdi = port:P@00<0><0><0><0> + + [s_powchk] + s_powchk_used = 0 +@@ -875,9 +875,9 @@ + + [leds_para] + leds_used = 0 +-;red_led = port:P@00<0><0><0><0> +-;red_led_active_low = 0 +-;green_led_active_low = 0 +-;blue_led = +-;blue_led_active_low = 0 ++;red_led = port:P@00<0><0><0><0> ++;red_led_active_low = 0 ++;green_led_active_low = 0 ++;blue_led = ++;blue_led_active_low = 0 + diff --git a/tests/test_all_fex.sh b/tests/test_all_fex.sh new file mode 100755 index 0000000..f22325e --- /dev/null +++ b/tests/test_all_fex.sh @@ -0,0 +1,7 @@ +#!/bin/sh +FEXFILES=fexfiles.lst +find $1 -name '*.fex' > ${FEXFILES} +while read fex; do + ./fextest.sh ${fex} || exit +done <${FEXFILES} +rm -f ${FEXFILES}