OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.native_test; | 5 package org.chromium.native_test; |
6 | 6 |
7 import android.app.Activity; | 7 import android.app.Activity; |
8 import android.app.ActivityManager; | 8 import android.app.ActivityManager; |
9 import android.app.Instrumentation; | 9 import android.app.Instrumentation; |
10 import android.content.ComponentName; | 10 import android.content.ComponentName; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 public class NativeTestInstrumentationTestRunner extends Instrumentation { | 44 public class NativeTestInstrumentationTestRunner extends Instrumentation { |
45 | 45 |
46 public static final String EXTRA_NATIVE_TEST_ACTIVITY = | 46 public static final String EXTRA_NATIVE_TEST_ACTIVITY = |
47 "org.chromium.native_test.NativeTestInstrumentationTestRunner.Native
TestActivity"; | 47 "org.chromium.native_test.NativeTestInstrumentationTestRunner.Native
TestActivity"; |
48 public static final String EXTRA_SHARD_NANO_TIMEOUT = | 48 public static final String EXTRA_SHARD_NANO_TIMEOUT = |
49 "org.chromium.native_test.NativeTestInstrumentationTestRunner.ShardN
anoTimeout"; | 49 "org.chromium.native_test.NativeTestInstrumentationTestRunner.ShardN
anoTimeout"; |
50 public static final String EXTRA_SHARD_SIZE_LIMIT = | 50 public static final String EXTRA_SHARD_SIZE_LIMIT = |
51 "org.chromium.native_test.NativeTestInstrumentationTestRunner.ShardS
izeLimit"; | 51 "org.chromium.native_test.NativeTestInstrumentationTestRunner.ShardS
izeLimit"; |
52 public static final String EXTRA_TEST_LIST_FILE = | 52 public static final String EXTRA_TEST_LIST_FILE = |
53 "org.chromium.native_test.NativeTestInstrumentationTestRunner.TestLi
st"; | 53 "org.chromium.native_test.NativeTestInstrumentationTestRunner.TestLi
st"; |
| 54 public static final String EXTRA_TEST = |
| 55 "org.chromium.native_test.NativeTestInstrumentationTestRunner.Test"; |
54 | 56 |
55 private static final String TAG = "cr_NativeTest"; | 57 private static final String TAG = "cr_NativeTest"; |
56 | 58 |
57 private static final long DEFAULT_SHARD_NANO_TIMEOUT = 60 * 1000000000L; | 59 private static final long DEFAULT_SHARD_NANO_TIMEOUT = 60 * 1000000000L; |
58 // Default to no size limit. | 60 // Default to no size limit. |
59 private static final int DEFAULT_SHARD_SIZE_LIMIT = 0; | 61 private static final int DEFAULT_SHARD_SIZE_LIMIT = 0; |
60 private static final String DEFAULT_NATIVE_TEST_ACTIVITY = | 62 private static final String DEFAULT_NATIVE_TEST_ACTIVITY = |
61 "org.chromium.native_test.NativeUnitTestActivity"; | 63 "org.chromium.native_test.NativeUnitTestActivity"; |
62 private static final Pattern RE_TEST_OUTPUT = | 64 private static final Pattern RE_TEST_OUTPUT = |
63 Pattern.compile("\\[ *([^ ]*) *\\] ?([^ ]+)( .*)?$"); | 65 Pattern.compile("\\[ *([^ ]*) *\\] ?([^ ]+)( .*)?$"); |
(...skipping 21 matching lines...) Expand all Loading... |
85 mTransparentArguments.remove(EXTRA_NATIVE_TEST_ACTIVITY); | 87 mTransparentArguments.remove(EXTRA_NATIVE_TEST_ACTIVITY); |
86 | 88 |
87 String shardNanoTimeout = arguments.getString(EXTRA_SHARD_NANO_TIMEOUT); | 89 String shardNanoTimeout = arguments.getString(EXTRA_SHARD_NANO_TIMEOUT); |
88 if (shardNanoTimeout != null) mShardNanoTimeout = Long.parseLong(shardNa
noTimeout); | 90 if (shardNanoTimeout != null) mShardNanoTimeout = Long.parseLong(shardNa
noTimeout); |
89 mTransparentArguments.remove(EXTRA_SHARD_NANO_TIMEOUT); | 91 mTransparentArguments.remove(EXTRA_SHARD_NANO_TIMEOUT); |
90 | 92 |
91 String shardSizeLimit = arguments.getString(EXTRA_SHARD_SIZE_LIMIT); | 93 String shardSizeLimit = arguments.getString(EXTRA_SHARD_SIZE_LIMIT); |
92 if (shardSizeLimit != null) mShardSizeLimit = Integer.parseInt(shardSize
Limit); | 94 if (shardSizeLimit != null) mShardSizeLimit = Integer.parseInt(shardSize
Limit); |
93 mTransparentArguments.remove(EXTRA_SHARD_SIZE_LIMIT); | 95 mTransparentArguments.remove(EXTRA_SHARD_SIZE_LIMIT); |
94 | 96 |
| 97 String singleTest = arguments.getString(EXTRA_TEST); |
| 98 if (singleTest != null) { |
| 99 ArrayList<String> shard = new ArrayList<>(1); |
| 100 shard.add(singleTest); |
| 101 mShards.add(shard); |
| 102 } |
| 103 |
95 String testListFilePath = arguments.getString(EXTRA_TEST_LIST_FILE); | 104 String testListFilePath = arguments.getString(EXTRA_TEST_LIST_FILE); |
96 if (testListFilePath != null) { | 105 if (testListFilePath != null) { |
97 File testListFile = new File(testListFilePath); | 106 File testListFile = new File(testListFilePath); |
98 try { | 107 try { |
99 BufferedReader testListFileReader = | 108 BufferedReader testListFileReader = |
100 new BufferedReader(new FileReader(testListFile)); | 109 new BufferedReader(new FileReader(testListFile)); |
101 | 110 |
102 String test; | 111 String test; |
103 ArrayList<String> workingShard = new ArrayList<String>(); | 112 ArrayList<String> workingShard = new ArrayList<String>(); |
104 while ((test = testListFileReader.readLine()) != null) { | 113 while ((test = testListFileReader.readLine()) != null) { |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 if (mStdoutFile != null) { | 323 if (mStdoutFile != null) { |
315 if (!mStdoutFile.delete()) { | 324 if (!mStdoutFile.delete()) { |
316 Log.e(TAG, "Unable to delete %s", mStdoutFile.getAbsolutePat
h()); | 325 Log.e(TAG, "Unable to delete %s", mStdoutFile.getAbsolutePat
h()); |
317 } | 326 } |
318 } | 327 } |
319 } | 328 } |
320 return results; | 329 return results; |
321 } | 330 } |
322 | 331 |
323 } | 332 } |
OLD | NEW |