#!/bin/bash # Helper script to use atest to run the MediaDrm CTS and GTS tests # This script: # 1. Unlocks a device that has no pin set # 2. Asserts that it has internet connectivity # 3. Clears logcat # 4. Uses atest to run the MediaDrm CTS and GTS tests # 5. Saves output of atest and logcat to log files in the $OUT dir if [[ -z "$ANDROID_SERIAL" ]]; then echo '$ANDROID_SERIAL not set. Set ANDROID_SERIAL to the serial of the' \ 'device you want to test.' exit 1 fi if [[ -z "$OUT" ]]; then echo '$OUT not set. You must source build/envsetup.sh and run lunch first.' exit 1 fi adb root if [[ "$?" -ne 0 ]]; then exit 1 fi # Make screen never sleep while charging adb shell settings put global stay_on_while_plugged_in 7 # Unlock a device that does not have a pin or password set (e.g. swipe up to unlock): # press the wakeup key, then if the device is still locked, press the menu key adb shell input keyevent 224 sleep 1 if [[ $(adb shell dumpsys nfc | grep '^mScreenState=ON_LOCKED$') ]] ; then adb shell input keyevent 82 fi if [[ ! $(adb shell ping -c 1 google.com) ]]; then echo "No wifi. Exiting" exit 1 fi adb shell mkdir -p /sdcard/test/images/ TIMESTAMP="$(date +"%b-%d-%H%M")" STDOUT_FILE="$OUT/atest.mediadrm.$ANDROID_SERIAL.$TIMESTAMP.stdout.log" STDERR_FILE="$OUT/atest.mediadrm.$ANDROID_SERIAL.$TIMESTAMP.stderr.log " LOGCAT_FILE="$OUT/atest.mediadrm.$ANDROID_SERIAL.$TIMESTAMP.logcat.log" WVTS_BASE="WvtsDeviceTestCases:com.google.android.wvts" GTS_BASE="GtsMediaTestCases:com.google.android.media.gts" adb logcat -c atest -v -s $ANDROID_SERIAL \ ${WVTS_BASE}.DecoderMetricsTests \ ${WVTS_BASE}.DrmSessionManagerTest \ ${WVTS_BASE}.MediaCodecCencTest \ ${GTS_BASE}.MediaCodecStressTest \ ${WVTS_BASE}.MediaCodecTest \ ${WVTS_BASE}.MediaDrmTest \ ${WVTS_BASE}.MediaPlayerTest \ ${WVTS_BASE}.Vp8CodecTest \ ${WVTS_BASE}.WidevineCodecStressTests \ ${WVTS_BASE}.WidevineDashPolicyTests \ ${WVTS_BASE}.WidevineFailureTests \ ${WVTS_BASE}.WidevineGenericOpsTests \ ${WVTS_BASE}.WidevineH264PlaybackTests \ ${WVTS_BASE}.WidevineHEVCPlaybackTests \ ${WVTS_BASE}.WidevineHLSPlaybackTests \ ${WVTS_BASE}.WidevineIdentifierTests \ ${WVTS_BASE}.WidevineVP9WebMPlaybackTests \ ${WVTS_BASE}.WidevineYouTubePerformanceTests \ GtsExoPlayerTestCases:com.google.android.exoplayer.gts.DashStreamingTest \ CtsMediaDrmTestCases:android.mediadrm.cts.MediaDrmClearkeyTest \ CtsMediaDrmTestCases:android.mediadrm.cts.MediaDrmCodecTest \ CtsMediaDrmTestCases:android.mediadrm.cts.MediaDrmMetricsTest \ CtsMediaDrmTestCases:android.mediadrm.cts.MediaPlayerDrmTest \ CtsMediaDrmTestCases:android.mediadrm.cts.NativeMediaDrmClearkeyTest \ > >(tee -a $STDOUT_FILE) \ 2> >(tee -a $STDERR_FILE >&2) adb logcat -d > $LOGCAT_FILE cat <