Factorize UI tests for Android and use separate log files

This commit is contained in:
Gautier Pelloux-Prayer 2015-01-28 14:44:10 +01:00
parent d1d72b7157
commit d6fd0204b4
3 changed files with 57 additions and 59 deletions

2
.gitignore vendored
View file

@ -17,7 +17,7 @@ liblinphone-junit-report.xml
liblinphonetester_*.zip liblinphonetester_*.zip
libs libs
linphone-android.iml linphone-android.iml
linphone-junit-report.xml linphone-junit-report*.xml
linphonetester_*.zip linphonetester_*.zip
lint.xml lint.xml
local.properties local.properties

View file

@ -17,11 +17,9 @@ all: clean
$(ANT) debug install $(ANT) debug install
run-basic-tests: all run-basic-tests: all
$(ANT) test $(ANT) test -Dtest.size=small
adb shell run-as org.linphone cat /data/data/org.linphone/files/junit-report.xml 2>/dev/null > linphone-junit-report.xml
if [ ! -s linphone-junit-report.xml ]; then exit 1; fi if [ ! -s linphone-junit-report.xml ]; then exit 1; fi
run-all-tests: all run-all-tests: all
adb shell am instrument -w -e size large org.linphone.test/com.zutubi.android.junitreport.JUnitReportTestRunner $(ANT) test -Dtest.size=large
adb shell run-as org.linphone cat /data/data/org.linphone/files/junit-report.xml 2>/dev/null > linphone-junit-report.xml
if [ ! -s linphone-junit-report.xml ]; then exit 1; fi if [ ! -s linphone-junit-report.xml ]; then exit 1; fi

View file

@ -1,60 +1,60 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project name="custom_rules"> <project name="linphone-tester">
<target name="test"> <target name="test">
<property name="output.file" value="./tests.output" /> <property name="output.file" value="./tests.output" />
<tstamp> <!-- Possible values for test.size are small or large -->
<format property="archive.name" <property name="test.size" value="small" />
pattern="'linphonetester_'yyyyMMdd_HHmmss" /> <tstamp>
</tstamp> <format property="archive.name" pattern="'linphonetester_'yyyyMMdd_HHmmss" />
<echo>Adb log files are put in ${archive.name}.zip</echo> </tstamp>
<echo>Adb log files are put in ${archive.name}.zip</echo>
<exec executable="adb" > <exec executable="adb" >
<arg value="logcat" /> <arg value="logcat" />
<arg value="-c" /> <arg value="-c" />
</exec> </exec>
<exec executable="./adb-log-start.sh" > <exec executable="./adb-log-start.sh" >
<arg value=" ${archive.name}" /> <arg value=" ${archive.name}" />
</exec> </exec>
<exec executable="bash"> <exec executable="bash">
<arg value="-c"/> <arg value="-c"/>
<!-- use 'tee' command to write in file AND on stdout. <!-- use 'tee' command to write in file AND on stdout.
First is used below to check if tests failed or not while second First is used below to check if tests failed or not while second
is used to get output in real time --> is used to get output in real time -->
<arg value="adb shell am instrument -r -w -e size small org.linphone.test/com.zutubi.android.junitreport.JUnitReportTestRunner | tee ${output.file}"/> <arg value="adb shell am instrument -r -w -e size ${test.size} org.linphone.test/com.zutubi.android.junitreport.JUnitReportTestRunner | tee ${output.file}"/>
</exec> </exec>
<exec executable="bash" > <exec executable="bash" >
<arg value="-c" /> <arg value="-c" />
<arg value="kill `cat adb.pid`" /> <arg value="kill `cat adb.pid`" />
</exec> </exec>
<exec executable="bash"> <exec executable="bash">
<arg value="-c"/> <arg value="-c"/>
<arg value="adb shell run-as org.linphone cat /data/data/org.linphone/files/junit-report.xml > linphone-junit-report.xml"/> <arg value="adb shell run-as org.linphone cat /data/data/org.linphone/files/junit-report.xml > linphone-junit-report-${test.size}.xml"/>
</exec> </exec>
<zip destfile="${archive.name}.zip"> <zip destfile="${archive.name}.zip">
<fileset dir="." includes="${archive.name}"/> <fileset dir="." includes="${archive.name}"/>
</zip> </zip>
<fail message="Tests failed"> <fail message="Tests failed">
<condition> <condition>
<resourcecontains resource="${output.file}" substring="FAILURES" /> <resourcecontains resource="${output.file}" substring="FAILURES" />
</condition> </condition>
</fail> </fail>
<condition property="has.crashed" > <condition property="has.crashed" >
<resourcecontains resource="${output.file}" substring="Process crashed" /> <resourcecontains resource="${output.file}" substring="Process crashed" />
</condition> </condition>
<antcall target="check-for-crash"/> <antcall target="check-for-crash"/>
<delete file="${archive.name}"/> <delete file="${archive.name}"/>
<delete file="${output.file}"/> <delete file="${output.file}"/>
</target> </target>
<target name="check-for-crash" if="has.crashed"> <target name="check-for-crash" if="has.crashed">
<exec executable="bash" > <exec executable="bash" >
<arg value="-c" /> <arg value="-c" />
<arg value="tail -n 500 ${archive.name}" /> <arg value="tail -n 500 ${archive.name}" />
</exec> </exec>
<exec executable="bash" > <exec executable="bash" >
<arg value="-c" /> <arg value="-c" />
<arg value="cat ${archive.name} |ndk-stack -sym obj/local/`adb shell getprop ro.product.cpu.abi | tr -d '\r'`" /> <arg value="cat ${archive.name} |ndk-stack -sym obj/local/`adb shell getprop ro.product.cpu.abi | tr -d '\r'`" />
</exec> </exec>
<fail message="Tests crashed"/> <fail message="Tests crashed"/>
</target> </target>
</project> </project>