blob: c6958f1b6ccea830ed56488756b613be231ffefe [file] [log] [blame]
David Srbecky854725b2021-04-27 19:30:41 +01001#!/usr/bin/env python3
2#
3# [VPYTHON:BEGIN]
4# python_version: "3.8"
5# [VPYTHON:END]
David Srbecky10132a02021-04-23 22:28:15 +01006#
7# Copyright (C) 2021 The Android Open Source Project
8#
9# Licensed under the Apache License, Version 2.0 (the "License");
10# you may not use this file except in compliance with the License.
11# You may obtain a copy of the License at
12#
13# http://www.apache.org/licenses/LICENSE-2.0
14#
15# Unless required by applicable law or agreed to in writing, software
16# distributed under the License is distributed on an "AS IS" BASIS,
17# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18# See the License for the specific language governing permissions and
19# limitations under the License.
20
David Srbeckya0ef40d2021-04-25 21:15:01 +010021import sys, os, argparse, subprocess, shlex, re, concurrent.futures, multiprocessing
David Srbecky10132a02021-04-23 22:28:15 +010022
23def parse_args():
24 parser = argparse.ArgumentParser(description="Run libcore tests using the vogar testing tool.")
25 parser.add_argument('--mode', choices=['device', 'host', 'jvm'], required=True,
26 help='Specify where tests should be run.')
27 parser.add_argument('--variant', choices=['X32', 'X64'],
28 help='Which dalvikvm variant to execute with.')
David Srbeckya0ef40d2021-04-25 21:15:01 +010029 parser.add_argument('-j', '--jobs', type=int,
30 help='Number of tests to run simultaneously.')
David Srbecky10132a02021-04-23 22:28:15 +010031 parser.add_argument('--timeout', type=int,
32 help='How long to run the test before aborting (seconds).')
33 parser.add_argument('--debug', action='store_true',
34 help='Use debug version of ART (device|host only).')
35 parser.add_argument('--dry-run', action='store_true',
36 help='Print vogar command-line, but do not run.')
37 parser.add_argument('--no-getrandom', action='store_false', dest='getrandom',
38 help='Ignore failures from getrandom() (for kernel < 3.17).')
39 parser.add_argument('--no-jit', action='store_false', dest='jit',
40 help='Disable JIT (device|host only).')
41 parser.add_argument('--gcstress', action='store_true',
42 help='Enable GC stress configuration (device|host only).')
43 parser.add_argument('tests', nargs="*",
44 help='Name(s) of the test(s) to run')
Orion Hodson77aa45d2022-10-14 16:11:56 +010045 parser.add_argument('--verbose', action='store_true', help='Print verbose output from vogar.')
David Srbecky10132a02021-04-23 22:28:15 +010046 return parser.parse_args()
47
48ART_TEST_ANDROID_ROOT = os.environ.get("ART_TEST_ANDROID_ROOT", "/system")
49ART_TEST_CHROOT = os.environ.get("ART_TEST_CHROOT")
50ANDROID_PRODUCT_OUT = os.environ.get("ANDROID_PRODUCT_OUT")
51
52LIBCORE_TEST_NAMES = [
Nikita Iashchenko2eebc532022-04-07 15:09:33 +010053 ### luni tests. ###
Santiago Aboy Solanes6a1d9b92022-04-06 08:28:51 +000054 # Naive critical path optimization: Run the longest tests first.
David Srbeckya0ef40d2021-04-25 21:15:01 +010055 "org.apache.harmony.tests.java.util", # 90min under gcstress
56 "libcore.java.lang", # 90min under gcstress
57 "jsr166", # 60min under gcstress
58 "libcore.java.util", # 60min under gcstress
59 "libcore.java.math", # 50min under gcstress
60 "org.apache.harmony.crypto", # 30min under gcstress
61 "org.apache.harmony.tests.java.io", # 30min under gcstress
62 "org.apache.harmony.tests.java.text", # 30min under gcstress
Santiago Aboy Solanes6a1d9b92022-04-06 08:28:51 +000063 # Split highmemorytest to individual classes since it is too big.
David Srbeckya0ef40d2021-04-25 21:15:01 +010064 "libcore.highmemorytest.java.text.DateFormatTest",
65 "libcore.highmemorytest.java.text.DecimalFormatTest",
66 "libcore.highmemorytest.java.text.SimpleDateFormatTest",
67 "libcore.highmemorytest.java.time.format.DateTimeFormatterTest",
68 "libcore.highmemorytest.java.util.CalendarTest",
69 "libcore.highmemorytest.java.util.CurrencyTest",
Victor Changae7335e2022-02-09 10:59:42 +000070 "libcore.highmemorytest.libcore.icu.SimpleDateFormatDataTest",
Nikita Iashchenko2eebc532022-04-07 15:09:33 +010071 # All other luni tests in alphabetical order.
David Srbecky10132a02021-04-23 22:28:15 +010072 "libcore.android.system",
73 "libcore.build",
74 "libcore.dalvik.system",
75 "libcore.java.awt",
David Srbecky10132a02021-04-23 22:28:15 +010076 "libcore.java.text",
David Srbecky10132a02021-04-23 22:28:15 +010077 "libcore.javax.crypto",
78 "libcore.javax.net",
79 "libcore.javax.security",
80 "libcore.javax.sql",
81 "libcore.javax.xml",
82 "libcore.libcore.icu",
83 "libcore.libcore.internal",
84 "libcore.libcore.io",
85 "libcore.libcore.net",
86 "libcore.libcore.reflect",
87 "libcore.libcore.util",
88 "libcore.sun.invoke",
David Srbecky10132a02021-04-23 22:28:15 +010089 "libcore.sun.misc",
David Srbeckya0ef40d2021-04-25 21:15:01 +010090 "libcore.sun.net",
David Srbecky10132a02021-04-23 22:28:15 +010091 "libcore.sun.security",
92 "libcore.sun.util",
93 "libcore.xml",
94 "org.apache.harmony.annotation",
Orion Hodson8a5c2f32022-11-08 12:57:11 +000095 "org.apache.harmony.luni.tests.internal.net.www.protocol.http.HttpURLConnection",
96 "org.apache.harmony.luni.tests.internal.net.www.protocol.https.HttpsURLConnection",
97 "org.apache.harmony.luni.tests.java.io",
98 "org.apache.harmony.luni.tests.java.net",
David Srbecky10132a02021-04-23 22:28:15 +010099 "org.apache.harmony.nio",
100 "org.apache.harmony.regex",
101 "org.apache.harmony.testframework",
David Srbecky10132a02021-04-23 22:28:15 +0100102 "org.apache.harmony.tests.java.lang",
103 "org.apache.harmony.tests.java.math",
David Srbecky10132a02021-04-23 22:28:15 +0100104 "org.apache.harmony.tests.javax.security",
105 "tests.java.lang.String",
Nikita Iashchenko2eebc532022-04-07 15:09:33 +0100106 ### OpenJDK upstream tests (ojluni). ###
107 # "test.java.awt",
108 "test.java.awt",
109 # test.java.io
110 "test.java.io.ByteArrayInputStream",
111 "test.java.io.ByteArrayOutputStream",
112 "test.java.io.FileReader",
113 "test.java.io.FileWriter",
114 "test.java.io.InputStream",
115 "test.java.io.OutputStream",
116 "test.java.io.PrintStream",
117 "test.java.io.PrintWriter",
118 "test.java.io.Reader",
119 "test.java.io.Writer",
120 # test.java.lang
121 "test.java.lang.Boolean",
122 "test.java.lang.ClassLoader",
123 "test.java.lang.Double",
124 "test.java.lang.Float",
125 "test.java.lang.Integer",
126 "test.java.lang.Long",
Nikita Iashchenko86f1b3f2022-04-20 15:39:23 +0100127 # Sharded test.java.lang.StrictMath
128 "test.java.lang.StrictMath.CubeRootTests",
Victor Chang37c04d82022-09-28 10:44:22 +0100129 # TODO: disable the test until b/248208762 is fixed.
130 # "test.java.lang.StrictMath.ExactArithTests",
Nikita Iashchenko86f1b3f2022-04-20 15:39:23 +0100131 "test.java.lang.StrictMath.Expm1Tests",
132 "test.java.lang.StrictMath.ExpTests",
133 "test.java.lang.StrictMath.HyperbolicTests",
134 "test.java.lang.StrictMath.HypotTests#testAgainstTranslit_shard1",
135 "test.java.lang.StrictMath.HypotTests#testAgainstTranslit_shard2",
136 "test.java.lang.StrictMath.HypotTests#testAgainstTranslit_shard3",
137 "test.java.lang.StrictMath.HypotTests#testAgainstTranslit_shard4",
138 "test.java.lang.StrictMath.HypotTests#testHypot",
139 "test.java.lang.StrictMath.Log1pTests",
140 "test.java.lang.StrictMath.Log10Tests",
141 "test.java.lang.StrictMath.MultiplicationTests",
142 "test.java.lang.StrictMath.PowTests",
Nikita Iashchenko2eebc532022-04-07 15:09:33 +0100143 "test.java.lang.String",
144 "test.java.lang.Thread",
145 # test.java.lang.invoke
146 "test.java.lang.invoke",
147 # test.java.lang.ref
148 "test.java.lang.ref.SoftReference",
149 "test.java.lang.ref.BasicTest",
150 "test.java.lang.ref.EnqueueNullRefTest",
151 "test.java.lang.ref.EnqueuePollRaceTest",
152 "test.java.lang.ref.ReferenceCloneTest",
153 "test.java.lang.ref.ReferenceEnqueuePendingTest",
154 # test.java.math
155 "test.java.math.BigDecimal",
Nikita Iashchenko86f1b3f2022-04-20 15:39:23 +0100156 # Sharded test.java.math.BigInteger
157 "test.java.math.BigInteger#testArithmetic",
158 "test.java.math.BigInteger#testBitCount",
159 "test.java.math.BigInteger#testBitLength",
160 "test.java.math.BigInteger#testbitOps",
161 "test.java.math.BigInteger#testBitwise",
162 "test.java.math.BigInteger#testByteArrayConv",
163 "test.java.math.BigInteger#testConstructor",
164 "test.java.math.BigInteger#testDivideAndReminder",
165 "test.java.math.BigInteger#testDivideLarge",
166 "test.java.math.BigInteger#testModExp",
Nikita Iashchenko86f1b3f2022-04-20 15:39:23 +0100167 "test.java.math.BigInteger#testMultiplyLarge",
168 "test.java.math.BigInteger#testNextProbablePrime",
169 "test.java.math.BigInteger#testPow",
Nikita Iashchenko86f1b3f2022-04-20 15:39:23 +0100170 "test.java.math.BigInteger#testSerialize",
171 "test.java.math.BigInteger#testShift",
172 "test.java.math.BigInteger#testSquare",
173 "test.java.math.BigInteger#testSquareLarge",
Nikita Iashchenko86f1b3f2022-04-20 15:39:23 +0100174 "test.java.math.BigInteger#testSquareRootAndReminder",
175 "test.java.math.BigInteger#testStringConv_generic",
Nikita Iashchenko2eebc532022-04-07 15:09:33 +0100176 "test.java.math.RoundingMode",
177 # test.java.net
178 "test.java.net.DatagramSocket",
179 "test.java.net.Socket",
180 "test.java.net.SocketOptions",
181 "test.java.net.URLDecoder",
182 "test.java.net.URLEncoder",
183 # test.java.nio
184 "test.java.nio.channels.Channels",
185 "test.java.nio.channels.SelectionKey",
186 "test.java.nio.channels.Selector",
187 "test.java.nio.file",
188 # test.java.security
189 "test.java.security.cert",
Nikita Iashchenko86f1b3f2022-04-20 15:39:23 +0100190 # Sharded test.java.security.KeyAgreement
191 "test.java.security.KeyAgreement.KeyAgreementTest",
Nikita Iashchenko86f1b3f2022-04-20 15:39:23 +0100192 "test.java.security.KeyAgreement.KeySizeTest#testECDHKeySize",
193 "test.java.security.KeyAgreement.KeySpecTest",
194 "test.java.security.KeyAgreement.MultiThreadTest",
195 "test.java.security.KeyAgreement.NegativeTest",
Nikita Iashchenko2eebc532022-04-07 15:09:33 +0100196 "test.java.security.KeyStore",
197 "test.java.security.Provider",
198 # test.java.time
199 "test.java.time",
200 # test.java.util
201 "test.java.util.Arrays",
202 "test.java.util.Collection",
203 "test.java.util.Collections",
204 "test.java.util.Date",
205 "test.java.util.EnumMap",
206 "test.java.util.EnumSet",
207 "test.java.util.GregorianCalendar",
208 "test.java.util.LinkedHashMap",
209 "test.java.util.LinkedHashSet",
210 "test.java.util.List",
211 "test.java.util.Map",
212 "test.java.util.Optional",
213 "test.java.util.TestFormatter",
214 "test.java.util.TimeZone",
215 # test.java.util.concurrent
216 "test.java.util.concurrent",
217 # test.java.util.function
218 "test.java.util.function",
219 # test.java.util.stream
220 "test.java.util.stream",
221 # test.java.util.zip
222 "test.java.util.zip.ZipFile",
223 # tck.java.time
224 "tck.java.time",
David Srbecky10132a02021-04-23 22:28:15 +0100225]
226# "org.apache.harmony.security", # We don't have rights to revert changes in case of failures.
227
228# Note: This must start with the CORE_IMG_JARS in Android.common_path.mk
229# because that's what we use for compiling the boot.art image.
230# It may contain additional modules from TEST_CORE_JARS.
231BOOT_CLASSPATH = [
232 "/apex/com.android.art/javalib/core-oj.jar",
233 "/apex/com.android.art/javalib/core-libart.jar",
234 "/apex/com.android.art/javalib/okhttp.jar",
235 "/apex/com.android.art/javalib/bouncycastle.jar",
236 "/apex/com.android.art/javalib/apache-xml.jar",
237 "/apex/com.android.i18n/javalib/core-icu4j.jar",
238 "/apex/com.android.conscrypt/javalib/conscrypt.jar",
239]
240
Nikita Iashchenko62df93b2022-03-25 16:55:56 +0000241CLASSPATH = ["core-tests", "core-ojtests", "jsr166-tests", "mockito-target"]
David Srbecky10132a02021-04-23 22:28:15 +0100242
Nikita Iashchenko195e38b2022-04-29 17:16:25 +0100243SLOW_OJLUNI_TESTS = {
244 "test.java.awt",
245 "test.java.lang.String",
246 "test.java.lang.invoke",
247 "test.java.nio.channels.Selector",
248 "test.java.time",
249 "test.java.util.Arrays",
250 "test.java.util.Map",
251 "test.java.util.concurrent",
252 "test.java.util.stream",
253 "test.java.util.zip.ZipFile",
254 "tck.java.time",
255}
256
Nikita Iashchenko6f82e432022-06-23 17:58:07 +0100257# Disabled to unblock art-buildbot
258# These tests fail with "java.io.IOException: Stream closed", tracked in
259# http://b/235566533 and http://b/208639267
260DISABLED_GCSTRESS_DEBUG_TESTS = {
David Srbecky27e028a2022-06-30 10:23:39 +0100261 "test.java.lang.StrictMath.HypotTests#testAgainstTranslit_shard1",
262 "test.java.lang.StrictMath.HypotTests#testAgainstTranslit_shard2",
263 "test.java.lang.StrictMath.HypotTests#testAgainstTranslit_shard3",
264 "test.java.lang.StrictMath.HypotTests#testAgainstTranslit_shard4",
Nikita Iashchenko6f82e432022-06-23 17:58:07 +0100265 "test.java.math.BigDecimal",
David Srbecky27e028a2022-06-30 10:23:39 +0100266 "test.java.math.BigInteger#testConstructor",
Nikita Iashchenko6f82e432022-06-23 17:58:07 +0100267}
268
Nikita Iashchenkodbf5f6a2022-06-23 18:38:38 +0100269DISABLED_FUGU_TESTS = {
Orion Hodson8a5c2f32022-11-08 12:57:11 +0000270 "org.apache.harmony.luni.tests.internal.net.www.protocol.http.HttpURLConnection",
271 "org.apache.harmony.luni.tests.internal.net.www.protocol.https.HttpsURLConnection",
Nikita Iashchenkodbf5f6a2022-06-23 18:38:38 +0100272 "test.java.awt",
273 "test.java.io.ByteArrayInputStream",
274 "test.java.io.ByteArrayOutputStream",
Nikita Iashchenko731e4802022-07-06 17:03:00 +0100275 "test.java.io.InputStream",
Nikita Iashchenkodbf5f6a2022-06-23 18:38:38 +0100276 "test.java.io.OutputStream",
277 "test.java.io.PrintStream",
278 "test.java.io.PrintWriter",
279 "test.java.io.Reader",
280 "test.java.io.Writer",
281 "test.java.lang.Boolean",
282 "test.java.lang.ClassLoader",
283 "test.java.lang.Double",
284 "test.java.lang.Float",
285 "test.java.lang.Integer",
286 "test.java.lang.Long",
287 "test.java.lang.StrictMath.CubeRootTests",
288 "test.java.lang.StrictMath.Expm1Tests",
289 "test.java.lang.StrictMath.ExpTests",
290 "test.java.lang.StrictMath.HyperbolicTests",
Nikita Iashchenko38cb5ad2022-07-04 14:37:49 +0100291 "test.java.lang.StrictMath.HypotTests#testAgainstTranslit_shard1",
292 "test.java.lang.StrictMath.HypotTests#testAgainstTranslit_shard2",
293 "test.java.lang.StrictMath.HypotTests#testAgainstTranslit_shard3",
294 "test.java.lang.StrictMath.HypotTests#testAgainstTranslit_shard4",
295 "test.java.lang.StrictMath.HypotTests#testHypot",
Nikita Iashchenkodbf5f6a2022-06-23 18:38:38 +0100296 "test.java.lang.StrictMath.Log1pTests",
297 "test.java.lang.StrictMath.Log10Tests",
298 "test.java.lang.StrictMath.MultiplicationTests",
299 "test.java.lang.StrictMath.PowTests",
300 "test.java.lang.String",
301 "test.java.lang.Thread",
302 "test.java.lang.invoke",
303 "test.java.lang.ref.SoftReference",
304 "test.java.lang.ref.BasicTest",
305 "test.java.lang.ref.EnqueueNullRefTest",
306 "test.java.lang.ref.EnqueuePollRaceTest",
307 "test.java.lang.ref.ReferenceCloneTest",
308 "test.java.lang.ref.ReferenceEnqueuePendingTest",
309 "test.java.math.BigDecimal",
Nikita Iashchenko38cb5ad2022-07-04 14:37:49 +0100310 "test.java.math.BigInteger#testArithmetic",
311 "test.java.math.BigInteger#testBitCount",
312 "test.java.math.BigInteger#testBitLength",
313 "test.java.math.BigInteger#testbitOps",
314 "test.java.math.BigInteger#testBitwise",
315 "test.java.math.BigInteger#testByteArrayConv",
316 "test.java.math.BigInteger#testConstructor",
317 "test.java.math.BigInteger#testDivideAndReminder",
318 "test.java.math.BigInteger#testDivideLarge",
319 "test.java.math.BigInteger#testModExp",
320 "test.java.math.BigInteger#testMultiplyLarge",
321 "test.java.math.BigInteger#testNextProbablePrime",
322 "test.java.math.BigInteger#testPow",
323 "test.java.math.BigInteger#testSerialize",
324 "test.java.math.BigInteger#testShift",
325 "test.java.math.BigInteger#testSquare",
326 "test.java.math.BigInteger#testSquareLarge",
327 "test.java.math.BigInteger#testSquareRootAndReminder",
328 "test.java.math.BigInteger#testStringConv_generic",
Nikita Iashchenkodbf5f6a2022-06-23 18:38:38 +0100329 "test.java.math.RoundingMode",
330 "test.java.net.DatagramSocket",
331 "test.java.net.Socket",
332 "test.java.net.SocketOptions",
333 "test.java.net.URLDecoder",
334 "test.java.net.URLEncoder",
335 "test.java.nio.channels.Channels",
336 "test.java.nio.channels.SelectionKey",
Nikita Iashchenko731e4802022-07-06 17:03:00 +0100337 "test.java.nio.channels.Selector",
Nikita Iashchenkodbf5f6a2022-06-23 18:38:38 +0100338 "test.java.nio.file",
339 "test.java.security.cert",
340 "test.java.security.KeyAgreement.KeyAgreementTest",
Nikita Iashchenko38cb5ad2022-07-04 14:37:49 +0100341 "test.java.security.KeyAgreement.KeySizeTest#testECDHKeySize",
Nikita Iashchenkodbf5f6a2022-06-23 18:38:38 +0100342 "test.java.security.KeyAgreement.KeySpecTest",
343 "test.java.security.KeyAgreement.MultiThreadTest",
344 "test.java.security.KeyAgreement.NegativeTest",
345 "test.java.security.KeyStore",
346 "test.java.security.Provider",
Nikita Iashchenko731e4802022-07-06 17:03:00 +0100347 "test.java.time",
Nikita Iashchenkodbf5f6a2022-06-23 18:38:38 +0100348 "test.java.util.Arrays",
349 "test.java.util.Collection",
350 "test.java.util.Collections",
351 "test.java.util.Date",
352 "test.java.util.EnumMap",
353 "test.java.util.EnumSet",
354 "test.java.util.GregorianCalendar",
355 "test.java.util.LinkedHashMap",
356 "test.java.util.LinkedHashSet",
357 "test.java.util.List",
358 "test.java.util.Map",
359 "test.java.util.Optional",
360 "test.java.util.TestFormatter",
361 "test.java.util.TimeZone",
362 "test.java.util.function",
363 "test.java.util.stream",
364 "tck.java.time",
365}
366
David Srbecky10132a02021-04-23 22:28:15 +0100367def get_jar_filename(classpath):
368 base_path = (ANDROID_PRODUCT_OUT + "/../..") if ANDROID_PRODUCT_OUT else "out/target"
369 base_path = os.path.normpath(base_path) # Normalize ".." components for readability.
370 return f"{base_path}/common/obj/JAVA_LIBRARIES/{classpath}_intermediates/classes.jar"
371
372def get_timeout_secs():
373 default_timeout_secs = 600
David Srbecky2ce26fd2021-05-19 18:26:54 +0100374 if args.gcstress:
David Srbecky10132a02021-04-23 22:28:15 +0100375 default_timeout_secs = 1200
376 if args.debug:
377 default_timeout_secs = 1800
378 return args.timeout or default_timeout_secs
379
380def get_expected_failures():
381 failures = ["art/tools/libcore_failures.txt"]
382 if args.mode != "jvm":
383 if args.gcstress:
384 failures.append("art/tools/libcore_gcstress_failures.txt")
385 if args.gcstress and args.debug:
386 failures.append("art/tools/libcore_gcstress_debug_failures.txt")
David Srbecky680d7682021-05-04 16:56:37 +0100387 if args.debug and not args.gcstress and args.getrandom:
David Srbecky10132a02021-04-23 22:28:15 +0100388 failures.append("art/tools/libcore_debug_failures.txt")
389 if not args.getrandom:
390 failures.append("art/tools/libcore_fugu_failures.txt")
391 return failures
392
393def get_test_names():
394 if args.tests:
395 return args.tests
396 test_names = list(LIBCORE_TEST_NAMES)
397 # See b/78228743 and b/178351808.
398 if args.gcstress or args.debug or args.mode == "jvm":
David Srbeckya0ef40d2021-04-25 21:15:01 +0100399 test_names = list(t for t in test_names if not t.startswith("libcore.highmemorytest"))
Nikita Iashchenko195e38b2022-04-29 17:16:25 +0100400 test_names = list(filter(lambda x: x not in SLOW_OJLUNI_TESTS, test_names))
David Srbecky27e028a2022-06-30 10:23:39 +0100401 if args.gcstress and args.debug:
Nikita Iashchenko6f82e432022-06-23 17:58:07 +0100402 test_names = list(filter(lambda x: x not in DISABLED_GCSTRESS_DEBUG_TESTS, test_names))
Nikita Iashchenkodbf5f6a2022-06-23 18:38:38 +0100403 if not args.getrandom:
Victor Chang52ab1e92022-11-08 14:38:25 +0000404 # Disable libcore.highmemorytest due to limited ram on fugu. http://b/258173036
405 test_names = list(filter(lambda x: x not in DISABLED_FUGU_TESTS and
406 not x.startswith("libcore.highmemorytest"), test_names))
David Srbecky10132a02021-04-23 22:28:15 +0100407 return test_names
408
David Srbeckya0ef40d2021-04-25 21:15:01 +0100409def get_vogar_command(test_name):
David Srbecky10132a02021-04-23 22:28:15 +0100410 cmd = ["vogar"]
411 if args.mode == "device":
Jiakai Zhang45c6d8b2022-02-18 14:17:31 +0000412 cmd.append("--mode=device --vm-arg -Ximage:/system/framework/art_boot_images/boot.art")
David Srbecky10132a02021-04-23 22:28:15 +0100413 cmd.append("--vm-arg -Xbootclasspath:" + ":".join(BOOT_CLASSPATH))
Orion Hodson77aa45d2022-10-14 16:11:56 +0100414
David Srbecky10132a02021-04-23 22:28:15 +0100415 if args.mode == "host":
416 # We explicitly give a wrong path for the image, to ensure vogar
417 # will create a boot image with the default compiler. Note that
418 # giving an existing image on host does not work because of
419 # classpath/resources differences when compiling the boot image.
420 cmd.append("--mode=host --vm-arg -Ximage:/non/existent/vogar.art")
421 if args.mode == "jvm":
422 cmd.append("--mode=jvm")
423 if args.variant:
424 cmd.append("--variant=" + args.variant)
425 if args.gcstress:
426 cmd.append("--vm-arg -Xgc:gcstress")
Sorin Basca24bdf642022-02-07 15:47:01 +0000427 cmd.append('--vm-arg -Djsr166.delay.factor="1.50"')
David Srbecky10132a02021-04-23 22:28:15 +0100428 if args.debug:
429 cmd.append("--vm-arg -XXlib:libartd.so --vm-arg -XX:SlowDebug=true")
430
Orion Hodson8858dc22022-11-14 10:52:15 +0000431 # The only device in go/art-buildbot without getrandom is fugu. We limit the amount of memory
432 # per runtime for fugu to avoid low memory killer, fugu has 4-cores 1GB RAM (b/258171768).
433 if not args.getrandom:
434 cmd.append("--vm-arg -Xmx128M")
435
David Srbecky10132a02021-04-23 22:28:15 +0100436 if args.mode == "device":
437 if ART_TEST_CHROOT:
David Srbeckya0ef40d2021-04-25 21:15:01 +0100438 cmd.append(f"--chroot {ART_TEST_CHROOT} --device-dir=/tmp/vogar/test-{test_name}")
David Srbecky10132a02021-04-23 22:28:15 +0100439 else:
Nikita Iashchenko36983102022-06-24 15:21:53 +0100440 cmd.append(f"--device-dir=/data/local/tmp/vogar/test-{test_name}")
David Srbecky10132a02021-04-23 22:28:15 +0100441 cmd.append(f"--vm-command={ART_TEST_ANDROID_ROOT}/bin/art")
David Srbeckya0ef40d2021-04-25 21:15:01 +0100442 else:
443 cmd.append(f"--device-dir=/tmp/vogar/test-{test_name}")
David Srbecky10132a02021-04-23 22:28:15 +0100444
445 if args.mode != "jvm":
446 cmd.append("--timeout {}".format(get_timeout_secs()))
David Srbecky10132a02021-04-23 22:28:15 +0100447 cmd.append("--toolchain d8 --language CUR")
448 if args.jit:
449 cmd.append("--vm-arg -Xcompiler-option --vm-arg --compiler-filter=quicken")
450 cmd.append("--vm-arg -Xusejit:{}".format(str(args.jit).lower()))
451
Orion Hodson77aa45d2022-10-14 16:11:56 +0100452 if args.verbose:
453 cmd.append("--verbose")
454
David Srbecky10132a02021-04-23 22:28:15 +0100455 # Suppress color codes if not attached to a terminal
456 if not sys.stdout.isatty():
457 cmd.append("--no-color")
458
459 cmd.extend("--expectations " + f for f in get_expected_failures())
460 cmd.extend("--classpath " + get_jar_filename(cp) for cp in CLASSPATH)
David Srbeckya0ef40d2021-04-25 21:15:01 +0100461 cmd.append(test_name)
David Srbecky10132a02021-04-23 22:28:15 +0100462 return cmd
463
David Srbeckya0ef40d2021-04-25 21:15:01 +0100464def get_target_cpu_count():
465 adb_command = 'adb shell cat /sys/devices/system/cpu/present'
466 with subprocess.Popen(adb_command.split(),
467 stderr=subprocess.STDOUT,
468 stdout=subprocess.PIPE,
469 universal_newlines=True) as proc:
470 assert(proc.wait() == 0) # Check the exit code.
471 match = re.match(r'\d*-(\d*)', proc.stdout.read())
472 assert(match)
473 return int(match.group(1)) + 1 # Add one to convert from "last-index" to "count"
474
David Srbecky10132a02021-04-23 22:28:15 +0100475def main():
476 global args
477 args = parse_args()
478
479 if not os.path.exists('build/envsetup.sh'):
480 raise AssertionError("Script needs to be run at the root of the android tree")
481 for jar in map(get_jar_filename, CLASSPATH):
482 if not os.path.exists(jar):
483 raise AssertionError(f"Missing {jar}. Run buildbot-build.sh first.")
484
David Srbeckya0ef40d2021-04-25 21:15:01 +0100485 if not args.jobs:
David Srbeckyf75b8e92021-06-07 11:11:38 +0000486 if args.mode == "device":
487 args.jobs = get_target_cpu_count()
488 else:
489 args.jobs = multiprocessing.cpu_count()
490 if args.gcstress:
491 # TODO: Investigate and fix the underlying issues.
492 args.jobs = args.jobs // 2
David Srbeckya0ef40d2021-04-25 21:15:01 +0100493
494 def run_test(test_name):
495 cmd = " ".join(get_vogar_command(test_name))
496 if args.dry_run:
497 return test_name, cmd, "Dry-run: skipping execution", 0
498 with subprocess.Popen(shlex.split(cmd),
499 stderr=subprocess.STDOUT,
500 stdout=subprocess.PIPE,
501 universal_newlines=True) as proc:
502 return test_name, cmd, proc.communicate()[0], proc.wait()
503
David Srbeckye059ef12021-05-04 18:54:34 +0100504 failed_regex = re.compile(r"^.* FAIL \((?:EXEC_FAILED|ERROR)\)$", re.MULTILINE)
David Srbeckya0ef40d2021-04-25 21:15:01 +0100505 failed_tests, max_exit_code = [], 0
506 with concurrent.futures.ThreadPoolExecutor(max_workers=args.jobs) as pool:
507 futures = [pool.submit(run_test, test_name) for test_name in get_test_names()]
David Srbecky0849c1c2021-04-30 12:22:50 +0100508 print(f"Running {len(futures)} tasks on {args.jobs} core(s)...\n")
David Srbeckya0ef40d2021-04-25 21:15:01 +0100509 for i, future in enumerate(concurrent.futures.as_completed(futures)):
510 test_name, cmd, stdout, exit_code = future.result()
Orion Hodson77aa45d2022-10-14 16:11:56 +0100511 if exit_code != 0 or args.dry_run or args.verbose:
David Srbeckya0ef40d2021-04-25 21:15:01 +0100512 print(cmd)
David Srbecky0849c1c2021-04-30 12:22:50 +0100513 print(stdout.strip())
David Srbeckya0ef40d2021-04-25 21:15:01 +0100514 else:
515 print(stdout.strip().split("\n")[-1]) # Vogar final summary line.
David Srbecky0849c1c2021-04-30 12:22:50 +0100516 failed_match = failed_regex.findall(stdout)
517 failed_tests.extend(failed_match)
David Srbeckya0ef40d2021-04-25 21:15:01 +0100518 max_exit_code = max(max_exit_code, exit_code)
David Srbecky0849c1c2021-04-30 12:22:50 +0100519 result = "PASSED" if exit_code == 0 else f"FAILED ({len(failed_match)} test(s) failed)"
520 print(f"[{i+1}/{len(futures)}] Test set {test_name} {result}\n")
521 print(f"Overall, {len(failed_tests)} test(s) failed:")
522 print("\n".join(failed_tests))
David Srbeckya0ef40d2021-04-25 21:15:01 +0100523 sys.exit(max_exit_code)
David Srbecky10132a02021-04-23 22:28:15 +0100524
525if __name__ == '__main__':
526 main()