Kyriakos Ispoglou | f00a0db | 2020-02-06 16:41:49 -0800 | [diff] [blame] | 1 | # ----------------------------------------------------------------- |
| 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: |
Colin Cross | 74f121d | 2020-06-16 17:49:08 -0700 | [diff] [blame^] | 11 | # NATIVE_COVERAGE=true NATIVE_COVERAGE_PATHS=* make haiku-line-coverage |
Kyriakos Ispoglou | f00a0db | 2020-02-06 16:41:49 -0800 | [diff] [blame] | 12 | # ----------------------------------------------------------------- |
| 13 | |
| 14 | # TODO(b/148306195): Due this issue some fuzz targets cannot be built with |
| 15 | # line coverage instrumentation. For now we just blacklist them. |
| 16 | blacklisted_fuzz_targets := libneuralnetworks_fuzzer |
| 17 | |
| 18 | fuzz_targets := $(ALL_FUZZ_TARGETS) |
| 19 | fuzz_targets := $(filter-out $(blacklisted_fuzz_targets),$(fuzz_targets)) |
| 20 | |
| 21 | |
| 22 | # Android components that considered critical. |
| 23 | # Please note that adding/Removing critical components is very rare. |
| 24 | critical_components_static := \ |
| 25 | lib-bt-packets \ |
| 26 | libbt-stack \ |
| 27 | libffi \ |
| 28 | libhevcdec \ |
| 29 | libhevcenc \ |
| 30 | libmpeg2dec \ |
| 31 | libosi \ |
| 32 | libpdx \ |
| 33 | libselinux \ |
| 34 | libvold \ |
| 35 | libyuv |
| 36 | |
Jiyong Park | 157ac24 | 2020-05-01 11:21:40 +0900 | [diff] [blame] | 37 | # Format is <module_name> or <module_name>:<apex_name> |
Kyriakos Ispoglou | f00a0db | 2020-02-06 16:41:49 -0800 | [diff] [blame] | 38 | critical_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 \ |
Jiyong Park | 157ac24 | 2020-05-01 11:21:40 +0900 | [diff] [blame] | 50 | libvixl:com.android.art.debug |
Kyriakos Ispoglou | f00a0db | 2020-02-06 16:41:49 -0800 | [diff] [blame] | 51 | |
| 52 | # Use the intermediates directory to avoid installing libraries to the device. |
| 53 | intermediates := $(call intermediates-dir-for,PACKAGING,haiku-line-coverage) |
| 54 | |
| 55 | |
| 56 | # We want the profile files for all fuzz targets + critical components. |
| 57 | line_coverage_profiles := $(intermediates)/line_coverage_profiles.zip |
| 58 | |
| 59 | critical_components_static_inputs := $(foreach lib,$(critical_components_static), \ |
| 60 | $(call intermediates-dir-for,STATIC_LIBRARIES,$(lib))/$(lib).a) |
| 61 | |
| 62 | critical_components_shared_inputs := $(foreach lib,$(critical_components_shared), \ |
Jiyong Park | 157ac24 | 2020-05-01 11:21:40 +0900 | [diff] [blame] | 63 | $(eval filename := $(call word-colon,1,$(lib))) \ |
| 64 | $(eval modulename := $(subst :,.,$(lib))) \ |
| 65 | $(call intermediates-dir-for,SHARED_LIBRARIES,$(modulename))/$(filename).so) |
Kyriakos Ispoglou | f00a0db | 2020-02-06 16:41:49 -0800 | [diff] [blame] | 66 | |
| 67 | fuzz_target_inputs := $(foreach fuzz,$(fuzz_targets), \ |
| 68 | $(call intermediates-dir-for,EXECUTABLES,$(fuzz))/$(fuzz)) |
| 69 | |
Colin Cross | 74f121d | 2020-06-16 17:49:08 -0700 | [diff] [blame^] | 70 | # When coverage is enabled (NATIVE_COVERAGE is set), make creates |
Kyriakos Ispoglou | f00a0db | 2020-02-06 16:41:49 -0800 | [diff] [blame] | 71 | # a "coverage" directory and stores all profile (*.gcno) files in inside. |
| 72 | # We need everything that is stored inside this directory. |
| 73 | $(line_coverage_profiles): $(fuzz_target_inputs) |
| 74 | $(line_coverage_profiles): $(critical_components_static_inputs) |
| 75 | $(line_coverage_profiles): $(critical_components_shared_inputs) |
| 76 | $(line_coverage_profiles): $(SOONG_ZIP) |
| 77 | $(SOONG_ZIP) -o $@ -D $(PRODUCT_OUT)/coverage |
| 78 | |
| 79 | |
| 80 | # Zip all fuzz targets compiled with line coverage. |
| 81 | line_coverage_fuzz_targets := $(intermediates)/line_coverage_fuzz_targets.zip |
| 82 | |
| 83 | $(line_coverage_fuzz_targets): $(fuzz_target_inputs) |
| 84 | $(line_coverage_fuzz_targets): $(SOONG_ZIP) |
| 85 | $(SOONG_ZIP) -o $@ -j $(addprefix -f ,$(fuzz_target_inputs)) |
| 86 | |
| 87 | |
| 88 | .PHONY: haiku-line-coverage |
| 89 | haiku-line-coverage: $(line_coverage_profiles) $(line_coverage_fuzz_targets) |
| 90 | $(call dist-for-goals, haiku-line-coverage, \ |
| 91 | $(line_coverage_profiles):line_coverage_profiles.zip \ |
| 92 | $(line_coverage_fuzz_targets):line_coverage_fuzz_targets.zip) |
| 93 | |
| 94 | line_coverage_profiles := |
| 95 | line_coverage_fuzz_targets := |