• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# SPDX-License-Identifier: GPL-2.0
2
3include $(src)/scripts/utils.mk
4
5bdir:=$(obj)/utest
6
7TARGETS = $(bdir)/trace-utest
8
9OBJS =
10OBJS += trace-utest.o
11OBJS += tracecmd-utest.o
12
13LIBS += $(LIBTRACECMD_STATIC) -lcunit $(LIBTRACEEVENT_LDLAGS) $(LIBTRACEFS_LDLAGS)
14
15LIBS += $(ZLIB_LDLAGS) $(LIBZSTD_LDLAGS)
16
17OBJS := $(OBJS:%.o=$(bdir)/%.o)
18DEPS := $(OBJS:$(bdir)/%.o=$(bdir)/.%.d)
19
20VALGRIND = $(shell which valgrind)
21
22$(bdir):
23	@mkdir -p $(bdir)
24
25$(OBJS): | $(bdir)
26$(DEPS): | $(bdir)
27
28$(bdir)/trace-utest: $(OBJS) $(LIBTRACECMD_STATIC)
29	$(Q)$(do_app_build)
30
31$(bdir)/%.o: %.c
32	$(Q)$(call do_fpic_compile)
33
34$(DEPS): $(bdir)/.%.d: %.c
35	$(Q)$(CC) -M $(CPPFLAGS) $(CFLAGS) $< > $@
36	$(Q)$(CC) -M -MT $(bdir)/$*.o $(CPPFLAGS) $(CFLAGS) $< > $@
37
38$(OBJS): $(bdir)/%.o : $(bdir)/.%.d
39
40dep_includes := $(wildcard $(DEPS))
41
42test: $(TARGETS)
43
44test_mem: test
45ifeq (, $(VALGRIND))
46	$(error "No valgrind in $(PATH), cannot run memory test")
47endif
48ifneq ($(shell id -u), 0)
49	$(error "The memory test should be run as root, as it reuqires full access to tracefs")
50endif
51	CK_FORK=no $(VALGRIND) \
52		--show-leak-kinds=all --leak-resolution=high \
53		--leak-check=full --show-possibly-lost=yes \
54		--track-origins=yes -s \
55		$(bdir)/trace-utest
56
57clean:
58	$(RM) $(TARGETS) $(bdir)/*.o $(bdir)/.*.d
59