File: test.py

package info (click to toggle)
android-platform-tools 29.0.6-28
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 365,224 kB
  • sloc: cpp: 1,049,638; java: 460,532; ansic: 375,452; asm: 301,257; xml: 134,509; python: 92,731; perl: 62,008; sh: 26,753; makefile: 3,210; javascript: 3,172; yacc: 1,403; lex: 455; awk: 368; ruby: 183; sql: 140
file content (70 lines) | stat: -rwxr-xr-x 2,696 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/env python
#
# Copyright 2017, The Android Open Source Project
#
# 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.

# --run-test : To run run-test
# --gtest : To run gtest
# -j : Number of jobs
# --host: for host tests
# --target: for target tests
# All the other arguments will be passed to the run-test testrunner.
import sys
import subprocess
import os
import argparse

ANDROID_BUILD_TOP = os.environ.get('ANDROID_BUILD_TOP', os.getcwd())

parser = argparse.ArgumentParser()
parser.add_argument('-j', default='', dest='n_threads', help='specify number of concurrent tests')
parser.add_argument('--run-test', '-r', action='store_true', dest='run_test', help='execute run tests')
parser.add_argument('--gtest', '-g', action='store_true', dest='gtest', help='execute gtest tests')
parser.add_argument('--target', action='store_true', dest='target', help='test on target system')
parser.add_argument('--host', action='store_true', dest='host', help='test on build host system')
parser.add_argument('--help-runner', action='store_true', dest='help_runner', help='show help for optional run test arguments')
options, unknown = parser.parse_known_args()

if options.run_test or options.help_runner or not options.gtest:
  testrunner = os.path.join('./',
                          ANDROID_BUILD_TOP,
                            'art/test/testrunner/testrunner.py')
  run_test_args = []
  for arg in sys.argv[1:]:
    if arg == '--run-test' or arg == '--gtest' \
    or arg == '-r' or arg == '-g':
      continue
    if arg == '--help-runner':
      run_test_args = ['--help']
      break
    run_test_args.append(arg)

  test_runner_cmd = [testrunner] + run_test_args
  print test_runner_cmd
  if subprocess.call(test_runner_cmd) or options.help_runner:
    sys.exit(1)

if options.gtest or not options.run_test:
  build_target = ''
  if options.host or not options.target:
    build_target += ' test-art-host-gtest'
  if options.target or not options.host:
    build_target += ' test-art-target-gtest'

  build_command = 'm -j' + str(options.n_threads) + ' ' + build_target
  print build_command
  if subprocess.call(build_command.split(), cwd=ANDROID_BUILD_TOP):
      sys.exit(1)

sys.exit(0)