Add make test rule.

This commit is contained in:
Ian Gulliver
2016-02-27 22:44:19 -08:00
parent 4414337f2e
commit 86a3a64be6

View File

@@ -4,6 +4,12 @@ CFLAGS ?= -Weverything -Werror -O3 -g --std=gnu11 --pedantic-errors -fPIE -fstac
LDFLAGS ?= $(CFLAGS) -Wl,-z,relro -Wl,-z,now -pie
LIBS ?= -ljansson -lprotobuf-c
TESTCASE_DIR ?= testcase
TESTOUT_DIR ?= testout
VALGRIND ?= valgrind
VALGRIND_FLAGS ?= --error-exitcode=1 --track-fds=yes --show-leak-kinds=all --leak-check=full
ADSBUS_TEST_FLAGS ?= --stdin --stdout=airspy_adsb --stdout=beast --stdout=json --stdout=proto --stdout=raw --stdout=stats
OBJ_NETWORK = incoming.o outgoing.o receive.o send.o
OBJ_PROTOCOL = airspy_adsb.o beast.o json.o proto.o raw.o stats.o
OBJ_UTIL = buf.o hex.o list.o opts.o packet.o peer.o rand.o resolve.o server.o socket.o uuid.o wakeup.o
@@ -12,7 +18,7 @@ OBJ_PROTO = adsb.pb-c.o
all: adsbus
clean:
rm -f *.o adsbus
rm -f *.o adsbus testout/*
%.o: %.c *.h
$(COMP) -c $(CFLAGS) $< -o $@
@@ -28,3 +34,8 @@ fuzz:
$(MAKE) clean
COMP=afl-clang $(MAKE) adsbus
afl-fuzz -i testcase/ -o findings/ ./adsbus --stdin --stdout=airspy_adsb --stdout=beast --stdout=json --stdout=proto --stdout=raw --stdout=stats
$(TESTOUT_DIR)/%: $(TESTCASE_DIR)/% adsbus
$(VALGRIND) $(VALGRIND_FLAGS) ./adsbus $(ADSBUS_TEST_FLAGS) >/dev/null 2>$@ < $<
test: $(patsubst $(TESTCASE_DIR)/%,$(TESTOUT_DIR)/%,$(wildcard $(TESTCASE_DIR)/*))