blob: a32eea6f7ec376213ec5c65208c4718639eb9523 [file] [log] [blame]
Kyriakos Ispoglouf00a0db2020-02-06 16:41:49 -08001# -----------------------------------------------------------------
2# Make target for line coverage. This target generates a zip file
3# called `line_coverage_profiles.zip` that contains a large set of
4# zip files one for each fuzz target/critical component. Each zip
5# file contains a set of profile files (*.gcno) that we will use
6# to generate line coverage reports. Furthermore, target compiles
7# all fuzz targets with line coverage instrumentation enabled and
8# packs them into another zip file called `line_coverage_profiles.zip`.
9#
10# To run the make target set the coverage related envvars first:
11# NATIVE_LINE_COVERAGE=true NATIVE_COVERAGE=true \
12# COVERAGE_PATHS=* make haiku-line-coverage
13# -----------------------------------------------------------------
14
15# TODO(b/148306195): Due this issue some fuzz targets cannot be built with
16# line coverage instrumentation. For now we just blacklist them.
17blacklisted_fuzz_targets := libneuralnetworks_fuzzer
18
19fuzz_targets := $(ALL_FUZZ_TARGETS)
20fuzz_targets := $(filter-out $(blacklisted_fuzz_targets),$(fuzz_targets))
21
22
23# Android components that considered critical.
24# Please note that adding/Removing critical components is very rare.
25critical_components_static := \
26 lib-bt-packets \
27 libbt-stack \
28 libffi \
29 libhevcdec \
30 libhevcenc \
31 libmpeg2dec \
32 libosi \
33 libpdx \
34 libselinux \
35 libvold \
36 libyuv
37
38critical_components_shared := \
39 libaudioprocessing \
40 libbinder \
41 libbluetooth_gd \
42 libbrillo \
43 libcameraservice \
44 libcurl \
45 libhardware \
46 libinputflinger \
47 libopus \
48 libstagefright \
49 libunwind \
50 libvixl
51
52# Use the intermediates directory to avoid installing libraries to the device.
53intermediates := $(call intermediates-dir-for,PACKAGING,haiku-line-coverage)
54
55
56# We want the profile files for all fuzz targets + critical components.
57line_coverage_profiles := $(intermediates)/line_coverage_profiles.zip
58
59critical_components_static_inputs := $(foreach lib,$(critical_components_static), \
60 $(call intermediates-dir-for,STATIC_LIBRARIES,$(lib))/$(lib).a)
61
62critical_components_shared_inputs := $(foreach lib,$(critical_components_shared), \
63 $(call intermediates-dir-for,SHARED_LIBRARIES,$(lib))/$(lib).so)
64
65fuzz_target_inputs := $(foreach fuzz,$(fuzz_targets), \
66 $(call intermediates-dir-for,EXECUTABLES,$(fuzz))/$(fuzz))
67
68# When line coverage is enabled (NATIVE_LINE_COVERAGE is set), make creates
69# a "coverage" directory and stores all profile (*.gcno) files in inside.
70# We need everything that is stored inside this directory.
71$(line_coverage_profiles): $(fuzz_target_inputs)
72$(line_coverage_profiles): $(critical_components_static_inputs)
73$(line_coverage_profiles): $(critical_components_shared_inputs)
74$(line_coverage_profiles): $(SOONG_ZIP)
75 $(SOONG_ZIP) -o $@ -D $(PRODUCT_OUT)/coverage
76
77
78# Zip all fuzz targets compiled with line coverage.
79line_coverage_fuzz_targets := $(intermediates)/line_coverage_fuzz_targets.zip
80
81$(line_coverage_fuzz_targets): $(fuzz_target_inputs)
82$(line_coverage_fuzz_targets): $(SOONG_ZIP)
83 $(SOONG_ZIP) -o $@ -j $(addprefix -f ,$(fuzz_target_inputs))
84
85
86.PHONY: haiku-line-coverage
87haiku-line-coverage: $(line_coverage_profiles) $(line_coverage_fuzz_targets)
88$(call dist-for-goals, haiku-line-coverage, \
89 $(line_coverage_profiles):line_coverage_profiles.zip \
90 $(line_coverage_fuzz_targets):line_coverage_fuzz_targets.zip)
91
92line_coverage_profiles :=
93line_coverage_fuzz_targets :=