Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/gtest/GTestResultParser.java
41144 views
1
/*
2
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*/
23
24
import javax.xml.XMLConstants;
25
import javax.xml.stream.XMLInputFactory;
26
import javax.xml.stream.XMLStreamConstants;
27
import javax.xml.stream.XMLStreamException;
28
import javax.xml.stream.XMLStreamReader;
29
import java.io.IOException;
30
import java.io.Reader;
31
import java.nio.file.Files;
32
import java.nio.file.Path;
33
import java.util.ArrayList;
34
import java.util.Collections;
35
import java.util.List;
36
37
public class GTestResultParser {
38
private final List<String> _failedTests;
39
40
public GTestResultParser(Path file) {
41
List<String> failedTests = new ArrayList<>();
42
try (Reader r = Files.newBufferedReader(file)) {
43
XMLInputFactory factory = XMLInputFactory.newInstance();
44
factory.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, "");
45
factory.setProperty(XMLConstants.ACCESS_EXTERNAL_SCHEMA, "");
46
XMLStreamReader xmlReader = factory.createXMLStreamReader(r);
47
String testSuite = null;
48
String testCase = null;
49
while (xmlReader.hasNext()) {
50
int code = xmlReader.next();
51
if (code == XMLStreamConstants.START_ELEMENT) {
52
switch (xmlReader.getLocalName()) {
53
case "testsuite":
54
testSuite = xmlReader.getAttributeValue("", "name");
55
break;
56
case "testcase":
57
testCase = xmlReader.getAttributeValue("", "name");
58
break;
59
case "failure":
60
failedTests.add(testSuite + "::" + testCase);
61
break;
62
default:
63
// ignore
64
}
65
}
66
}
67
} catch (XMLStreamException e) {
68
throw new IllegalArgumentException("can't open parse xml " + file, e);
69
} catch (IOException e) {
70
throw new IllegalArgumentException("can't open result file " + file, e);
71
}
72
_failedTests = Collections.unmodifiableList(failedTests);
73
}
74
75
public List<String> failedTests() {
76
return _failedTests;
77
}
78
}
79
80