• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2
3##############################################################
4#Build ios test ref app
5
6#set the default configuration
7CODEC_TEST_IOS_ARCH="armv7"
8CODEC_TEST_IOS_PLATFORM="iphoneos"
9CODEC_TEST_IOS_DEBUG_RELEASE="Release"
10CODEC_TEST_IOS_REPORT_SUBFOLDER="release"
11
12
13buildXcodeProject()
14{
15 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
16
17if [ $? -eq 0 ]; then
18 echo "build $1 $3 successfully"
19 else
20 echo "build $1 $3  fail"
21 exit 1
22 fi
23}
24
25
26
27iosUnitTest()
28{
29
30if [ $# -gt 2 ]; then
31echo "Please use command $0 [armv7/armv7s/arm64] [release/debug]"
32exit 1
33fi
34
35     CODEC_TEST_XCODE_PROJECT_NAME="${AUTO_TEST_SRC_PATH}/test/build/ios/codec_unittest/codec_unittest.xcodeproj/"
36     CODEC_TEST_IOS_PROJECT_NAME="codec_unittest"
37     CODEC_TEST_IOS_PROJECT_PATH="${AUTO_TEST_SRC_PATH}/test/build/ios/codec_unittest/build"
38     CODEC_TEST_IOS_APP=${CODEC_TEST_IOS_PROJECT_PATH}/${CODEC_TEST_IOS_DEBUG_RELEASE}-iphoneos/${CODEC_TEST_IOS_PROJECT_NAME}.app
39     CODEC_TEST_IOS_APP_ID="com.cisco.codec-unittest"
40     CODEC_TEST_RES=${AUTO_TEST_SRC_PATH}/res
41     CODEC_TEST_LOG="codec_unittest"
42for PARAM in $*; do
43   if [ "release" = "${PARAM}" ]; then
44     CODEC_TEST_IOS_DEBUG_RELEASE="Release"
45     CODEC_TEST_IOS_REPORT_SUBFOLDER="release"
46 elif [ "debug" = "${PARAM}" ]; then
47     CODEC_TEST_IOS_DEBUG_RELEASE="Debug"
48     CODEC_TEST_IOS_REPORT_SUBFOLDER="debug"
49 elif [ "armv7" = "${PARAM}" ];then
50      CODEC_TEST_IOS_ARCH="armv7"
51 elif [ "armv7s" = "${PARAM}" ];then
52     CODEC_TEST_IOS_ARCH="armv7s"
53 elif [ "arm64" = "${PARAM}" ];then
54    CODEC_TEST_IOS_ARCH="arm64"
55 else
56    echo parameters are illegal!!!, please have a check.
57    exit 1
58 fi
59 done
60cd ${AUTO_TEST_SRC_PATH}
61IOS_MAKE_PARAMS="OS=ios ARCH=${CODEC_TEST_IOS_ARCH}"
62############make build
63find ./ -name *.o -exec rm -rf {} \;
64find ./ -name *.d -exec rm -rf {} \;
65rm -f *.so
66make clean
67make ${IOS_MAKE_PARAMS} test
68echo "Codec test will run on ${CODEC_TEST_IOS_PLATFORM} with ${CODEC_TEST_IOS_DEBUG_RELEASE}"
69cd ${AUTO_TEST_IOS_PATH}
70buildXcodeProject ${CODEC_TEST_XCODE_PROJECT_NAME} ${CODEC_TEST_IOS_PROJECT_NAME} ${CODEC_TEST_IOS_DEBUG_RELEASE} ${CODEC_TEST_IOS_PLATFORM}
71
72
73
74
75##############run on ios devices#########################
76# for real device
77if [ ! -d ${CODEC_TEST_IOS_APP} ] ; then
78echo "${CODEC_TEST_IOS_APP} is not found"
79exit 1
80else
81echo "Find app ${CODEC_TEST_IOS_APP}"
82fi
83
84 #ensure instruments not runing
85echo "Try to kill the runing instruments"
86pids_str=`ps x -o pid,command | grep -v grep | grep "instruments" | awk '{printf "%s,", $1}'`
87instruments_pids="${pids_str//,/ }"
88for pid in ${instruments_pids}; do
89echo "Found instruments ${pid}. Killing..."
90kill -9 ${pid} && wait ${pid} &> /dev/null
91done
92
93
94
95DEVICES=`system_profiler SPUSBDataType | sed -n -e '/iPad/,/Serial/p' -e '/iPhone/,/Serial/p' | grep "Serial Number:" | awk -F ": " '{print $2}'`
96if [ "${DEVICES}#" == "#" ]
97then
98echo "Can not find any connected device! please check device is connected to MAC!"
99exit 1
100else
101rand=`date +%s`
102for DEVICE_ID in ${DEVICES}
103do
104echo "Try to run on device:${DEVICE_ID}"
105
106#uninstall the application from device to remove the last result
107${AUTO_TEST_IOS_SCRIPT_PATH}/fruitstrap uninstall --bundle ${CODEC_TEST_IOS_APP_ID} --id ${DEVICE_ID}
108if [ $? -ne 0 ]; then
109echo uninstall application: ${CODEC_TEST_IOS_APP} from device: ${DEVICE_ID} is failed!
110fi
111#install the application
112${AUTO_TEST_IOS_SCRIPT_PATH}/fruitstrap install --bundle ${CODEC_TEST_IOS_APP} --id ${DEVICE_ID}
113if [ $? -ne 0 ]; then
114echo install application: ${CODEC_TEST_IOS_APP} to device: ${DEVICE_ID} is failed!
115exit 1
116fi
117
118${AUTO_TEST_IOS_SCRIPT_PATH}/iFileTransfer -o copy -id ${DEVICE_ID} -app ${CODEC_TEST_IOS_APP_ID} -from ${CODEC_TEST_RES}
119instruments -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/
120#copy to report folder
121${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
122if [ $? -ne 0 ]; then
123echo "download file: ${CODEC_TEST_LOG}.xml from ${CODEC_TEST_IOS_APP_ID} is failed!"
124exit 1
125fi
126
127done
128fi
129}
130
131AUTO_TEST_IOS_PATH=`pwd`
132AUTO_TEST_SRC_PATH="../../.."
133AUTO_TEST_IOS_SCRIPT_PATH="../../performanceTest/ios"
134CODEC_TEST_IOS_REPORT_PATH="${AUTO_TEST_IOS_PATH}/report"
135if [ ! -d ${CODEC_TEST_IOS_REPORT_PATH} ]
136then
137 mkdir -p ${CODEC_TEST_IOS_REPORT_PATH}
138else
139 echo "Will delete those outdate xml in the report"
140 rm -f ${CODEC_TEST_IOS_REPORT_PATH}/*.xml
141fi
142
143#start to run unittest,default run the xcode at arch armv7 with release
144iosUnitTest armv7 release
145
146if [ $? -ne 0 ]; then
147echo "Running Unittest demo with armv7 is failed!"
148exit 1
149else
150echo Finished unittest with armv7 on ios devices
151echo the test result is generated at ./ios/report/xx.xml
152fi
153#start to run unittest,run the xcode at arch arm64 with release
154iosUnitTest arm64 release
155if [ $? -ne 0 ]; then
156echo "Running Unittest demo with arm64 is failed!"
157exit 1
158else
159echo Finished unittest with arm64 on ios devices
160echo the test result is generated at ./ios/report/xx.xml
161fi
162
163echo xxxxxxxxxxxxxxxxxxxxxxxxxxxxIOS unittest  Endxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
164
165#TODO:according to the trace of instruments to do some analysis
166#find ${AUTO_TEST_IOS_SCRIPT_PATH} -name *.trace -exec rm -rf {} \;
167rm -rf *.trace
168