Loading adb/coverage.sh +31 −6 Original line number Diff line number Diff line Loading @@ -15,7 +15,25 @@ set -euxo pipefail ADB_TESTS="adbd_test adb_crypto_test adb_pairing_auth_test adb_pairing_connection_test adb_tls_connection_test" TRACEDIR=`mktemp -d` adb root ### Run the adb unit tests and fetch traces from them. mkdir "$TRACEDIR"/test_traces adb shell rm -rf /data/local/tmp/adb_coverage adb shell mkdir /data/local/tmp/adb_coverage for TEST in $ADB_TESTS; do adb shell LLVM_PROFILE_FILE=/data/local/tmp/adb_coverage/$TEST.profraw /data/nativetest64/$TEST/$TEST adb pull /data/local/tmp/adb_coverage/$TEST.profraw "$TRACEDIR"/test_traces/ done adb pull /data/local/tmp/adb_coverage "$TRACEDIR"/test_traces ### Run test_device.py, and fetch traces from adbd itself. adb shell logcat -c -G128M adb shell setprop persist.adb.trace_mask 1 adb shell killall adbd Loading @@ -23,7 +41,7 @@ adb shell killall adbd # TODO: Add `adb transport-id` and wait-for-offline on it. sleep 5 adb wait-for-device shell rm "/data/misc/trace/*" adb wait-for-device shell rm -rf "/data/misc/trace/*" /data/local/tmp/adb_coverage/ ./test_device.py Loading @@ -33,11 +51,9 @@ adb shell killall -37 adbd echo Waiting for adbd to finish dumping traces sleep 5 TRACEDIR=`mktemp -d` adb pull /data/misc/trace "$TRACEDIR"/ echo Pulled traces to $TRACEDIR # Identify which of the trace files are actually adbd, in case something else exited simultaneously. ADBD_PIDS=$(adb shell "logcat -d -s adbd --format=process | grep 'adbd started' | cut -c 3-7 | tr -d ' ' | sort | uniq") mkdir "$TRACEDIR"/adbd_traces Loading @@ -48,16 +64,25 @@ IFS=$'\n' for PID in $ADBD_PIDS; do cp "$TRACEDIR"/trace/clang-$PID-*.profraw "$TRACEDIR"/adbd_traces 2>/dev/null || true done unset IFS ADB_TEST_BINARIES="" for TEST in $ADB_TESTS; do ADB_TEST_BINARIES="--object=$ANDROID_PRODUCT_OUT/data/nativetest64/$TEST/$TEST $ADB_TEST_BINARIES" done llvm-profdata merge --output="$TRACEDIR"/adbd.profdata "$TRACEDIR"/adbd_traces/* ### Merge the traces and generate a report. llvm-profdata merge --output="$TRACEDIR"/adbd.profdata "$TRACEDIR"/adbd_traces/* "$TRACEDIR"/test_traces/* cd $ANDROID_BUILD_TOP llvm-cov report --instr-profile="$TRACEDIR"/adbd.profdata \ $ANDROID_PRODUCT_OUT/apex/com.android.adbd/bin/adbd \ --show-region-summary=false \ /proc/self/cwd/system/core/adb /proc/self/cwd/system/core/adb \ $ADB_TEST_BINARIES llvm-cov show --instr-profile="$TRACEDIR"/adbd.profdata \ $ANDROID_PRODUCT_OUT/apex/com.android.adbd/bin/adbd \ --format=html \ /proc/self/cwd/system/core/adb > $TRACEDIR/report.html /proc/self/cwd/system/core/adb \ $ADB_TEST_BINARIES > $TRACEDIR/report.html Loading
adb/coverage.sh +31 −6 Original line number Diff line number Diff line Loading @@ -15,7 +15,25 @@ set -euxo pipefail ADB_TESTS="adbd_test adb_crypto_test adb_pairing_auth_test adb_pairing_connection_test adb_tls_connection_test" TRACEDIR=`mktemp -d` adb root ### Run the adb unit tests and fetch traces from them. mkdir "$TRACEDIR"/test_traces adb shell rm -rf /data/local/tmp/adb_coverage adb shell mkdir /data/local/tmp/adb_coverage for TEST in $ADB_TESTS; do adb shell LLVM_PROFILE_FILE=/data/local/tmp/adb_coverage/$TEST.profraw /data/nativetest64/$TEST/$TEST adb pull /data/local/tmp/adb_coverage/$TEST.profraw "$TRACEDIR"/test_traces/ done adb pull /data/local/tmp/adb_coverage "$TRACEDIR"/test_traces ### Run test_device.py, and fetch traces from adbd itself. adb shell logcat -c -G128M adb shell setprop persist.adb.trace_mask 1 adb shell killall adbd Loading @@ -23,7 +41,7 @@ adb shell killall adbd # TODO: Add `adb transport-id` and wait-for-offline on it. sleep 5 adb wait-for-device shell rm "/data/misc/trace/*" adb wait-for-device shell rm -rf "/data/misc/trace/*" /data/local/tmp/adb_coverage/ ./test_device.py Loading @@ -33,11 +51,9 @@ adb shell killall -37 adbd echo Waiting for adbd to finish dumping traces sleep 5 TRACEDIR=`mktemp -d` adb pull /data/misc/trace "$TRACEDIR"/ echo Pulled traces to $TRACEDIR # Identify which of the trace files are actually adbd, in case something else exited simultaneously. ADBD_PIDS=$(adb shell "logcat -d -s adbd --format=process | grep 'adbd started' | cut -c 3-7 | tr -d ' ' | sort | uniq") mkdir "$TRACEDIR"/adbd_traces Loading @@ -48,16 +64,25 @@ IFS=$'\n' for PID in $ADBD_PIDS; do cp "$TRACEDIR"/trace/clang-$PID-*.profraw "$TRACEDIR"/adbd_traces 2>/dev/null || true done unset IFS ADB_TEST_BINARIES="" for TEST in $ADB_TESTS; do ADB_TEST_BINARIES="--object=$ANDROID_PRODUCT_OUT/data/nativetest64/$TEST/$TEST $ADB_TEST_BINARIES" done llvm-profdata merge --output="$TRACEDIR"/adbd.profdata "$TRACEDIR"/adbd_traces/* ### Merge the traces and generate a report. llvm-profdata merge --output="$TRACEDIR"/adbd.profdata "$TRACEDIR"/adbd_traces/* "$TRACEDIR"/test_traces/* cd $ANDROID_BUILD_TOP llvm-cov report --instr-profile="$TRACEDIR"/adbd.profdata \ $ANDROID_PRODUCT_OUT/apex/com.android.adbd/bin/adbd \ --show-region-summary=false \ /proc/self/cwd/system/core/adb /proc/self/cwd/system/core/adb \ $ADB_TEST_BINARIES llvm-cov show --instr-profile="$TRACEDIR"/adbd.profdata \ $ANDROID_PRODUCT_OUT/apex/com.android.adbd/bin/adbd \ --format=html \ /proc/self/cwd/system/core/adb > $TRACEDIR/report.html /proc/self/cwd/system/core/adb \ $ADB_TEST_BINARIES > $TRACEDIR/report.html