| 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 | 
| Joel Galenson | 154ac1d | 2020-07-30 14:23:31 -0700 | [diff] [blame] | 15 | # line coverage instrumentation. For now we just block them. | 
 | 16 | blocked_fuzz_targets := libneuralnetworks_fuzzer | 
| Kyriakos Ispoglou | f00a0db | 2020-02-06 16:41:49 -0800 | [diff] [blame] | 17 |  | 
 | 18 | fuzz_targets := $(ALL_FUZZ_TARGETS) | 
| Joel Galenson | 154ac1d | 2020-07-30 14:23:31 -0700 | [diff] [blame] | 19 | fuzz_targets := $(filter-out $(blocked_fuzz_targets),$(fuzz_targets)) | 
| Kyriakos Ispoglou | f00a0db | 2020-02-06 16:41:49 -0800 | [diff] [blame] | 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 \ | 
| Jiyong Park | 157ac24 | 2020-05-01 11:21:40 +0900 | [diff] [blame] | 49 | 	libvixl:com.android.art.debug | 
| Kyriakos Ispoglou | f00a0db | 2020-02-06 16:41:49 -0800 | [diff] [blame] | 50 |  | 
 | 51 | # Use the intermediates directory to avoid installing libraries to the device. | 
 | 52 | intermediates := $(call intermediates-dir-for,PACKAGING,haiku-line-coverage) | 
 | 53 |  | 
 | 54 |  | 
 | 55 | # We want the profile files for all fuzz targets + critical components. | 
 | 56 | line_coverage_profiles := $(intermediates)/line_coverage_profiles.zip | 
 | 57 |  | 
 | 58 | critical_components_static_inputs := $(foreach lib,$(critical_components_static), \ | 
 | 59 | 	$(call intermediates-dir-for,STATIC_LIBRARIES,$(lib))/$(lib).a) | 
 | 60 |  | 
 | 61 | critical_components_shared_inputs := $(foreach lib,$(critical_components_shared), \ | 
| Jiyong Park | 157ac24 | 2020-05-01 11:21:40 +0900 | [diff] [blame] | 62 | 	$(eval filename := $(call word-colon,1,$(lib))) \ | 
 | 63 | 	$(eval modulename := $(subst :,.,$(lib))) \ | 
 | 64 | 	$(call intermediates-dir-for,SHARED_LIBRARIES,$(modulename))/$(filename).so) | 
| Kyriakos Ispoglou | f00a0db | 2020-02-06 16:41:49 -0800 | [diff] [blame] | 65 |  | 
 | 66 | fuzz_target_inputs := $(foreach fuzz,$(fuzz_targets), \ | 
 | 67 | 	$(call intermediates-dir-for,EXECUTABLES,$(fuzz))/$(fuzz)) | 
 | 68 |  | 
| Colin Cross | 74f121d | 2020-06-16 17:49:08 -0700 | [diff] [blame] | 69 | # When coverage is enabled (NATIVE_COVERAGE is set), make creates | 
| Kyriakos Ispoglou | f00a0db | 2020-02-06 16:41:49 -0800 | [diff] [blame] | 70 | # a "coverage" directory and stores all profile (*.gcno) files in inside. | 
 | 71 | # We need everything that is stored inside this directory. | 
 | 72 | $(line_coverage_profiles): $(fuzz_target_inputs) | 
 | 73 | $(line_coverage_profiles): $(critical_components_static_inputs) | 
 | 74 | $(line_coverage_profiles): $(critical_components_shared_inputs) | 
 | 75 | $(line_coverage_profiles): $(SOONG_ZIP) | 
 | 76 | 	$(SOONG_ZIP) -o $@ -D $(PRODUCT_OUT)/coverage | 
 | 77 |  | 
 | 78 |  | 
 | 79 | # Zip all fuzz targets compiled with line coverage. | 
 | 80 | line_coverage_fuzz_targets := $(intermediates)/line_coverage_fuzz_targets.zip | 
 | 81 |  | 
 | 82 | $(line_coverage_fuzz_targets): $(fuzz_target_inputs) | 
 | 83 | $(line_coverage_fuzz_targets): $(SOONG_ZIP) | 
 | 84 | 	$(SOONG_ZIP) -o $@ -j $(addprefix -f ,$(fuzz_target_inputs)) | 
 | 85 |  | 
 | 86 |  | 
 | 87 | .PHONY: haiku-line-coverage | 
 | 88 | haiku-line-coverage: $(line_coverage_profiles) $(line_coverage_fuzz_targets) | 
 | 89 | $(call dist-for-goals, haiku-line-coverage, \ | 
 | 90 | 	$(line_coverage_profiles):line_coverage_profiles.zip \ | 
 | 91 | 	$(line_coverage_fuzz_targets):line_coverage_fuzz_targets.zip) | 
 | 92 |  | 
 | 93 | line_coverage_profiles := | 
 | 94 | line_coverage_fuzz_targets := |