112 lines · 3.0 KB · Shell
RawDownload
#!/bin/bash AUTO_TEST_ANDROID_PATH=`pwd`AUTO_TEST_SRC_PATH="../../../"AUTO_TEST_RES_PATH="${AUTO_TEST_ANDROID_PATH}/report"if [ ! -d ${AUTO_TEST_RES_PATH} ]thenmkdir -p ${AUTO_TEST_RES_PATH}elseecho "Will delete those outdate xml in the report"rm -f ${AUTO_TEST_RES_PATH}/*.xmlfi#Prepare android build enviromentecho please set the enviroment variable as:echo export ANDROID_HOME="path of android sdk"echo export ANDROID_NDK_HOME="path of android ndk"ANDROID_SDK_PATH=${ANDROID_HOME}ANDROID_NDK_PATH=${ANDROID_NDK_HOME}ANDROID_MAKE_PARAMS="OS=android NDKROOT=${ANDROID_NDK_PATH} TARGET=android-19" if [ "#${ANDROID_SDK_PATH}" = "#" ]thenecho Please set ANDROID_HOME with the path of Android SDKexit 1fiif [ "#${ANDROID_NDK_PATH}" = "#" ]thenecho Please set ANDROID_NDK_HOME with the path of Android NDKexit 1fi#make buildcd ${AUTO_TEST_SRC_PATH}find ./ -name *.o -exec rm -f {} \;find ./ -name *.d -exec rm -f {} \;make cleanmake $ANDROID_MAKE_PARAMS test if [ $? -ne 0 ]then   echo Build error,check with the trace of make   exit 1fi #find apkecho Start to find unittest apkapk_name=`find ./ -name MainActivity-debug.apk`if [ "#${apk_name}" = "#" ]then  echo Fail to find encoder APK.  exit 1fi #prepare devicesADB=${ANDROID_SDK_PATH}/platform-tools/adb #get devicesdevices=`$ADB devices | awk -F" " '/\tdevice/{print $1}'`if [ "#$devices" = "#" ];then   echo "Have not any android devices."   exit 1fi #run apkrun_apk() {local apk=$1;local rand=` date +%s`apk_id="com.cisco.codec.unittest"apk_main="com.cisco.codec.unittest/.MainActivity"test_path="/sdcard/welsenc"log_grep_params="welsenc"test_res=./resxml_file="sdcard/codec_unittest.xml"for dev in $devices; do    #dev_info_file=${AUTO_TEST_RES_PATH}/${dev}.log    report_file=${AUTO_TEST_RES_PATH}/codec_unittest_${dev}_${rand}.xml    $ADB -s $dev uninstall ${apk_id}    $ADB -s $dev install -r ${apk}    #TODO: output more info about android device such as name,cpu,memory,and also power comsumption.    echo `$ADB -s $dev shell cat /system/build.prop |grep ro.product.model | awk -F"=" '{print $2}'`>${dev_info_file}    $ADB -s $dev push ${test_res} /sdcard/res    $ADB -s $dev shell am start --es path "$xml_file" -n ${apk_main}    # check whetehr the app is finished every 2 sec    for (( ; ; )); do        $ADB -s $dev shell ps | grep ${apk_id}        if [ $? -ne 0 ]; then            sleep 2            $ADB -s $dev shell ps | grep ${apk_id}            [ $? -ne 0 ] && break        fi        sleep 2    done     # kill logcat    $ADB -s $dev pull ${xml_file} ${report_file}    #delete the res    $ADB -s $dev shell rm -rf ${xml_file}    $ADB -s $dev shell rm -rf /sdcard/resdone}for apk in ${apk_name};do   run_apk $apk;   if [ $? -ne 0 ]   then     echo There is something wrong happened when run ${apk_name}     exit 1   else     echo Finished unit test on android     echo The test result is at ./android/report/xxx.xml     echo xxxxxxxxxxxxxxxAndroid unittest Endxxxxxxxxxxxxxxxx   fidone 

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t