A previous patch changed the way tests are run by piping the output into sed to indent the output. This broke checking the return code of the test because the return code is really that of sed. Fix this by taking a dependecy on bash and using PIPESTATUS to get the return code fo the test.
99 lines
2.1 KiB
Makefile
99 lines
2.1 KiB
Makefile
CONFIG = config.mak
|
|
|
|
include $(CONFIG)
|
|
|
|
CONFIGURE = $(SRC_DIR)/
|
|
|
|
COV_DIR=$(OUT)/coverage/
|
|
APP_DIR=$(SRC_DIR)/apps/
|
|
CC=gcc
|
|
SHELL=/bin/bash
|
|
|
|
CCFLAGS = -Wall -Werror
|
|
CCFLAGS += -std=c99 -D_POSIX_C_SOURCE=200809L
|
|
CCFLAGS += -I$(SRC_DIR)
|
|
|
|
CCFLAGS += -I/usr/include/glib-2.0/ -I/usr/lib/x86_64-linux-gnu/glib-2.0/include
|
|
LDFLAGS += -lglib-2.0
|
|
|
|
CCFLAGS += $(CCFLAGS_EXTRA)
|
|
LDFLAGS += $(LDFLAGS_EXTRA)
|
|
|
|
C_SOURCES = $(shell find $(SRC_DIR) -name "*.c")
|
|
ALL_OBJS = $(patsubst $(SRC_DIR)/%.c, $(OUT)/%.o, $(C_SOURCES))
|
|
APP_OBJS = $(filter $(OUT)/apps/%, $(ALL_OBJS))
|
|
TEST_OBJS = $(filter $(OUT)%test.o, $(ALL_OBJS))
|
|
OBJS = $(filter-out $(TEST_OBJS) $(APP_OBJS), $(ALL_OBJS))
|
|
APPS = $(patsubst %.o, %, $(APP_OBJS))
|
|
|
|
.PHONY: all
|
|
all: gbdb gbasm tests
|
|
|
|
.PHONY: gbdb gbasm
|
|
gbdb: $(OUT)/apps/gbdb
|
|
gbasm: $(OUT)/apps/gbasm
|
|
|
|
.PHONY: gbasm-test tests
|
|
|
|
TESTS = $(patsubst %.o, %, $(filter %/test.o, $(ALL_OBJS)))
|
|
tests: $(TESTS)
|
|
|
|
$(ALL_APPS) $(ALL_OBJS): $(CONFIG)
|
|
|
|
$(OUT)/%.o: $(SRC_DIR)/%.c $(CONFIG)
|
|
@echo " CC $@"
|
|
@$(shell mkdir -p $(@D))
|
|
@$(CC) -c $(CCFLAGS) -o $@ $<
|
|
|
|
|
|
.SECONDEXPANSION:
|
|
$(APPS) $(TESTS): $(OBJS) $$@.o
|
|
@echo " LD $@"
|
|
@$(shell mkdir -p $(@D))
|
|
@$(CC) $^ $(LDFLAGS) -o $@
|
|
|
|
|
|
.PHONY: check cov-report
|
|
|
|
define run_tests =
|
|
@for i in $(TESTS); do \
|
|
echo " TEST $$i"; \
|
|
$$i | sed 's/^/ /'; \
|
|
if [ $${PIPESTATUS[0]} -ne 0 ]; then \
|
|
exit 1; \
|
|
fi; \
|
|
done;
|
|
endef
|
|
|
|
.PHONY: check coverage coverage-report
|
|
check: $(TESTS)
|
|
$(run_tests)
|
|
|
|
COV_BASE=$(COV_DIR)/cov_base.info
|
|
.PHONY: $(COV_BASE)
|
|
$(COV_BASE):
|
|
@mkdir -p $(COV_DIR)
|
|
@lcov -q -c -i -d $(OUT) -o $(COV_BASE)
|
|
|
|
$(COV_DIR)/coverage.info coverage: $(TESTS) $(COV_BASE)
|
|
$(call run_tests)
|
|
@lcov -q -c -d $(OUT) -o $(COV_DIR)results.info -t results
|
|
@lcov -q -a $(COV_DIR)results.info -o $(COV_DIR)coverage.info
|
|
@lcov --summary $(COV_DIR)coverage.info
|
|
|
|
coverage-report: coverage
|
|
@mkdir -p $(COV_DIR)/html/
|
|
@genhtml -q --prefix $(PWD) --output-directory=$(COV_DIR)/html $(COV_DIR)/coverage.info
|
|
|
|
.PHONY: clean realclean cov-clean
|
|
|
|
cov-clean:
|
|
@find $(OUT)/ \( -iname *.gcno -o -iname *.gcda \) -delete
|
|
@rm -rf $(COV_DIR)
|
|
|
|
clean: cov-clean
|
|
@rm -f $(ALL_OBJS) $(APPS) $(TESTS)
|
|
|
|
realclean: clean
|
|
@rm -f $(CONFIG)
|