aboutsummaryrefslogtreecommitdiff
path: root/tests/test_art_host.sh
blob: e33f995051999a92816d0d4326c92827fb35a7a2 (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
#!/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_unwrapped() {
  disable_error_on_unset_expansion
  local -r test_command="art/test.py -v -j${JCPU_COUNT} --host --$1 --$2"
  log I "Running ${test_command}"
  ${test_command}
  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
  build_host

  test_gtest
  test_optimizing
  test_interpreter
  test_jit

  end_test "${timer_name}"
}

main "$@"