// test: ascii.exe -h
// test: ascii.exe -h | awk '/usage:/ { rc=1 } END { exit (1-rc) }'
-// test: ascii.exe -_ 2> /dev/null | awk 'END { if (NR == 0) { exit(0) } else exit (1) }'
+// test: ascii.exe -_ 2>/dev/null | awk 'END { if (NR == 0) { exit(0) } else exit (1) }'
+// test: ascii.exe error 2>&1 | grep -q 'invalid option'
// test: ascii.exe -_ 2>&1 | awk '/usage:/ { rc=1 } END { exit (1-rc) }'
// test: ascii.exe | awk '/ 64\[40\] @/ { rc=1 } END { exit (1-rc) }'
// test: ascii.exe | awk '/127\[7f\] DEL/ { rc=1 } END { exit (1-rc) }'
+// test: ascii.exe -v | grep -q version
// test: ascii.exe -c 4 | tail -1 | awk '/63/ { rc=1 } END { exit (1-rc) }'
// test: ascii.exe -c 5 | tail -1 | awk '/51/ { rc=1 } END { exit (1-rc) }'
// test: ascii.exe -c 6 | tail -1 | awk '/42/ { rc=1 } END { exit (1-rc) }'
+// test: ascii.exe -c 2>&1 | grep -q 'missing number of columns'
/* vim: set ts=4 sw=4 et: */
#OFLAGS += -malign-double
CFLAGS += -W -Wall -Wextra -g
CFLAGS += -std=c99 -D_XOPEN_SOURCE=500
-CFLAGS += $(OFLAGS) $(INCLUDES)
-LDFLAGS += -g
+CFLAGS += $(OFLAGS) $(INCLUDES) $(GCOV)
+LDFLAGS += -g $(GCOV)
# Targets
ALLEXE =
ALLEXE += ascii
-ALLEXE += skel
+#ALLEXE += skel
SHELL = bash
-MAKE = mingw32-make
+#MAKE = mingw32-make
MAKEFLAGS += -s
+include $(wildcard .makefile)
# Functions
all: depends
$(MAKE) $(ALLEXE:%=%.exe)
-alltests: all
- $(MAKE) $(addprefix test_,$(ALLEXE:%.exe=%))
-
-depends: $(patsubst %.c, %.d, $(wildcard *.c)) $(patsubst %, %.ld, $(ALLEXE))
-
count:
wc $(wildcard *.c *.h) $(MAKEFILE_LIST)
rm -f clean $(wildcard *.d *.ld *.log *.o *.test *~ .exec_*)
$(call PASS, SUCCESS)
+depends: $(patsubst %.c, %.d, $(wildcard *.c)) $(patsubst %, %.ld, $(ALLEXE))
+
+gcovs:
+ $(MAKE) $(addprefix gcov_,$(ALLEXE))
+
purge: clean
$(call TITLE, "Purging")
touch purge
- rm -f purge $(ALLEXE) $(shell [ -f .targets ] && { cat .targets | sort | uniq; echo .targets; })
+ rm -f purge $(ALLEXE:%=%.exe)
$(call PASS, SUCCESS)
+valgrinds:
+ $(MAKE) $(addprefix valgrind_,$(ALLEXE))
+
+wipe: purge
+ $(call TITLE, "Wiping")
+ touch wipe
+ rm -f wipe $(wildcard *.gcda *.gcno *.gcov)
+ $(call PASS, SUCCESS)
+
+tests: all
+ $(MAKE) $(addprefix test_,$(ALLEXE))
+
## Main rules
include $(wildcard *.d)
include $(wildcard *.ld)
+gcov_%:
+ $(MAKE) purge
+ GCOV="-fprofile-arcs -ftest-coverage -O0" $(MAKE)
+ $(MAKE) test_$(@:gcov_%=%)
+ gcov `sed -e 's/\.exe:/.c/;s/\.o/.c/g' $(@:gcov_%=%.ld)`
+ touch gcov
+ rm -f gcov $(wildcard *.gcda *.gcno)
+ $(MAKE) purge
+
%.test: %.c
$(call TITLE, "Building $@")
# awk '/\/\* *test:.*\*\// { sub(/^.*\/\* *test: */, ""); sub(/ *\*\/.*$$/, ""); print }' $< > $@
[ $$? -eq 0 ] && echo -e "\033[1;32mSUCCESS\033[0;0m" \
|| { echo -e "\033[1;31mFAILED\033[0;0m"; RC=1; }; \
done; \
- test "$$RC" -ne 1
+ test "$$RC" -ne 1
-valgrind_%: %
+valgrind_%: %.exe
VALGRIND="valgrind -v --leak-check=full --show-reachable=yes --log-fd=2"; \
export VALGRIND; \
- $(MAKE) test_$<
+ $(MAKE) $(@:valgrind_%=test_%)
%.d: %.c
$(call TITLE, "Building $@")
## Phony
-.PHONY: clean count purge
+.PHONY: all clean count depends gcovs purge tests
## Precious