#!/bin/sh set -e if [ -z "$ANDROID_BUILD_TOP" ]; then echo "Android build environment not set" exit -1 fi # Read arguments in case the user wants to do a multicore build NUM_CORES=1 while getopts "j:" opt; do case $opt in j) NUM_CORES=$OPTARG ;; esac done # Define the relevant aliases . $ANDROID_BUILD_TOP/build/envsetup.sh # Build all the targets cd $ANDROID_BUILD_TOP/vendor/widevine/libwvdrmengine pwd mm -j $NUM_CORES || mma -j $NUM_CORES cd $ANDROID_BUILD_TOP/vendor/widevine/libwvdrmengine/test/unit pwd mm -j $NUM_CORES || mma -j $NUM_CORES cd $ANDROID_BUILD_TOP/vendor/widevine/libwvdrmengine/cdm/test pwd mm -j $NUM_CORES || mma -j $NUM_CORES cd $ANDROID_BUILD_TOP/vendor/widevine/libwvdrmengine/mediacrypto/test pwd mm -j $NUM_CORES || mma -j $NUM_CORES cd $ANDROID_BUILD_TOP/vendor/widevine/libwvdrmengine/mediadrm/test pwd mm -j $NUM_CORES || mma -j $NUM_CORES cd $ANDROID_BUILD_TOP/vendor/widevine/libwvdrmengine/oemcrypto/test pwd mm -j $NUM_CORES || mma -j $NUM_CORES # Detect the device and check if Verity is going to stop the script from working echo "waiting for device" ADB_OUTPUT=`adb root && adb wait-for-device remount` echo $ADB_OUTPUT if echo $ADB_OUTPUT | grep -qi "verity"; then echo echo "ERROR: This device has Verity enabled. build_and_run_all_unit_tests.sh " echo "does not work if Verity is enabled. Please disable Verity with" echo "\"adb disable-verity\" and try again." exit -1 fi # Push the files to the device # Given a local path to a file, this will first try to push it to /vendor/bin # and then, if that fails, to /data/widevine_tests. try_adb_push() { # Swallow the error message -- assume it is a read-only file system. if ! adb push $@ /vendor/bin &> /dev/null; then adb shell mkdir -p /data/widevine_tests # If this fails, the user will get the error message. adb push $@ /data/widevine_tests fi } # Push the tests to the device try_adb_push $OUT/vendor/bin/oemcrypto_test try_adb_push $OUT/vendor/bin/request_license_test try_adb_push $OUT/vendor/bin/cdm_extended_duration_test try_adb_push $OUT/vendor/bin/policy_engine_unittest try_adb_push $OUT/vendor/bin/policy_engine_constraints_unittest try_adb_push $OUT/vendor/bin/libwvdrmmediacrypto_test try_adb_push $OUT/vendor/bin/libwvdrmmediacrypto_hidl_test try_adb_push $OUT/vendor/bin/libwvdrmdrmplugin_test try_adb_push $OUT/vendor/bin/libwvdrmdrmplugin_hidl_test try_adb_push $OUT/vendor/bin/cdm_engine_test try_adb_push $OUT/vendor/bin/cdm_session_unittest try_adb_push $OUT/vendor/bin/file_store_unittest try_adb_push $OUT/vendor/bin/file_utils_unittest try_adb_push $OUT/vendor/bin/license_unittest try_adb_push $OUT/vendor/bin/license_keys_unittest try_adb_push $OUT/vendor/bin/initialization_data_unittest try_adb_push $OUT/vendor/bin/device_files_unittest try_adb_push $OUT/vendor/bin/service_certificate_unittest try_adb_push $OUT/vendor/bin/timer_unittest try_adb_push $OUT/vendor/bin/libwvdrmengine_test try_adb_push $OUT/vendor/bin/libwvdrmengine_hidl_test try_adb_push $OUT/vendor/bin/buffer_reader_test try_adb_push $OUT/vendor/bin/distribution_test try_adb_push $OUT/vendor/bin/event_metric_test # Run the tests using run_all_unit_tests.sh cd $ANDROID_BUILD_TOP/vendor/widevine/libwvdrmengine ./run_all_unit_tests.sh