Cert: Generate backing process code coverage report after test run

* Generate line-by-line coverage report after test run using
  llvm-profdata and llvm-cov in JSON format
* Iteratively merge coverage report to the same file for the backing
  processes of both cert stack and stack under test even when they
  are using the same binary
* Since we cannot run a method after all tests, we have to iteratively
  merge coverage report into a common file after each test run
* llvm-cov and llvm-profdata tool is packaged together with the test
  ZIP as they have to be the same version when indexing .profraw data

Outputs:

* Two indexed data files per test run:
  - GdDevice_cert_stock_backing_process_coverage.profdata
  - GdDevice_stack_under_test_backing_process_coverage.profdata
* Two reports per test run:
  - GdDevice_cert_stock_backing_process_coverage.json
  - GdDevice_stack_under_test_backing_process_coverage.json
* Two summaries per test run:
  - GdDevice_cert_stock_backing_process_coverage_summary.txt
  - GdDevice_stack_under_test_backing_process_coverage_summary.txt
* Two raw data files per test class
  - GdDevice_cert_stock_backing_process_coverage.profraw
  - GdDevice_stack_under_test_backing_process_coverage.profraw

Performance Analysis:

* File Sizes:
  - profraw: around 6MB, 2 generated per test class
  - profdata: around 400KB, 2 generated per test class
  - coverage report: around 40MB, 2 generated per test run
* Each coverage report takes about 2 seconds and hence 4 seconds
  per test class. 11 test classes would result in 44 seconds for
  the whole test suite
* Hence, additional 80MB storage and about 50 seconds run time per
  test run

Bug: 153384476
Test: gd/cert/run --host
Change-Id: If488f1d1816fb1f9379729ace9d2b0e1a0343233
3 files changed
tree: 394e0ed99cd17544b339350d82a030335ff7fe71
  1. apex/
  2. system/
  3. .clang-format
  4. .gitignore
  5. .gn
  6. .style.yapf
  7. Android.bp
  8. AndroidTestTemplate.xml
  9. BUILD.gn
  10. CleanSpec.mk
  11. EventLogTags.logtags
  12. MODULE_LICENSE_APACHE2
  13. NOTICE
  14. OWNERS
  15. PREUPLOAD.cfg
  16. README.md
  17. TEST_MAPPING
README.md

Fluoride Bluetooth stack

Building and running on AOSP

Just build AOSP - Fluoride is there by default.

Building and running on Linux

Instructions for Ubuntu, tested on 14.04 with Clang 3.5.0 and 16.10 with Clang 3.8.0

Download source

mkdir ~/fluoride
cd ~/fluoride
git clone https://android.googlesource.com/platform/packages/modules/Bluetooth/system

Install dependencies (require sudo access):

cd ~/fluoride/bt
build/install_deps.sh

Then fetch third party dependencies:

cd ~/fluoride/bt
mkdir third_party
cd third_party
git clone https://github.com/google/googletest.git
git clone https://android.googlesource.com/platform/external/aac
git clone https://android.googlesource.com/platform/external/libchrome
git clone https://android.googlesource.com/platform/external/libldac
git clone https://android.googlesource.com/platform/external/modp_b64
git clone https://android.googlesource.com/platform/external/tinyxml2

And third party dependencies of third party dependencies:

cd fluoride/bt/third_party/libchrome/base/third_party
mkdir valgrind
cd valgrind
curl https://chromium.googlesource.com/chromium/src/base/+/master/third_party/valgrind/valgrind.h?format=TEXT | base64 -d > valgrind.h
curl https://chromium.googlesource.com/chromium/src/base/+/master/third_party/valgrind/memcheck.h?format=TEXT | base64 -d > memcheck.h

NOTE: If packages/modules/Bluetooth/system is checked out under AOSP, then create symbolic links instead of downloading sources

cd packages/modules/Bluetooth/system
mkdir third_party
cd third_party
ln -s ../../../external/aac aac
ln -s ../../../external/libchrome libchrome
ln -s ../../../external/libldac libldac
ln -s ../../../external/modp_b64 modp_b64
ln -s ../../../external/tinyxml2 tinyxml2
ln -s ../../../external/googletest googletest

Generate your build files

cd ~/fluoride/bt
gn gen out/Default

Build

cd ~/fluoride/bt
ninja -C out/Default all

This will build all targets (the shared library, executables, tests, etc) and put them in out/Default. To build an individual target, replace "all" with the target of your choice, e.g. ninja -C out/Default net_test_osi.

Run

cd ~/fluoride/bt/out/Default
LD_LIBRARY_PATH=./ ./bluetoothtbd -create-ipc-socket=fluoride

Eclipse IDE Support

  1. Follows the Chromium project Eclipse Setup Instructions until "Optional: Building inside Eclipse" section (don't do that section, we will set it up differently)

  2. Generate Eclipse settings:

cd packages/modules/Bluetooth/system
gn gen --ide=eclipse out/Default
  1. In Eclipse, do File->Import->C/C++->C/C++ Project Settings, choose the XML location under packages/modules/Bluetooth/system/out/Default

  2. Right click on the project. Go to Preferences->C/C++ Build->Builder Settings. Uncheck "Use default build command", but instead using "ninja -C out/Default"

  3. Goto Behaviour tab, change clean command to "-t clean"