0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2025-03-11 17:08:46 +00:00

Birdtest: Customize Makefiles build system

From root dir is possible launch:
  $ make check         # for re-build and run all tests
  $ make build-tests   # for re-build all tests only
This commit is contained in:
Pavel Tvrdík 2015-03-13 18:23:31 +01:00
parent 02a844cbf9
commit 56fe8bc26c
5 changed files with 39 additions and 19 deletions

View File

@ -1,5 +1,7 @@
source=cf-parse.tab.c cf-lex.c conf.c
root-rel=../
dir-name=conf
dynamic-dir=1
include ../Rules

View File

@ -3,12 +3,30 @@
objdir=@objdir@
all depend tags install install-docs check:
all depend tags install install-docs build-tests:
$(MAKE) -C $(objdir) $@
docs userdocs progdocs:
$(MAKE) -C doc $@
check: build-tests
@all_tests=( `find . -name '*_test' -executable` ) ; \
test_num=1 ; \
num_succ_tests=0 ; \
num_fail_tests=0 ; \
echo -e "\n== Start all $${#all_tests[@]} unit tests ==\n" ; \
for test in "$${all_tests[@]}" ; do \
echo -e "=[$$((test_num++))/$${#all_tests[@]}]= $$test" ; \
./$$test \
&& num_succ_tests=$$((num_succ_tests+1)) \
|| num_fail_tests=$$((num_fail_tests+1)) ; \
done ; \
echo "" ; \
echo "------------------------------" ; \
echo " Success: $$num_succ_tests" ; \
echo " Failure: $$num_fail_tests" ; \
echo "------------------------------"
clean:
$(MAKE) -C $(objdir) clean
find . -name "*~" -or -name "*.[oa]" -or -name "\#*\#" -or -name TAGS -or -name core -or -name depend -or -name ".#*" | xargs rm -f

View File

@ -7,12 +7,9 @@ include Rules
all: sysdep/paths.h .dep-stamp subdir daemon birdcl @CLIENT@
check: build-tests
find . -name '*_test' -executable -exec {} \;
build-tests: subdir birdtest/birdtest.a
set -e ; for a in $(dynamic-dirs) ; do $(MAKE) -C $$a build-test ; done
set -e ; for a in $(static-dirs) $(client-dirs) ; do $(MAKE) -C $$a -f $(srcdir_abs)/$$a/Makefile build-test ; done
build-tests: birdtest/birdtest.a
set -e ; for a in $(dynamic-dirs) ; do $(MAKE) -C $$a $@ ; done
set -e ; for a in $(static-dirs) $(client-dirs) ; do $(MAKE) -C $$a -f $(srcdir_abs)/$$a/Makefile $@ ; done
birdtest/birdtest.a: birdtest/birdtest.o
$(AR) rcs $@ $^

View File

@ -41,25 +41,26 @@ sysconfdir=@sysconfdir@
localstatedir=@localstatedir@
docdir=@prefix@/doc
test-src-path := $(srcdir)/$(dir-name)/
build-tests:
@for i in `find $(test-src-path) -name '*_test.c'` ; do \
testname=`basename $$i .c` ; \
testobj=$${testname}.o ; \
$(CC) $(CFLAGS) -I $(srcdir)/birdtest/ -o $$testobj -c $$i && \
$(CC) $(LDFLAGS) $$testobj -o $$testname $(root-rel)birdtest/birdtest.a || \
rm -rf $$testname ; \
done
ifdef source
objs := $(subst .c,.o,$(source))
ifdef dir-name
ifndef dynamic-dir
src-path := $(srcdir)/$(dir-name)/
endif
build-test:
for i in $(source); do \
test_name=`echo $$i | sed 's/\.c$$/_test/g'` ; \
test_source=$(src-path)$${test_name}.c ; \
test_obj=$${test_name}.o ; \
if [ -f $$test_source ]; then \
$(CC) $(CFLAGS) -I $(srcdir)/birdtest/ -o $$test_obj -c $$test_source ; \
$(CC) $(LDFLAGS) $$test_obj -o $$test_name $(root-rel)birdtest/birdtest.a ; \
fi ; \
done
all:
cd $(root-rel) && make

View File

@ -52,6 +52,8 @@ cat >$LIBDIR/Makefile <<EOF
source=$SRCS
lib-dest=birdlib.a
root-rel=../
dir-name=lib
dynamic-dir=1
include ../Rules
EOF