Vladimir Marko | 4db2af7 | 2021-04-21 14:49:00 +0000 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
Shubham Ajmera | 54515c7 | 2017-03-23 13:58:23 -0700 | [diff] [blame] | 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. |
| 23 | import sys |
| 24 | import subprocess |
| 25 | import os |
| 26 | import argparse |
| 27 | |
| 28 | ANDROID_BUILD_TOP = os.environ.get('ANDROID_BUILD_TOP', os.getcwd()) |
| 29 | |
| 30 | parser = argparse.ArgumentParser() |
Orion Hodson | 42f1658 | 2017-07-12 11:55:22 +0100 | [diff] [blame] | 31 | parser.add_argument('-j', default='', dest='n_threads', help='specify number of concurrent tests') |
| 32 | parser.add_argument('--run-test', '-r', action='store_true', dest='run_test', help='execute run tests') |
| 33 | parser.add_argument('--gtest', '-g', action='store_true', dest='gtest', help='execute gtest tests') |
| 34 | parser.add_argument('--target', action='store_true', dest='target', help='test on target system') |
| 35 | parser.add_argument('--host', action='store_true', dest='host', help='test on build host system') |
| 36 | parser.add_argument('--help-runner', action='store_true', dest='help_runner', help='show help for optional run test arguments') |
Shubham Ajmera | 54515c7 | 2017-03-23 13:58:23 -0700 | [diff] [blame] | 37 | options, unknown = parser.parse_known_args() |
| 38 | |
Orion Hodson | 42f1658 | 2017-07-12 11:55:22 +0100 | [diff] [blame] | 39 | if options.run_test or options.help_runner or not options.gtest: |
Shubham Ajmera | 54515c7 | 2017-03-23 13:58:23 -0700 | [diff] [blame] | 40 | testrunner = os.path.join('./', |
| 41 | ANDROID_BUILD_TOP, |
| 42 | 'art/test/testrunner/testrunner.py') |
| 43 | run_test_args = [] |
| 44 | for arg in sys.argv[1:]: |
| 45 | if arg == '--run-test' or arg == '--gtest' \ |
| 46 | or arg == '-r' or arg == '-g': |
| 47 | continue |
Orion Hodson | 42f1658 | 2017-07-12 11:55:22 +0100 | [diff] [blame] | 48 | if arg == '--help-runner': |
| 49 | run_test_args = ['--help'] |
| 50 | break |
Shubham Ajmera | 54515c7 | 2017-03-23 13:58:23 -0700 | [diff] [blame] | 51 | run_test_args.append(arg) |
| 52 | |
| 53 | test_runner_cmd = [testrunner] + run_test_args |
Vladimir Marko | 4db2af7 | 2021-04-21 14:49:00 +0000 | [diff] [blame] | 54 | print(test_runner_cmd) |
Orion Hodson | 42f1658 | 2017-07-12 11:55:22 +0100 | [diff] [blame] | 55 | if subprocess.call(test_runner_cmd) or options.help_runner: |
Shubham Ajmera | 54515c7 | 2017-03-23 13:58:23 -0700 | [diff] [blame] | 56 | sys.exit(1) |
| 57 | |
| 58 | if options.gtest or not options.run_test: |
| 59 | build_target = '' |
| 60 | if options.host or not options.target: |
| 61 | build_target += ' test-art-host-gtest' |
| 62 | if options.target or not options.host: |
| 63 | build_target += ' test-art-target-gtest' |
| 64 | |
Vladimir Marko | 4db2af7 | 2021-04-21 14:49:00 +0000 | [diff] [blame] | 65 | build_command = ANDROID_BUILD_TOP + '/build/soong/soong_ui.bash --make-mode' |
| 66 | build_command += ' -j' + str(options.n_threads) |
| 67 | build_command += ' ' + build_target |
| 68 | print(build_command) |
Martin Stjernholm | 411a6de | 2019-08-09 13:17:45 +0100 | [diff] [blame] | 69 | if subprocess.call(build_command.split(), cwd=ANDROID_BUILD_TOP): |
Vladimir Marko | 4db2af7 | 2021-04-21 14:49:00 +0000 | [diff] [blame] | 70 | sys.exit(1) |
Shubham Ajmera | 54515c7 | 2017-03-23 13:58:23 -0700 | [diff] [blame] | 71 | |
| 72 | sys.exit(0) |