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 <bernhard.nortmann@web.de>
This commit is contained in:
Bernhard Nortmann 2016-06-03 10:03:37 +02:00
parent dc1b5889c3
commit 5cbb0c91a4
5 changed files with 99 additions and 0 deletions

View File

@ -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/

24
tests/Makefile Normal file
View File

@ -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)

8
tests/fextest.sh Executable file
View File

@ -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}

View File

@ -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

7
tests/test_all_fex.sh Executable file
View File

@ -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}