commit
ecfd7df157
4
autotest/unitTest/.gitignore
vendored
Normal file
4
autotest/unitTest/.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
.DS_Store
|
||||||
|
./ios/report/
|
||||||
|
./android/report/
|
||||||
|
|
106
autotest/unitTest/android/run_AutoTest_android.sh
Normal file
106
autotest/unitTest/android/run_AutoTest_android.sh
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
AUTO_TEST_ANDROID_PATH=`pwd`
|
||||||
|
AUTO_TEST_SRC_PATH="../../../"
|
||||||
|
AUTO_TEST_RES_PATH="${AUTO_TEST_ANDROID_PATH}/report"
|
||||||
|
mkdir -p ${AUTO_TEST_RES_PATH}
|
||||||
|
#Prepare android build enviroment
|
||||||
|
echo 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}" = "#" ]
|
||||||
|
then
|
||||||
|
echo Please set ANDROID_HOME with the path of Android SDK
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ "#${ANDROID_NDK_PATH}" = "#" ]
|
||||||
|
then
|
||||||
|
echo Please set ANDROID_NDK_HOME with the path of Android NDK
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
#make build
|
||||||
|
cd ${AUTO_TEST_SRC_PATH}
|
||||||
|
find ./ -name *.o -exec rm -f {} \;
|
||||||
|
find ./ -name *.d -exec rm -f {} \;
|
||||||
|
make clean
|
||||||
|
make $ANDROID_MAKE_PARAMS test
|
||||||
|
|
||||||
|
if [ $? -ne 0 ]
|
||||||
|
then
|
||||||
|
echo Build error,check with the trace of make
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
#find apk
|
||||||
|
echo Start to find unittest apk
|
||||||
|
apk_name=`find ./ -name MainActivity-debug.apk`
|
||||||
|
if [ "#${apk_name}" = "#" ]
|
||||||
|
then
|
||||||
|
echo Fail to find encoder APK.
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
#prepare devices
|
||||||
|
ADB=${ANDROID_SDK_PATH}/platform-tools/adb
|
||||||
|
|
||||||
|
#get devices
|
||||||
|
devices=`$ADB devices | awk -F" " '/\tdevice/{print $1}'`
|
||||||
|
if [ "#$devices" = "#" ];then
|
||||||
|
echo "Have not any android devices."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
#run apk
|
||||||
|
run_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=./res
|
||||||
|
xml_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/res
|
||||||
|
done
|
||||||
|
}
|
||||||
|
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
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
163
autotest/unitTest/ios/run_AutoTest_ios.sh
Normal file
163
autotest/unitTest/ios/run_AutoTest_ios.sh
Normal file
@ -0,0 +1,163 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
##############################################################
|
||||||
|
#Build ios test ref app
|
||||||
|
|
||||||
|
#set the default configuration
|
||||||
|
CODEC_TEST_IOS_ARCH="armv7"
|
||||||
|
CODEC_TEST_IOS_PLATFORM="iphoneos"
|
||||||
|
CODEC_TEST_IOS_DEBUG_RELEASE="Release"
|
||||||
|
CODEC_TEST_IOS_REPORT_SUBFOLDER="release"
|
||||||
|
|
||||||
|
|
||||||
|
buildXcodeProject()
|
||||||
|
{
|
||||||
|
xcodebuild ARCHS="${CODEC_TEST_IOS_ARCH}" VALID_ARCHS="${CODEC_TEST_IOS_ARCH}" ONLY_ACTIVE_ARCH=NO -project $1 -target $2 -configuration $3 -sdk ${CODEC_TEST_IOS_PLATFORM} clean build
|
||||||
|
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
echo "build $1 $3 successfully"
|
||||||
|
else
|
||||||
|
echo "build $1 $3 fail"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
iosUnitTest()
|
||||||
|
{
|
||||||
|
|
||||||
|
if [ $# -gt 2 ]; then
|
||||||
|
echo "Please use command $0 [armv7/armv7s/arm64] [release/debug]"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
CODEC_TEST_XCODE_PROJECT_NAME="${AUTO_TEST_SRC_PATH}/test/build/ios/codec_unittest/codec_unittest.xcodeproj/"
|
||||||
|
CODEC_TEST_IOS_PROJECT_NAME="codec_unittest"
|
||||||
|
CODEC_TEST_IOS_PROJECT_PATH="${AUTO_TEST_SRC_PATH}/test/build/ios/codec_unittest/build"
|
||||||
|
CODEC_TEST_IOS_APP=${CODEC_TEST_IOS_PROJECT_PATH}/${CODEC_TEST_IOS_DEBUG_RELEASE}-iphoneos/${CODEC_TEST_IOS_PROJECT_NAME}.app
|
||||||
|
CODEC_TEST_IOS_APP_ID="com.cisco.codec-unittest"
|
||||||
|
CODEC_TEST_RES=${AUTO_TEST_SRC_PATH}/res
|
||||||
|
CODEC_TEST_LOG="codec_unittest"
|
||||||
|
for PARAM in $*; do
|
||||||
|
if [ "release" = "${PARAM}" ]; then
|
||||||
|
CODEC_TEST_IOS_DEBUG_RELEASE="Release"
|
||||||
|
CODEC_TEST_IOS_REPORT_SUBFOLDER="release"
|
||||||
|
elif [ "debug" = "${PARAM}" ]; then
|
||||||
|
CODEC_TEST_IOS_DEBUG_RELEASE="Debug"
|
||||||
|
CODEC_TEST_IOS_REPORT_SUBFOLDER="debug"
|
||||||
|
elif [ "armv7" = "${PARAM}" ];then
|
||||||
|
CODEC_TEST_IOS_ARCH="armv7"
|
||||||
|
elif [ "armv7s" = "${PARAM}" ];then
|
||||||
|
CODEC_TEST_IOS_ARCH="armv7s"
|
||||||
|
elif [ "arm64" = "${PARAM}" ];then
|
||||||
|
CODEC_TEST_IOS_ARCH="arm64"
|
||||||
|
else
|
||||||
|
echo parameters are illegal!!!, please have a check.
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
cd ${AUTO_TEST_SRC_PATH}
|
||||||
|
IOS_MAKE_PARAMS="OS=ios ARCH=${CODEC_TEST_IOS_ARCH}"
|
||||||
|
############make build
|
||||||
|
find ./ -name *.o -exec rm -rf {} \;
|
||||||
|
find ./ -name *.d -exec rm -rf {} \;
|
||||||
|
make clean
|
||||||
|
make ${IOS_MAKE_PARAMS} test
|
||||||
|
echo "Codec test will run on ${CODEC_TEST_IOS_PLATFORM} with ${CODEC_TEST_IOS_DEBUG_RELEASE}"
|
||||||
|
cd ${AUTO_TEST_IOS_PATH}
|
||||||
|
buildXcodeProject ${CODEC_TEST_XCODE_PROJECT_NAME} ${CODEC_TEST_IOS_PROJECT_NAME} ${CODEC_TEST_IOS_DEBUG_RELEASE} ${CODEC_TEST_IOS_PLATFORM}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
##############run on ios devices#########################
|
||||||
|
# for real device
|
||||||
|
if [ ! -d ${CODEC_TEST_IOS_APP} ] ; then
|
||||||
|
echo "${CODEC_TEST_IOS_APP} is not found"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "Find app ${CODEC_TEST_IOS_APP}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
#ensure instruments not runing
|
||||||
|
echo "Try to kill the runing instruments"
|
||||||
|
pids_str=`ps x -o pid,command | grep -v grep | grep "instruments" | awk '{printf "%s,", $1}'`
|
||||||
|
instruments_pids="${pids_str//,/ }"
|
||||||
|
for pid in ${instruments_pids}; do
|
||||||
|
echo "Found instruments ${pid}. Killing..."
|
||||||
|
kill -9 ${pid} && wait ${pid} &> /dev/null
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
DEVICES=`system_profiler SPUSBDataType | sed -n -e '/iPad/,/Serial/p' -e '/iPhone/,/Serial/p' | grep "Serial Number:" | awk -F ": " '{print $2}'`
|
||||||
|
if [ "${DEVICES}#" == "#" ]
|
||||||
|
then
|
||||||
|
echo "Can not find any connected device! please check device is connected to MAC!"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
rand=`date +%s`
|
||||||
|
for DEVICE_ID in ${DEVICES}
|
||||||
|
do
|
||||||
|
echo "Try to run on device:${DEVICE_ID}"
|
||||||
|
|
||||||
|
#uninstall the application from device to remove the last result
|
||||||
|
${AUTO_TEST_IOS_SCRIPT_PATH}/fruitstrap uninstall --bundle ${CODEC_TEST_IOS_APP_ID} --id ${DEVICE_ID}
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo uninstall application: ${CODEC_TEST_IOS_APP} from device: ${DEVICE_ID} is failed!
|
||||||
|
fi
|
||||||
|
#install the application
|
||||||
|
${AUTO_TEST_IOS_SCRIPT_PATH}/fruitstrap install --bundle ${CODEC_TEST_IOS_APP} --id ${DEVICE_ID}
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo install application: ${CODEC_TEST_IOS_APP} to device: ${DEVICE_ID} is failed!
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
${AUTO_TEST_IOS_SCRIPT_PATH}/iFileTransfer -o copy -id ${DEVICE_ID} -app ${CODEC_TEST_IOS_APP_ID} -from ${CODEC_TEST_RES}
|
||||||
|
instruments -w ${DEVICE_ID} -t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate ${CODEC_TEST_IOS_APP} -e UIASCRIPT ${AUTO_TEST_IOS_SCRIPT_PATH}/uiascript.js -e UIARRESULTPATH /tmp/
|
||||||
|
#copy to report folder
|
||||||
|
${AUTO_TEST_IOS_SCRIPT_PATH}/iFileTransfer -o download -id ${DEVICE_ID} -app ${CODEC_TEST_IOS_APP_ID} -from /Documents/${CODEC_TEST_LOG}.xml -to ${CODEC_TEST_IOS_REPORT_PATH}/${CODEC_TEST_LOG}_${DEVICE_ID}_${rand}_${CODEC_TEST_IOS_ARCH}.xml
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "download file: ${CODEC_TEST_LOG}.xml from ${CODEC_TEST_IOS_APP_ID} is failed!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
AUTO_TEST_IOS_PATH=`pwd`
|
||||||
|
AUTO_TEST_SRC_PATH="../../.."
|
||||||
|
AUTO_TEST_IOS_SCRIPT_PATH="../../performanceTest/ios"
|
||||||
|
CODEC_TEST_IOS_REPORT_PATH="${AUTO_TEST_IOS_PATH}/report"
|
||||||
|
if [ ! -d ${CODEC_TEST_IOS_REPORT_PATH} ]
|
||||||
|
then
|
||||||
|
mkdir -p ${CODEC_TEST_IOS_REPORT_PATH}
|
||||||
|
fi
|
||||||
|
|
||||||
|
#start to run unittest,default run the xcode at arch armv7 with release
|
||||||
|
iosUnitTest armv7 release
|
||||||
|
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Running Unittest demo with armv7 is failed!"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo Finished unittest with armv7 on ios devices
|
||||||
|
echo the test result is generated at ./ios/report/xx.xml
|
||||||
|
fi
|
||||||
|
#start to run unittest,run the xcode at arch arm64 with release
|
||||||
|
iosUnitTest arm64 release
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Running Unittest demo with arm64 is failed!"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo Finished unittest with arm64 on ios devices
|
||||||
|
echo the test result is generated at ./ios/report/xx.xml
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo xxxxxxxxxxxxxxxxxxxxxxxxxxxxIOS unittest Endxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||||
|
|
||||||
|
#TODO:according to the trace of instruments to do some analysis
|
||||||
|
#find ${AUTO_TEST_IOS_SCRIPT_PATH} -name *.trace -exec rm -rf {} \;
|
||||||
|
rm -rf *.trace
|
43
autotest/unitTest/run_ParseUTxml.sh
Normal file
43
autotest/unitTest/run_ParseUTxml.sh
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
if [ $# -ne 1 ];then
|
||||||
|
echo Please input $0 [report dir]
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
REPORT=$1
|
||||||
|
if [ ! -e ${REPORT} ];then
|
||||||
|
echo "The directory of ${REPORT} dose't not exit,please check the test log"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
UT_Failed_Num=0
|
||||||
|
parse_unittest() {
|
||||||
|
res=$1
|
||||||
|
echo ${res}
|
||||||
|
echo Start to parse unittest results of $res
|
||||||
|
if [ -e $res ];then
|
||||||
|
tests=`cat $res | grep "<testsuites" | awk -F " " '{print $2;}' | awk -F "\"" '{print $2;}'`
|
||||||
|
fails=`cat $res | grep "<testsuites" | awk -F " " '{print $3;}' | awk -F "\"" '{print $2;}'`
|
||||||
|
times=`cat $res | grep "<testsuites" | awk -F " " '{print $6;}' | awk -F "\"" '{print $2;}'`
|
||||||
|
waste=`cat $res | grep "<testsuites" | awk -F " " '{print $7;}' | awk -F "\"" '{print $2;}'`
|
||||||
|
msg="Total testcases: $tests, failed: $fails,time:$waste seconds, at$times,xml:$res"
|
||||||
|
echo ${msg}
|
||||||
|
UT_Failed_Num=$((${UT_Failed_Num}+${fails}))
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
xmlcount=`ls $REPORT | wc -l`
|
||||||
|
xmlfiles=`ls $REPORT`
|
||||||
|
if [ ${xmlcount} -eq 0 ];
|
||||||
|
then echo There is nothing xml files generated at $REPORT
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
for file in $xmlfiles;do
|
||||||
|
parse_unittest $REPORT/$file
|
||||||
|
done
|
||||||
|
if [ ${UT_Failed_Num} = "0" ];then
|
||||||
|
echo Total $xmlcount files at $REPORT,all sucessful
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
echo Total $xmlcount files at $REPORT,${UT_Failed_Num} error cases
|
||||||
|
exit 2
|
||||||
|
fi
|
86
autotest/unitTest/run_unitTest.sh
Normal file
86
autotest/unitTest/run_unitTest.sh
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
AUTO_TEST_PATH=`pwd`
|
||||||
|
IOS=0
|
||||||
|
ANDROID=0
|
||||||
|
#Prepare GTEST
|
||||||
|
AUTO_TEST_SRC_PATH="../../"
|
||||||
|
cd ${AUTO_TEST_SRC_PATH}
|
||||||
|
if [ ! -d "./gtest" ]
|
||||||
|
then
|
||||||
|
make gtest-bootstrap
|
||||||
|
fi
|
||||||
|
cd ${AUTO_TEST_PATH}
|
||||||
|
#To find whether have android devices
|
||||||
|
echo 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}
|
||||||
|
if [ "#${ANDROID_SDK_PATH}" = "#" ]
|
||||||
|
then
|
||||||
|
echo Please set ANDROID_HOME with the path of Android SDK
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ "#${ANDROID_NDK_PATH}" = "#" ]
|
||||||
|
then
|
||||||
|
echo Please set ANDROID_NDK_HOME with the path of Android NDK
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
#prepare devices
|
||||||
|
ADB=${ANDROID_SDK_PATH}/platform-tools/adb
|
||||||
|
|
||||||
|
#get devices
|
||||||
|
devices=`$ADB devices | awk -F" " '/\tdevice/{print $1}'`
|
||||||
|
if [ "#$devices" = "#" ];then
|
||||||
|
echo "Can not find any android devices!"
|
||||||
|
else
|
||||||
|
echo Start to run the unittest on android devices
|
||||||
|
ANDROID=1
|
||||||
|
cd ./android
|
||||||
|
bash run_AutoTest_android.sh
|
||||||
|
cd ${AUTO_TEST_PATH}
|
||||||
|
if [ $? -ne 0 ];then
|
||||||
|
echo There is something wrong happened when runing unittest on android devices,please to check
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
#To find whether have ios devices
|
||||||
|
DEVICES=`system_profiler SPUSBDataType | sed -n -e '/iPad/,/Serial/p' -e '/iPhone/,/Serial/p' | grep "Serial Number:" | awk -F ": " '{print $2}'`
|
||||||
|
if [ "${DEVICES}#" == "#" ]
|
||||||
|
then
|
||||||
|
echo "Can not find any ios devices!"
|
||||||
|
else
|
||||||
|
echo Start to run the unittest on ios devices
|
||||||
|
IOS=1
|
||||||
|
cd ./ios
|
||||||
|
bash run_AutoTest_ios.sh
|
||||||
|
cd ${AUTO_TEST_PATH}
|
||||||
|
if [ $? -ne 0 ];then
|
||||||
|
echo There is something wrong happened when runing unittest on ios devices,please to check
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
#To parse the unit test result file to find whether have failures
|
||||||
|
if [ ${ANDROID} = "1" ];then
|
||||||
|
bash run_ParseUTxml.sh ./android/report
|
||||||
|
ret=$?
|
||||||
|
if [ ${ret} -eq 0 ];then
|
||||||
|
echo Unit test run on the android devices have not any failure case
|
||||||
|
elif [ ${ret} -eq 2 ];then
|
||||||
|
echo Unit test have cases failed,please check
|
||||||
|
elif [ ${ret} -eq 1 ];then
|
||||||
|
echo Unit test run failed
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if [ ${IOS} = "1" ];then
|
||||||
|
bash run_ParseUTxml.sh ./ios/report
|
||||||
|
ret=$?
|
||||||
|
if [ $ret -eq 0 ];then
|
||||||
|
echo Unit test run on the ios devices have not any failure case
|
||||||
|
elif [ $ret -eq 2 ];then
|
||||||
|
echo Unit test have cases failed,please check
|
||||||
|
elif [ $ret -eq 1 ];then
|
||||||
|
echo Unit test run failed
|
||||||
|
fi
|
||||||
|
fi
|
@ -22,7 +22,11 @@ bool YUVPixelDataGenerator (uint8_t* pPointer, int32_t iWidth, int32_t iHeight,
|
|||||||
}
|
}
|
||||||
|
|
||||||
FileInputStream fileStream;
|
FileInputStream fileStream;
|
||||||
|
#if defined(ANDROID_NDK)
|
||||||
|
if (!fileStream.Open ("/sdcard/res/CiscoVT2people_160x96_6fps.yuv")) {
|
||||||
|
#else
|
||||||
if (!fileStream.Open ("res/CiscoVT2people_160x96_6fps.yuv")) {
|
if (!fileStream.Open ("res/CiscoVT2people_160x96_6fps.yuv")) {
|
||||||
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (fileStream.read (sBuf.data(), kiFrameSize) == kiFrameSize) {
|
if (fileStream.read (sBuf.data(), kiFrameSize) == kiFrameSize) {
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#include "utils/InputStream.h"
|
#include "utils/InputStream.h"
|
||||||
#include "BaseDecoderTest.h"
|
#include "BaseDecoderTest.h"
|
||||||
#include "BaseEncoderTest.h"
|
#include "BaseEncoderTest.h"
|
||||||
|
#include <string>
|
||||||
static void UpdateHashFromFrame (const SFrameBSInfo& info, SHA1Context* ctx) {
|
static void UpdateHashFromFrame (const SFrameBSInfo& info, SHA1Context* ctx) {
|
||||||
for (int i = 0; i < info.iLayerNum; ++i) {
|
for (int i = 0; i < info.iLayerNum; ++i) {
|
||||||
const SLayerBSInfo& layerInfo = info.sLayerInfo[i];
|
const SLayerBSInfo& layerInfo = info.sLayerInfo[i];
|
||||||
@ -93,8 +93,12 @@ class DecodeEncodeTest : public ::testing::TestWithParam<DecodeEncodeFileParam>,
|
|||||||
|
|
||||||
TEST_P (DecodeEncodeTest, CompareOutput) {
|
TEST_P (DecodeEncodeTest, CompareOutput) {
|
||||||
DecodeEncodeFileParam p = GetParam();
|
DecodeEncodeFileParam p = GetParam();
|
||||||
|
#if defined(ANDROID_NDK)
|
||||||
|
std::string filename = std::string ("/sdcard/") + p.fileName;
|
||||||
|
ASSERT_TRUE (Open (filename.c_str()));
|
||||||
|
#else
|
||||||
ASSERT_TRUE (Open (p.fileName));
|
ASSERT_TRUE (Open (p.fileName));
|
||||||
|
#endif
|
||||||
EncodeStream (this, CAMERA_VIDEO_REAL_TIME, p.width, p.height, p.frameRate, SM_SINGLE_SLICE, false, 1, this);
|
EncodeStream (this, CAMERA_VIDEO_REAL_TIME, p.width, p.height, p.frameRate, SM_SINGLE_SLICE, false, 1, this);
|
||||||
unsigned char digest[SHA_DIGEST_LENGTH];
|
unsigned char digest[SHA_DIGEST_LENGTH];
|
||||||
SHA1Result (&ctx_, digest);
|
SHA1Result (&ctx_, digest);
|
||||||
@ -102,11 +106,11 @@ TEST_P (DecodeEncodeTest, CompareOutput) {
|
|||||||
CompareHash (digest, p.hashStr);
|
CompareHash (digest, p.hashStr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static const DecodeEncodeFileParam kFileParamArray[] = {
|
static const DecodeEncodeFileParam kFileParamArray[] = {
|
||||||
{"res/test_vd_1d.264", "a4c7299ec1a7bacd5819685e221a79ac2b56cdbc", 320, 192, 12.0f},
|
{"res/test_vd_1d.264", "a4c7299ec1a7bacd5819685e221a79ac2b56cdbc", 320, 192, 12.0f},
|
||||||
{"res/test_vd_rc.264", "106fd8cc978c1801b0d1f8297e9b7f17d5336e15", 320, 192, 12.0f},
|
{"res/test_vd_rc.264", "106fd8cc978c1801b0d1f8297e9b7f17d5336e15", 320, 192, 12.0f},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
INSTANTIATE_TEST_CASE_P (DecodeEncodeFile, DecodeEncodeTest,
|
INSTANTIATE_TEST_CASE_P (DecodeEncodeFile, DecodeEncodeTest,
|
||||||
::testing::ValuesIn (kFileParamArray));
|
::testing::ValuesIn (kFileParamArray));
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include "utils/HashFunctions.h"
|
#include "utils/HashFunctions.h"
|
||||||
#include "BaseDecoderTest.h"
|
#include "BaseDecoderTest.h"
|
||||||
|
#include <string>
|
||||||
|
|
||||||
static void UpdateHashFromPlane (SHA1Context* ctx, const uint8_t* plane,
|
static void UpdateHashFromPlane (SHA1Context* ctx, const uint8_t* plane,
|
||||||
int width, int height, int stride) {
|
int width, int height, int stride) {
|
||||||
@ -52,7 +53,12 @@ class DecoderOutputTest : public ::testing::WithParamInterface<FileParam>,
|
|||||||
|
|
||||||
TEST_P (DecoderOutputTest, CompareOutput) {
|
TEST_P (DecoderOutputTest, CompareOutput) {
|
||||||
FileParam p = GetParam();
|
FileParam p = GetParam();
|
||||||
|
#if defined(ANDROID_NDK)
|
||||||
|
std::string filename = std::string ("/sdcard/") + p.fileName;
|
||||||
|
DecodeFile (filename.c_str(), this);
|
||||||
|
#else
|
||||||
DecodeFile (p.fileName, this);
|
DecodeFile (p.fileName, this);
|
||||||
|
#endif
|
||||||
|
|
||||||
unsigned char digest[SHA_DIGEST_LENGTH];
|
unsigned char digest[SHA_DIGEST_LENGTH];
|
||||||
SHA1Result (&ctx_, digest);
|
SHA1Result (&ctx_, digest);
|
||||||
@ -60,7 +66,6 @@ TEST_P (DecoderOutputTest, CompareOutput) {
|
|||||||
CompareHash (digest, p.hashStr);
|
CompareHash (digest, p.hashStr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static const FileParam kFileParamArray[] = {
|
static const FileParam kFileParamArray[] = {
|
||||||
{"res/test_vd_1d.264", "5827d2338b79ff82cd091c707823e466197281d3"},
|
{"res/test_vd_1d.264", "5827d2338b79ff82cd091c707823e466197281d3"},
|
||||||
{"res/test_vd_rc.264", "eea02e97bfec89d0418593a8abaaf55d02eaa1ca"},
|
{"res/test_vd_rc.264", "eea02e97bfec89d0418593a8abaaf55d02eaa1ca"},
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include "utils/HashFunctions.h"
|
#include "utils/HashFunctions.h"
|
||||||
#include "BaseEncoderTest.h"
|
#include "BaseEncoderTest.h"
|
||||||
|
#include <string>
|
||||||
static void UpdateHashFromFrame (const SFrameBSInfo& info, SHA1Context* ctx) {
|
static void UpdateHashFromFrame (const SFrameBSInfo& info, SHA1Context* ctx) {
|
||||||
for (int i = 0; i < info.iLayerNum; ++i) {
|
for (int i = 0; i < info.iLayerNum; ++i) {
|
||||||
const SLayerBSInfo& layerInfo = info.sLayerInfo[i];
|
const SLayerBSInfo& layerInfo = info.sLayerInfo[i];
|
||||||
@ -57,8 +57,12 @@ class EncoderOutputTest : public ::testing::WithParamInterface<EncodeFileParam>,
|
|||||||
|
|
||||||
TEST_P (EncoderOutputTest, CompareOutput) {
|
TEST_P (EncoderOutputTest, CompareOutput) {
|
||||||
EncodeFileParam p = GetParam();
|
EncodeFileParam p = GetParam();
|
||||||
|
#if defined(ANDROID_NDK)
|
||||||
|
std::string filename = std::string ("/sdcard/") + p.fileName;
|
||||||
|
EncodeFile (filename.c_str(), p.usageType , p.width, p.height, p.frameRate, p.slices, p.denoise, p.layers, this);
|
||||||
|
#else
|
||||||
EncodeFile (p.fileName, p.usageType , p.width, p.height, p.frameRate, p.slices, p.denoise, p.layers, this);
|
EncodeFile (p.fileName, p.usageType , p.width, p.height, p.frameRate, p.slices, p.denoise, p.layers, this);
|
||||||
|
#endif
|
||||||
//will remove this after screen content algorithms are ready,
|
//will remove this after screen content algorithms are ready,
|
||||||
//because the bitstream output will vary when the different algorithms are added.
|
//because the bitstream output will vary when the different algorithms are added.
|
||||||
unsigned char digest[SHA_DIGEST_LENGTH];
|
unsigned char digest[SHA_DIGEST_LENGTH];
|
||||||
@ -67,7 +71,6 @@ TEST_P (EncoderOutputTest, CompareOutput) {
|
|||||||
CompareHash (digest, p.hashStr);
|
CompareHash (digest, p.hashStr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static const EncodeFileParam kFileParamArray[] = {
|
static const EncodeFileParam kFileParamArray[] = {
|
||||||
{
|
{
|
||||||
"res/CiscoVT2people_320x192_12fps.yuv",
|
"res/CiscoVT2people_320x192_12fps.yuv",
|
||||||
|
@ -28,6 +28,8 @@ public class MainActivity extends Activity {
|
|||||||
@Override
|
@Override
|
||||||
public void onDestroy()
|
public void onDestroy()
|
||||||
{
|
{
|
||||||
|
super.onDestroy();
|
||||||
|
Log.i("codec_unittest","OnDestroy");
|
||||||
Process.killProcess(Process.myPid());
|
Process.killProcess(Process.myPid());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,7 +57,6 @@ public class MainActivity extends Activity {
|
|||||||
Log.i("codec_unittest","codec unittest runing @"+path);
|
Log.i("codec_unittest","codec unittest runing @"+path);
|
||||||
DoUnittest("/sdcard", path);
|
DoUnittest("/sdcard", path);
|
||||||
Log.i("codec_unittest","codec unittest end");
|
Log.i("codec_unittest","codec unittest end");
|
||||||
Process.killProcess(Process.myPid());
|
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
extern int CodecUtMain(int argc, char** argv);
|
extern int CodecUtMain(int argc, char** argv);
|
||||||
|
|
||||||
|
|
||||||
int GetDocumentPath(char *pPath, unsigned long *pLen)
|
int DoTest(char *pPath, unsigned long *pLen)
|
||||||
{
|
{
|
||||||
if (!pLen) return 1;
|
if (!pLen) return 1;
|
||||||
unsigned long uPathLen = *pLen;
|
unsigned long uPathLen = *pLen;
|
||||||
@ -27,10 +27,17 @@ int GetDocumentPath(char *pPath, unsigned long *pLen)
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
NSString* document = [paths objectAtIndex:0];
|
NSString* document = [paths objectAtIndex:0];
|
||||||
|
NSFileManager* manager = [NSFileManager defaultManager];
|
||||||
|
[manager changeCurrentDirectoryPath:[document stringByExpandingTildeInPath]];
|
||||||
NSString* escapedPath = [document stringByReplacingOccurrencesOfString:@" " withString:@"\\ "];
|
NSString* escapedPath = [document stringByReplacingOccurrencesOfString:@" " withString:@"\\ "];
|
||||||
unsigned long uDocumentPathLen = [escapedPath length];
|
unsigned long uDocumentPathLen = [escapedPath length];
|
||||||
uPathLen= (uDocumentPathLen <= uPathLen) ? uDocumentPathLen : uPathLen;
|
uPathLen= (uDocumentPathLen <= uPathLen) ? uDocumentPathLen : uPathLen;
|
||||||
memcpy(pPath,[escapedPath UTF8String],uPathLen);
|
memcpy(pPath,[escapedPath UTF8String],uPathLen);
|
||||||
|
char path[1024] = "";
|
||||||
|
sprintf(path, "%s%s",pPath,"/codec_unittest.xml");
|
||||||
|
int argc =2;
|
||||||
|
char* argv[]={(char*)"codec_unittest",path};
|
||||||
|
CodecUtMain(argc,argv);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,18 +49,22 @@ int main(int argc, char * argv[])
|
|||||||
//Call the UT
|
//Call the UT
|
||||||
#ifdef IOS_SIMULATOR
|
#ifdef IOS_SIMULATOR
|
||||||
const char* path="/tmp/codec_unittest.xml";
|
const char* path="/tmp/codec_unittest.xml";
|
||||||
#else
|
|
||||||
char xmlWritePath[1024] = "";
|
|
||||||
unsigned long uPathLen = 1024;
|
|
||||||
char path[1024] = "";
|
|
||||||
GetDocumentPath(xmlWritePath,&uPathLen);
|
|
||||||
sprintf(path, "%s%s",xmlWritePath,"/codec_unittest.xml");
|
|
||||||
#endif
|
|
||||||
argc =2;
|
argc =2;
|
||||||
argv[0]=(char*)"codec_unittest";
|
argv[0]=(char*)"codec_unittest";
|
||||||
argv[1]=path;
|
argv[1]=path;
|
||||||
CodecUtMain(argc,argv);
|
CodecUtMain(argc,argv);
|
||||||
abort();
|
abort();
|
||||||
|
#else
|
||||||
|
char xmlWritePath[1024] = "";
|
||||||
|
unsigned long uPathLen = 1024;
|
||||||
|
if(DoTest(xmlWritePath,&uPathLen) == 0)
|
||||||
|
NSLog(@"Unit test running sucessfully on devices");
|
||||||
|
else
|
||||||
|
NSLog(@"Unit test runing failed on devices");
|
||||||
|
abort();
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
|
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user