Yohei Yukawa | 8855306 | 2014-04-02 16:17:25 +0900 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # Copyright 2014, The Android Open Source Project |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | |
Yohei Yukawa | 7f4cca0 | 2014-06-20 16:26:13 +0900 | [diff] [blame] | 16 | function usage() { |
| 17 | echo "usage: source run-tests.sh [--host] [--target] [-h] [--help]" 1>&2 |
| 18 | echo " --host: run test on the host environment" 1>&2 |
| 19 | echo " --no-host: skip host test" 1>&2 |
| 20 | echo " --target: run test on the target environment" 1>&2 |
| 21 | echo " --no-target: skip target device test" 1>&2 |
| 22 | } |
| 23 | |
| 24 | # check script arguments |
Yohei Yukawa | 8855306 | 2014-04-02 16:17:25 +0900 | [diff] [blame] | 25 | if [[ $(type -t mmm) != function ]]; then |
Yohei Yukawa | 7f4cca0 | 2014-06-20 16:26:13 +0900 | [diff] [blame] | 26 | usage |
Yohei Yukawa | c73b46f | 2014-04-02 19:46:05 +0900 | [diff] [blame] | 27 | if [[ ${BASH_SOURCE[0]} != $0 ]]; then return; else exit 1; fi |
Yohei Yukawa | 8855306 | 2014-04-02 16:17:25 +0900 | [diff] [blame] | 28 | fi |
| 29 | |
Yohei Yukawa | 7f4cca0 | 2014-06-20 16:26:13 +0900 | [diff] [blame] | 30 | show_usage=no |
| 31 | enable_host_test=yes |
| 32 | enable_target_device_test=no |
| 33 | while [ "$1" != "" ] |
| 34 | do |
| 35 | case "$1" in |
| 36 | "-h") show_usage=yes;; |
| 37 | "--help") show_usage=yes;; |
| 38 | "--target") enable_target_device_test=yes;; |
| 39 | "--no-target") enable_target_device_test=no;; |
| 40 | "--host") enable_host_test=yes;; |
| 41 | "--no-host") enable_host_test=no;; |
| 42 | esac |
| 43 | shift |
| 44 | done |
| 45 | |
| 46 | if [[ $show_usage == yes ]]; then |
| 47 | usage |
| 48 | if [[ ${BASH_SOURCE[0]} != $0 ]]; then return; else exit 1; fi |
| 49 | fi |
| 50 | |
Yohei Yukawa | ba35bb8 | 2014-10-23 17:58:00 +0900 | [diff] [blame] | 51 | # Host build is never supported in unbundled (NDK/tapas) build |
| 52 | if [[ $enable_host_test == yes && -n $TARGET_BUILD_APPS ]]; then |
| 53 | echo "Host build is never supported in tapas build." 1>&2 |
| 54 | echo "Use lunch command instead." 1>&2 |
| 55 | if [[ ${BASH_SOURCE[0]} != $0 ]]; then return; else exit 1; fi |
| 56 | fi |
| 57 | |
Yohei Yukawa | 7f4cca0 | 2014-06-20 16:26:13 +0900 | [diff] [blame] | 58 | target_test_name=liblatinime_target_unittests |
| 59 | host_test_name=liblatinime_host_unittests |
| 60 | |
Yohei Yukawa | 8855306 | 2014-04-02 16:17:25 +0900 | [diff] [blame] | 61 | pushd $PWD > /dev/null |
| 62 | cd $(gettop) |
| 63 | mmm -j16 packages/inputmethods/LatinIME/native/jni || \ |
Yohei Yukawa | 7f4cca0 | 2014-06-20 16:26:13 +0900 | [diff] [blame] | 64 | make -j16 adb $target_test_name $host_test_name |
| 65 | if [[ $enable_host_test == yes ]]; then |
| 66 | $ANDROID_HOST_OUT/bin/$host_test_name |
| 67 | fi |
| 68 | if [[ $enable_target_device_test == yes ]]; then |
| 69 | target_test_local=$ANDROID_PRODUCT_OUT/data/nativetest/$target_test_name/$target_test_name |
| 70 | target_test_device=/data/nativetest/$target_test_name/$target_test_name |
| 71 | adb push $target_test_local $target_test_device |
| 72 | adb shell $target_test_device |
| 73 | adb shell rm -rf $target_test_device |
| 74 | fi |
| 75 | popd > /dev/null |