}
}
- private static List<Pattern> buildPatternList(List<String> filters) {
- List<Pattern> patterns = new ArrayList(filters.size());
+ private static List<Pattern> getPatternFilters(List<String> filters) {
+ List<Pattern> patterns = new ArrayList<Pattern>();
for (String filter : filters) {
- patterns.add(Pattern.compile(filter.replace(".","\\.").replace("*",".*")));
+ if (filter.contains("*")) {
+ patterns.add(Pattern.compile(filter.replace(".","\\.").replace("*",".*")));
+ }
}
return patterns;
}
+ private static Set<String> getNonPatternFilters(List<String> filters) {
+ Set<String> nonPatternFilters = new HashSet<String>();
+ for (String filter : filters) {
+ if (!filter.contains("*")) {
+ nonPatternFilters.add(filter);
+ }
+ }
+ return nonPatternFilters;
+ }
+
private static boolean matchesAny(TestIdentifier test, List<Pattern> patterns) {
for (Pattern pattern : patterns) {
if (pattern.matcher(test.toString()).matches()) {
}
/**
- * Filter tests.
- *
- * '*' is 0 or more characters. '.' is interpreted verbatim.
- *
- * Optimized for small number of filters against many tests.
+ * Filter tests with the option of filtering by pattern.
*
+ * '*' is 0 or more characters.
+ * '.' is interpreted verbatim.
*/
private static void filterTests(Map<TestIdentifier, Set<BatchRunConfiguration>> tests,
List<String> includeFilters,
List<String> excludeFilters) {
// We could filter faster by building the test case tree.
// Let's see if this is fast enough.
- List<Pattern> includes = buildPatternList(includeFilters);
- List<Pattern> excludes = buildPatternList(excludeFilters);
+ Set<String> includeStrings = getNonPatternFilters(includeFilters);
+ Set<String> excludeStrings = getNonPatternFilters(excludeFilters);
+ List<Pattern> includePatterns = getPatternFilters(includeFilters);
+ List<Pattern> excludePatterns = getPatternFilters(excludeFilters);
List<TestIdentifier> testList = new ArrayList(tests.keySet());
for (TestIdentifier test : testList) {
- // Remove test if it does not match includes or matches
- // excludes.
- // Empty include filter includes everything.
- if (includes.isEmpty() || matchesAny(test, includes)) {
- if (!matchesAny(test, excludes)) {
- continue;
- }
+ if (excludeStrings.contains(test.toString())) {
+ tests.remove(test); // remove test if explicitly excluded
+ continue;
+ }
+ boolean includesExist = !includeStrings.isEmpty() || !includePatterns.isEmpty();
+ boolean testIsIncluded = includeStrings.contains(test.toString())
+ || matchesAny(test, includePatterns);
+ if ((includesExist && !testIsIncluded) || matchesAny(test, excludePatterns)) {
+ // if this test isn't included and other tests are,
+ // or if test matches exclude pattern, exclude test
+ tests.remove(test);
}
- tests.remove(test);
}
}
String expectedTrie,
List<TestIdentifier> expectedTests) throws Exception {
-
+ boolean thereAreTests = !expectedTests.isEmpty();
ITestDevice mockDevice = EasyMock.createMock(ITestDevice.class);
ITestInvocationListener mockListener
= EasyMock.createStrictMock(ITestInvocationListener.class);
EasyMock.expect(mockDevice.getProperty("ro.opengles.version"))
.andReturn(Integer.toString(version)).atLeastOnce();
- EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG))).andReturn("")
+ if (thereAreTests)
+ {
+ // only expect to install/uninstall packages if there are any tests
+ EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG))).andReturn("")
.once();
- EasyMock.expect(mockDevice.installPackage(EasyMock.<File>anyObject(),
+ EasyMock.expect(mockDevice.installPackage(EasyMock.<File>anyObject(),
EasyMock.eq(true), EasyMock.eq(AbiUtils.createAbiFlag(ABI.getName()))))
.andReturn(null).once();
+ }
+
mockListener.testRunStarted(getTestId(deqpTest), expectedTests.size());
EasyMock.expectLastCall().once();
- if (expectedTests.size() > 0)
+ if (thereAreTests)
{
expectRenderConfigQuery(mockDevice, 3, 0);
mockListener.testRunEnded(EasyMock.anyLong(), EasyMock.<Map<String, String>>notNull());
EasyMock.expectLastCall().once();
- EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG))).andReturn("")
+ if (thereAreTests)
+ {
+ // package will only be installed if there are tests to run
+ EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG))).andReturn("")
.once();
+ }
EasyMock.replay(mockDevice, mockIDevice);
EasyMock.replay(mockListener);