linphone-android/liblinphone_tester/custom_rules.xml

84 lines
2.7 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<project name="custom_rules" xmlns:unless="ant:unless">
<target name="run">
<exec executable="adb">
<arg value="shell" />
<arg value="am" />
<arg value="start" />
<arg value="-a" />
<arg value="android.intent.action.MAIN" />
<arg value="-n" />
<arg value="org.linphone.tester/org.linphone.tester.MainActivity" />
</exec>
</target>
<target name="test">
<property name="output.file" value="./tests.output" />
<tstamp>
<format property="archive.name" pattern="'liblinphonetester_'yyyyMMdd_HHmmss" />
</tstamp>
<echo>Adb log files are put in ${archive.name}.zip</echo>
<!-- Ensure that adb is killed before running anything. This is needed in case
the previous execution crashed (while adb still running) because adb will not be able to list atached devices
until any adb is running -->
<exec executable="bash" >
<arg value="-c" />
<arg value="killall adb" />
</exec>
<exec executable="adb" >
<arg value="logcat" />
<arg value="-c" />
</exec>
<exec executable="./adb-log-start.sh" >
<arg value=" ${archive.name}" />
</exec>
<exec executable="bash">
<arg value="-c"/>
<!-- use 'tee' command to write in file AND on stdout.
First is used below to check if tests failed or not while second
is used to get output in real time -->
<arg value="adb shell am instrument -r -w org.linphone.tester/org.linphone.tester.TestRunner | tee ${output.file}"/>
</exec>
<exec executable="bash" >
<arg value="-c" />
<arg value="kill `cat adb.pid`" />
</exec>
<condition property="has.crashed" >
<or>
<resourcecontains resource="${output.file}" substring="Process crashed" />
<resourcecontains resource="${output.file}" substring="Native crash" />
</or>
</condition>
<exec executable="bash" unless:set="has.crashed">
<arg value="-c"/>
<arg value="adb shell run-as org.linphone.tester cat /data/data/org.linphone.tester/files/junit-report.xml > liblinphone-junit-report.xml"/>
</exec>
<zip destfile="${archive.name}.zip">
<fileset dir="." includes="${archive.name}"/>
</zip>
<antcall target="check-for-crash"/>
<fail message="Tests failed">
<condition>
<resourcecontains resource="${output.file}" substring="FAILURES" />
</condition>
</fail>
<delete file="${archive.name}"/>
<delete file="${output.file}"/>
</target>
<target name="check-for-crash" if="has.crashed">
<exec executable="bash" >
<arg value="-c" />
<arg value="tail -n 500 ${archive.name}" />
</exec>
<exec executable="bash" >
<arg value="-c" />
<arg value="cat ${archive.name} |ndk-stack -sym obj/local/`adb shell getprop ro.product.cpu.abi | tr -d '\r'`" />
</exec>
<fail message="Tests crashed"/>
</target>
</project>