blob: 1cbad7252962c9cd3987cc1105b5e33be6da5362 [file] [log] [blame]
Shubham Ajmera54515c72017-03-23 13:58:23 -07001#!/usr/bin/env python
2#
3# Copyright 2017, The Android Open Source Project
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17# --run-test : To run run-test
18# --gtest : To run gtest
19# -j : Number of jobs
20# --host: for host tests
21# --target: for target tests
22# All the other arguments will be passed to the run-test testrunner.
23import sys
24import subprocess
25import os
26import argparse
27
28ANDROID_BUILD_TOP = os.environ.get('ANDROID_BUILD_TOP', os.getcwd())
29
30parser = argparse.ArgumentParser()
Orion Hodson42f16582017-07-12 11:55:22 +010031parser.add_argument('-j', default='', dest='n_threads', help='specify number of concurrent tests')
32parser.add_argument('--run-test', '-r', action='store_true', dest='run_test', help='execute run tests')
33parser.add_argument('--gtest', '-g', action='store_true', dest='gtest', help='execute gtest tests')
34parser.add_argument('--target', action='store_true', dest='target', help='test on target system')
35parser.add_argument('--host', action='store_true', dest='host', help='test on build host system')
Ulyana Trafimoviche886d682020-07-16 15:09:38 +000036parser.add_argument('--simulate-arm64', action='store_true', dest='simulate_arm64', help='test on build host system')
Orion Hodson42f16582017-07-12 11:55:22 +010037parser.add_argument('--help-runner', action='store_true', dest='help_runner', help='show help for optional run test arguments')
Shubham Ajmera54515c72017-03-23 13:58:23 -070038options, unknown = parser.parse_known_args()
39
Orion Hodson42f16582017-07-12 11:55:22 +010040if options.run_test or options.help_runner or not options.gtest:
Shubham Ajmera54515c72017-03-23 13:58:23 -070041 testrunner = os.path.join('./',
42 ANDROID_BUILD_TOP,
43 'art/test/testrunner/testrunner.py')
44 run_test_args = []
45 for arg in sys.argv[1:]:
46 if arg == '--run-test' or arg == '--gtest' \
47 or arg == '-r' or arg == '-g':
48 continue
Orion Hodson42f16582017-07-12 11:55:22 +010049 if arg == '--help-runner':
50 run_test_args = ['--help']
51 break
Shubham Ajmera54515c72017-03-23 13:58:23 -070052 run_test_args.append(arg)
53
54 test_runner_cmd = [testrunner] + run_test_args
55 print test_runner_cmd
Orion Hodson42f16582017-07-12 11:55:22 +010056 if subprocess.call(test_runner_cmd) or options.help_runner:
Shubham Ajmera54515c72017-03-23 13:58:23 -070057 sys.exit(1)
58
59if options.gtest or not options.run_test:
60 build_target = ''
61 if options.host or not options.target:
62 build_target += ' test-art-host-gtest'
63 if options.target or not options.host:
64 build_target += ' test-art-target-gtest'
65
Martin Stjernholm411a6de2019-08-09 13:17:45 +010066 build_command = 'm -j' + str(options.n_threads) + ' ' + build_target
Shubham Ajmera54515c72017-03-23 13:58:23 -070067 print build_command
Martin Stjernholm411a6de2019-08-09 13:17:45 +010068 if subprocess.call(build_command.split(), cwd=ANDROID_BUILD_TOP):
Shubham Ajmera54515c72017-03-23 13:58:23 -070069 sys.exit(1)
70
71sys.exit(0)