1#!/bin/sh
2
3BASE_DIR=`dirname $0`
4OPENCV_TEST_PATH=$BASE_DIR/@TEST_PATH@
5OPENCV_TEST_DATA_PATH=$BASE_DIR/sdk/etc/testdata/
6
7if [ $# -ne 1 ]; then
8  echo "Device architecture is not preset in command line"
9  echo "Tests are available for architectures: `ls -m ${OPENCV_TEST_PATH}`"
10  echo "Usage: $0 <target_device_arch>"
11  return 1
12else
13  TARGET_ARCH=$1
14fi
15
16if [ -z `which adb` ]; then
17  echo "adb command was not found in PATH"
18  return 1
19fi
20
21adb push $OPENCV_TEST_DATA_PATH /sdcard/opencv_testdata
22
23adb shell "mkdir -p /data/local/tmp/opencv_test"
24SUMMARY_STATUS=0
25for t in "$OPENCV_TEST_PATH/$TARGET_ARCH/"opencv_test_* "$OPENCV_TEST_PATH/$TARGET_ARCH/"opencv_perf_*;
26do
27  test_name=`basename "$t"`
28  report="$test_name-`date --rfc-3339=date`.xml"
29  adb push $t /data/local/tmp/opencv_test/
30  adb shell "export OPENCV_TEST_DATA_PATH=/sdcard/opencv_testdata && /data/local/tmp/opencv_test/$test_name --perf_min_samples=1 --perf_force_samples=1 --gtest_output=xml:/data/local/tmp/opencv_test/$report"
31  adb pull "/data/local/tmp/opencv_test/$report" $report
32  TEST_STATUS=0
33  if [ -e $report ]; then
34    if [ `grep -c "<fail" $report` -ne 0 ]; then
35      TEST_STATUS=2
36    fi
37  else
38    TEST_STATUS=3
39  fi
40  if [ $TEST_STATUS -ne 0 ]; then
41    SUMMARY_STATUS=$TEST_STATUS
42  fi
43done
44
45if [ $SUMMARY_STATUS -eq 0 ]; then
46  echo "All OpenCV tests finished successfully"
47else
48  echo "OpenCV tests finished with status $SUMMARY_STATUS"
49fi
50
51return $SUMMARY_STATUS