From acf8da4f666a54c7eceb55491b3d90454e8349d0 Mon Sep 17 00:00:00 2001 From: Chase Qi Date: Wed, 18 Mar 2015 08:31:23 +0000 Subject: android: upgrade gtest definitions Added repeatedly run support. Use test duration as measurement. Change-Id: I26aae98ef5713ecd9020259dcf5d8924749dc6c7 Signed-off-by: Chase Qi --- android/gtest.yaml | 6 ++-- android/scripts/gtest.sh | 84 +++++++++++++++++++++++++++++------------------- 2 files changed, 55 insertions(+), 35 deletions(-) diff --git a/android/gtest.yaml b/android/gtest.yaml index c4a40fe..2f152b0 100644 --- a/android/gtest.yaml +++ b/android/gtest.yaml @@ -18,9 +18,11 @@ metadata: - ifc6410 params: - # Use absolute path and modify the TESTS parameter in JSON file to run other or 64bit test programs. + # Use absolute path and modify the TESTS parameter in test plan to run other or 64bit test programs. TESTS: '/data/nativetest/ion-unit-tests/ion-unit-tests /data/nativetest/backtrace_test/backtrace_test' + # Change the value of LOOPS parameter in test plan to run test program multiple times. + LOOPS: 1 run: steps: - - ./android/scripts/gtest.sh "$TESTS" + - ./android/scripts/gtest.sh "$TESTS" $LOOPS diff --git a/android/scripts/gtest.sh b/android/scripts/gtest.sh index 159aeb0..a57b2c4 100755 --- a/android/scripts/gtest.sh +++ b/android/scripts/gtest.sh @@ -23,7 +23,7 @@ # TESTS=$1 -ScriptDIR=`pwd` +ScriptDIR="`pwd`" FilesDIR="/data/data/org.linaro.gparser/files" # Download and install gparser.apk @@ -31,50 +31,68 @@ wget http://testdata.validation.linaro.org/tools/gparser.apk chmod -R 777 $ScriptDIR pm install "$ScriptDIR/gparser.apk" mkdir $FilesDIR +# Print the most recent 50 lines and exit logcat +logcat -t 50 for i in $TESTS; do # Use the last field as test case name, NF refers to the # number of fields of the whole string. - TestCaseName=`echo $i |awk -F '/' '{print $NF}'` - chmod 755 $i - # Nonzero exit code will terminate test script, use "||true" as work around. - $i --gtest_output="xml:$ScriptDIR/$TestCaseName.xml" || true - if [ -f $ScriptDIR/$TestCaseName.xml ]; then - echo "Generated XML report successfully." + TestCaseName="`echo $i |awk -F '/' '{print $NF}'`" + + if [ -f $i ]; then + chmod 755 $i + LOOPS=$2 + Count=1 else - echo "$TestCaseName XML report NOT found." + echo "$i file NOT found." lava-test-case $TestCaseName --result fail continue fi - # Parse test result. - cp $ScriptDIR/$TestCaseName.xml $FilesDIR/TestResults.xml - chmod -R 777 $FilesDIR - - # Start gparser MainActivity, TestResults.xml will be parsed automatically. - # Parsed result will be saved as ParsedTestResults.txt under the same directory. - am start -n org.linaro.gparser/.MainActivity - sleep 15 - # Stop gparser for the next loop. - am force-stop org.linaro.gparser + while [ $Count -le $LOOPS ]; do + # Run tests. + echo "Running $TestCaseName tests (iteration $Count) . . ." + # Nonzero exit code will terminate test script, use "||true" as work around. + $i --gtest_output="xml:$ScriptDIR/$TestCaseName-$Count.xml" || true + if [ -f $ScriptDIR/$TestCaseName-$Count.xml ]; then + echo "Generated XML report successfully." + else + echo "$TestCaseName-$Count XML report NOT found." + lava-test-case $TestCaseName --result fail + continue + fi - if [ -f $FilesDIR/ParsedTestResults.txt ]; then - echo "XML report parsed successfully." - mv $FilesDIR/ParsedTestResults.txt $ScriptDIR/$TestCaseName.ParsedTestResults.txt - else - echo "Failed to parse $TestCaseName test result." - lava-test-case $TestCaseName --result fail - continue - fi + # Parse test result. + cp $ScriptDIR/$TestCaseName-$Count.xml $FilesDIR/TestResults.xml + chmod -R 777 $FilesDIR + # Start gparser MainActivity, TestResults.xml will be parsed automatically. + # Parsed result will be saved as ParsedTestResults.txt under the same directory. + am start -n org.linaro.gparser/.MainActivity + sleep 15 + # Stop gparser for the next loop. + am force-stop org.linaro.gparser + # Print the most recent 50 lines and exit logcat + logcat -t 50 + if [ -f $FilesDIR/ParsedTestResults.txt ]; then + echo "XML report parsed successfully." + mv $FilesDIR/ParsedTestResults.txt $ScriptDIR/$TestCaseName-$Count.ParsedTestResults.txt + else + echo "Failed to parse $TestCaseName-$Count test result." + lava-test-case $TestCaseName --result fail + continue + fi - # Collect test results. - while read line; do - TestCaseID=`echo $line | awk '{print $1}'` - TestResult=`echo $line | awk '{print $2}'` + # Collect test results. + while read line; do + TestCaseID="`echo $line | awk '{print $1}'`" + TestResult="`echo $line | awk '{print $2}'`" + TestDuration="`echo $line | awk '{print $3}'`" + # Use test case name as prefix to amend TestCaseID. + lava-test-case $TestCaseName.$TestCaseID --result $TestResult --measurement $TestDuration --units s + done < $ScriptDIR/$TestCaseName-$Count.ParsedTestResults.txt - # Use test case name as prefix to amend TestCaseID. - lava-test-case $TestCaseName.$TestCaseID --result $TestResult - done < $ScriptDIR/$TestCaseName.ParsedTestResults.txt + Count=$((Count+1)) + done done # Uninstall gparser -- cgit v1.2.3