tizen 2.4 release
[framework/uifw/libevdev.git] / test / Makefile.am
1 if BUILD_TESTS
2 run_tests = test-libevdev test-kernel
3 build_tests = test-compile-pedantic test-link
4
5 .NOTPARALLEL:
6
7 noinst_PROGRAMS = $(run_tests) $(build_tests)
8
9 TESTS = $(run_tests)
10
11 libevdev_sources = $(top_srcdir)/libevdev/libevdev.c \
12                    $(top_srcdir)/libevdev/libevdev.h \
13                    $(top_srcdir)/libevdev/libevdev-names.c \
14                    $(top_srcdir)/libevdev/libevdev-uinput.h \
15                    $(top_srcdir)/libevdev/libevdev-uinput.c \
16                    $(top_srcdir)/libevdev/libevdev-uinput-int.h \
17                    $(top_srcdir)/libevdev/libevdev-util.h \
18                    $(top_srcdir)/libevdev/libevdev-int.h
19 common_sources = $(libevdev_sources) \
20                  test-common-uinput.c \
21                  test-common-uinput.h \
22                  test-common.c \
23                  test-common.h
24
25 # include builddir for event-names.h
26 AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/include -I$(top_builddir)/libevdev $(CHECK_CFLAGS) $(GCOV_CFLAGS)
27
28 test_libevdev_SOURCES = \
29                         test-main.c \
30                         test-event-names.c \
31                         test-event-codes.c \
32                         test-libevdev-init.c \
33                         test-libevdev-has-event.c \
34                         test-int-queue.c \
35                         test-libevdev-events.c \
36                         test-uinput.c \
37                         $(common_sources)
38
39 test_libevdev_LDADD =  $(CHECK_LIBS) $(GCOV_LDFLAGS)
40
41 test_compile_pedantic_SOURCES = test-compile-pedantic.c
42 test_compile_pedantic_CFLAGS = $(AM_CPPFLAGS) -pedantic -Werror -std=c90
43
44 test_link_SOURCES = test-link.c
45 test_link_CFLAGS = -I$(top_srcdir)
46 test_link_LDADD = $(top_builddir)/libevdev/libevdev.la
47
48 test_kernel_SOURCES = \
49                       test-kernel.c \
50                       $(common_sources)
51 test_kernel_CFLAGS = -I$(top_srcdir)
52 test_kernel_LDADD = $(CHECK_LIBS)
53
54 if HAVE_VALGRIND
55 VALGRIND_FLAGS=--leak-check=full \
56                 --quiet \
57                 --error-exitcode=3 \
58                 --suppressions=$(srcdir)/valgrind.suppressions
59
60 valgrind:
61                 $(MAKE) check-TESTS LOG_COMPILER="$(VALGRIND)" LOG_FLAGS="$(VALGRIND_FLAGS)"
62
63 check: valgrind
64
65 endif
66
67 EXTRA_DIST = valgrind.suppressions
68
69 if GCOV_ENABLED
70
71 CLEANFILES = gcov-report.txt
72
73 gcov-clean:
74         @rm -f *.gcov
75
76 gcov-report.txt: gcov-clean check-TESTS
77         $(AM_V_GEN)(rm -rf $@; \
78                 echo "========== coverage report ========" >> $@; \
79                 for file in `find $(top_srcdir)/libevdev -name "*.c" -printf "%P\n"`; do \
80                         gcov $$file > /dev/null; \
81                         if test -f $$file.gcov; then \
82                                 total=`grep -v " -:" $$file.gcov | wc -l`; \
83                                 missing=`grep "#####" $$file.gcov | wc -l`; \
84                                 hit=$$((total - missing)); \
85                                 echo -e "$$file: total lines: $$total not tested: $$missing ($$((($$hit * 100)/$$total))%)"; \
86                         fi \
87                 done >> $@; \
88                 echo "========== =============== ========" >> $@; \
89         )
90
91 gcov: gcov-report.txt
92         @cat gcov-report.txt
93
94 check-local: gcov
95
96 else
97
98 gcov-report.txt:
99         @true
100
101 gcov:
102         @true
103
104 gcov-clean:
105         @true
106
107 endif
108
109 .PHONY: gcov gcov-clean gcov-report.txt
110
111 clean-local: gcov-clean
112         rm -f *.gcno *.gcda
113
114 endif