blob: 414d7790f8e401ac7e32f932828b22b52d2f5f4a [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()
31parser.add_argument('-j', default='', dest='n_threads')
32parser.add_argument('--run-test', '-r', action='store_true', dest='run_test')
33parser.add_argument('--gtest', '-g', action='store_true', dest='gtest')
34parser.add_argument('--target', action='store_true', dest='target')
35parser.add_argument('--host', action='store_true', dest='host')
36options, unknown = parser.parse_known_args()
37
38if options.run_test or not options.gtest:
39 testrunner = os.path.join('./',
40 ANDROID_BUILD_TOP,
41 'art/test/testrunner/testrunner.py')
42 run_test_args = []
43 for arg in sys.argv[1:]:
44 if arg == '--run-test' or arg == '--gtest' \
45 or arg == '-r' or arg == '-g':
46 continue
47 run_test_args.append(arg)
48
49 test_runner_cmd = [testrunner] + run_test_args
50 print test_runner_cmd
51 if subprocess.call(test_runner_cmd):
52 sys.exit(1)
53
54if options.gtest or not options.run_test:
55 build_target = ''
56 if options.host or not options.target:
57 build_target += ' test-art-host-gtest'
58 if options.target or not options.host:
59 build_target += ' test-art-target-gtest'
60
61 build_command = 'make'
62 build_command += ' -j' + str(options.n_threads)
63
64 build_command += ' -C ' + ANDROID_BUILD_TOP
65 build_command += ' ' + build_target
66 # Add 'dist' to avoid Jack issues b/36169180.
67 build_command += ' dist'
68
69 print build_command
70
71 if subprocess.call(build_command.split()):
72 sys.exit(1)
73
74sys.exit(0)