aboutsummaryrefslogtreecommitdiff
path: root/tests/test_art_host.sh
blob: be4c915aae2ae00762498cc5ac4c2770d15b4c38 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!/bin/bash
#
# Copyright (c) 2016-2017, Linaro Ltd.
# All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# ART Host tests.
#
# Jenkins link:
# Not used by Jenkins yet.

readonly local_path=$(dirname "$0")
source "${local_path}/../utils/utils.sh"
source "${local_path}/../utils/utils_test.sh"
source "${local_path}/../utils/utils_android.sh"
source "${local_path}/../utils/utils_android_root.sh"

readonly timer_name="Host Test"
readonly default_lunch_target="aosp_arm64-eng"

usage() {
  log I "$0"
  log I "This script is used to run the host Jenkins test."
  log I "By default the lunch target is inferred from the environment as"
  log I "\${TARGET_PRODUCT}-\${TARGET_BUILD_VARIANT} (as set up by the \`lunch\`"
  log I "command). If those are not defined \`${default_lunch_target}\` is used"
  log I "instead. (current environment's default: $(lunch_target_from_env))"
  log I " -h - help"
  log I " -v - verbose"
}

argument_parser() {
  while getopts ":vh" opt; do
    case ${opt} in
      v)
        enable_verbose
        ;;
      h)
        usage
        exit 0
        ;;
      \?)
        log E "Invalid option: ${OPTARG}"
        abort
        ;;
    esac
  done
}

run_test_with_make_target() {
  local make_target
  if [[ $1 == "gtest" ]]; then
    make_target="test-art-host-gtest"
  else
    make_target="test-art-host-run-test-$2"
  fi
  local -r test_command="make -j${JCPU_COUNT} $make_target"
  log I "Running ${test_command}"
  ${test_command}
}

run_test_with_python_runner() {
  local -r test_command="art/test.py -v -j${JCPU_COUNT} --host --$1 --$2"
  log I "Running ${test_command}"
  ${test_command}
}

run_test_unwrapped() {
  disable_error_on_unset_expansion

  if python_runner_exists; then
    run_test_with_python_runner "$@"
  else
    run_test_with_make_target "$@"
  fi
  local -r return_code=$?
  enable_error_on_unset_expansion
  return ${return_code}
}

run_test() {
  start_section "$2"

  run_test_unwrapped "$1" "$2"
  end_section "$2" "$?"
}

test_gtest() {
  run_test "gtest" "gtest"
}

test_optimizing() {
  run_test "run-test" "optimizing"
}

test_interpreter() {
  run_test "run-test" "interpreter"
}

test_jit() {
  run_test "run-test" "jit"
}

main() {
  argument_parser "$@"
  start_test "${timer_name}"

  setup_android_target_to_environment_or_default "${default_lunch_target}"
  set_environment_host
  set_environment_tests
  build_host

  test_gtest
  test_optimizing
  test_interpreter
  test_jit

  end_test "${timer_name}"
}

main "$@"