Update struct input_event
[platform/upstream/libevdev.git] / test / Makefile.am
1 build_tests = test-compile-pedantic test-link
2
3 if ENABLE_STATIC_LINK_TEST
4 build_tests += test-static-link
5 endif
6
7 noinst_PROGRAMS = $(build_tests)
8
9 AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/include -I$(top_builddir)/libevdev
10 AM_LDFLAGS =
11
12 test_compile_pedantic_SOURCES = test-compile-pedantic.c
13 test_compile_pedantic_CFLAGS = $(AM_CPPFLAGS) -pedantic -Werror -std=c89
14
15 test_link_SOURCES = test-link.c
16 test_link_CFLAGS = -I$(top_srcdir)
17 test_link_LDADD = $(top_builddir)/libevdev/libevdev.la
18
19 test_static_link_SOURCES = test-link.c
20 test_static_link_CFLAGS = -I$(top_srcdir)
21 test_static_link_LDADD = $(top_builddir)/libevdev/libevdev.la
22 test_static_link_LDFLAGS = $(AM_LDFLAGS) -static
23
24 check_local_deps =
25
26 if ENABLE_RUNTIME_TESTS
27 run_tests = test-libevdev test-kernel
28
29 .NOTPARALLEL:
30
31 noinst_PROGRAMS += $(run_tests)
32
33 if RUN_TESTS
34 TESTS = $(run_tests)
35 endif
36
37 common_sources = \
38                  test-common-uinput.c \
39                  test-common-uinput.h \
40                  test-common.c \
41                  test-common.h
42
43 # include builddir for event-names.h
44 AM_CPPFLAGS += $(CHECK_CFLAGS) $(GCOV_CFLAGS)
45 AM_LDFLAGS += $(GCOV_LDFLAGS)
46
47 test_libevdev_SOURCES = \
48                         test-main.c \
49                         test-event-names.c \
50                         test-event-codes.c \
51                         test-libevdev-init.c \
52                         test-libevdev-has-event.c \
53                         test-int-queue.c \
54                         test-libevdev-events.c \
55                         test-uinput.c \
56                         $(common_sources)
57
58 test_libevdev_LDADD = $(CHECK_LIBS) $(top_builddir)/libevdev/libevdev.la
59 test_libevdev_LDFLAGS = -no-install
60
61 test_kernel_SOURCES = \
62                       test-kernel.c \
63                       $(common_sources)
64 test_kernel_CFLAGS = -I$(top_srcdir)
65 test_kernel_LDADD = $(CHECK_LIBS) $(top_builddir)/libevdev/libevdev.la
66
67 if HAVE_VALGRIND
68 VALGRIND_FLAGS=--leak-check=full \
69                 --quiet \
70                 --error-exitcode=3 \
71                 --suppressions=$(srcdir)/valgrind.suppressions
72
73 valgrind:
74                 $(MAKE) check-TESTS LOG_COMPILER="$(VALGRIND)" LOG_FLAGS="$(VALGRIND_FLAGS)"
75
76 check_local_deps += valgrind
77
78 endif
79
80 EXTRA_DIST = valgrind.suppressions  generate-gcov-report.sh
81
82 if GCOV_ENABLED
83
84 CLEANFILES = gcov-reports/*.gcov gcov-reports/summary.txt *.gcno *.gcda
85
86 gcov-report: generate-gcov-report.sh check-TESTS
87         $(AM_V_GEN)$(srcdir)/generate-gcov-report.sh gcov-reports $(top_builddir)/libevdev $(builddir)
88
89 gcov: gcov-report
90         @cat gcov-reports/summary.txt
91
92 check_local_deps += gcov
93
94 else
95
96 gcov-report.txt:
97         @true
98
99 gcov:
100         @true
101
102
103 endif # GCOV_ENABLED
104
105 .PHONY: gcov gcov-clean gcov-report
106
107 endif # ENABLE_RUNTIME_TESTS
108
109 if ENABLE_STATIC_SYMBOL_LEAKS_TEST
110 # Hack to check for leaking symbols in the static library.
111 # See https://bugs.freedesktop.org/show_bug.cgi?id=82785
112 # Note the spaces in the expressions! After the first grep, each line
113 # is " T symbol_name"
114 static-symbol-leaks: test-static-link
115         $(AM_V_GEN)(\
116                 $(NM) --extern-only $(builddir)/test-static-link | \
117                         grep -o -e " T .*" | \
118                         grep -v -e " main$$" \
119                                 -e " atexit" \
120                                 -e " *gcov.*" \
121                                 -e " _.*" \
122                                 -e " libevdev_*" && \
123                                 echo "Leaking symbols found" && \
124                                 exit 1 || exit 0 \
125         )
126
127 check_local_deps += static-symbol-leaks
128 endif # HAVE_NM
129
130 check-local: $(check_local_deps)
131