lib_LTLIBRARIES=libevdev.la
-AM_CPPFLAGS = $(GCC_CFLAGS) -I$(top_srcdir)/include -I$(top_srcdir)
+AM_CPPFLAGS = $(GCC_CFLAGS) $(GCOV_CFLAGS) -I$(top_srcdir)/include -I$(top_srcdir)
+AM_LDFLAGS = $(GCOV_LDFLAGS)
libevdev_la_SOURCES = \
libevdev.h \
../include/linux/uinput.h
libevdev_la_LDFLAGS = \
+ $(AM_LDFLAGS) \
-version-info $(LIBEVDEV_LT_VERSION) \
-Wl,--version-script="$(srcdir)/libevdev.sym" \
$(GNU_LD_FLAGS)
CLEANFILES = event-names.h
BUILT_SOURCES = event-names.h
+if GCOV_ENABLED
+CLEANFILES += *.gcno
+endif
test_static_link_LDFLAGS = $(AM_LDFLAGS) -static
check_local_deps =
-clean_local_deps =
if ENABLE_RUNTIME_TESTS
run_tests = test-libevdev test-kernel
TESTS = $(run_tests)
endif
-libevdev_sources = $(top_srcdir)/libevdev/libevdev.c \
- $(top_srcdir)/libevdev/libevdev.h \
- $(top_srcdir)/libevdev/libevdev-names.c \
- $(top_srcdir)/libevdev/libevdev-uinput.h \
- $(top_srcdir)/libevdev/libevdev-uinput.c \
- $(top_srcdir)/libevdev/libevdev-uinput-int.h \
- $(top_srcdir)/libevdev/libevdev-util.h \
- $(top_srcdir)/libevdev/libevdev-int.h
-common_sources = $(libevdev_sources) \
+common_sources = \
test-common-uinput.c \
test-common-uinput.h \
test-common.c \
test-uinput.c \
$(common_sources)
-test_libevdev_LDADD = $(CHECK_LIBS)
+test_libevdev_LDADD = $(CHECK_LIBS) $(top_builddir)/libevdev/libevdev.la
test_kernel_SOURCES = \
test-kernel.c \
$(common_sources)
test_kernel_CFLAGS = -I$(top_srcdir)
-test_kernel_LDADD = $(CHECK_LIBS)
+test_kernel_LDADD = $(CHECK_LIBS) $(top_builddir)/libevdev/libevdev.la
if HAVE_VALGRIND
VALGRIND_FLAGS=--leak-check=full \
endif
-EXTRA_DIST = valgrind.suppressions
+EXTRA_DIST = valgrind.suppressions generate-gcov-report.sh
if GCOV_ENABLED
-CLEANFILES = gcov-report.txt
-
-gcov-clean:
- @rm -f *.gcov
-
-gcov-report.txt: gcov-clean check-TESTS
- $(AM_V_GEN)(rm -rf $@; \
- echo "========== coverage report ========" >> $@; \
- for file in `find $(top_srcdir)/libevdev -name "*.c" -printf "%P\n"`; do \
- gcov $$file > /dev/null; \
- if test -f $$file.gcov; then \
- total=`grep -v " -:" $$file.gcov | wc -l`; \
- missing=`grep "#####" $$file.gcov | wc -l`; \
- hit=$$((total - missing)); \
- echo -e "$$file: total lines: $$total not tested: $$missing ($$((($$hit * 100)/$$total))%)"; \
- fi \
- done >> $@; \
- echo "========== =============== ========" >> $@; \
- )
+CLEANFILES = gcov-reports/*.gcov gcov-reports/summary.txt *.gcno *.gcda
+
+gcov-report: generate-gcov-report.sh check-TESTS
+ $(AM_V_GEN)$(srcdir)/generate-gcov-report.sh gcov-reports $(top_builddir)/libevdev $(builddir)
-gcov: gcov-report.txt
- @cat gcov-report.txt
+gcov: gcov-report
+ @cat gcov-reports/summary.txt
check_local_deps += gcov
-clean_local_deps += gcov-clean
else
gcov:
@true
-gcov-clean:
- @true
endif # GCOV_ENABLED
-.PHONY: gcov gcov-clean gcov-report.txt
+.PHONY: gcov gcov-clean gcov-report
endif # ENABLE_RUNTIME_TESTS
check-local: $(check_local_deps)
-clean-local: $(clean_local_deps)
- rm -f *.gcno *.gcda
--- /dev/null
+#!/bin/bash -e
+
+if [[ $# -lt 2 ]]; then
+ echo "Usage: ./generate-gcov-report.sh <rel-target-dir> <srcdir> [<srcdir> ... ]"
+ exit 1
+fi
+
+target_dir=$1
+shift
+source_dirs=$*
+
+if [[ "${target_dir:0:1}" != '/' ]]; then
+ target_dir="$PWD/$target_dir"
+fi
+summary_file="$target_dir/summary.txt"
+
+mkdir -p "$target_dir"
+rm -f "$target_dir"/*.gcov
+
+for dir in $source_dirs; do
+ pushd "$dir" > /dev/null
+ for file in *.c; do
+ find ./ -name "*${file/\.c/.gcda}" -exec gcov {} \; > /dev/null
+ done
+ find ./ -name "*.gcov" \! -path "*/`basename "$target_dir"`/*" -exec mv {} "$target_dir" \;
+ popd > /dev/null
+done
+
+echo "========== coverage report ========" > "$summary_file"
+for file in "$target_dir"/*.gcov; do
+ total=`grep -v " -:" "$file" | wc -l`
+ missing=`grep "#####" "$file" | wc -l`
+ hit=$((total - missing));
+ percent=$((($hit * 100)/$total))
+ fname=`basename "$file"`
+ printf "%-32s total lines: %4s not tested: %4s (%3s%%)\n" "$fname" "$total" "$missing" "$percent">> "$summary_file"
+done
+echo "========== =============== ========" >> "$summary_file"