Improve error handling (NPE in DRT2)
Bug: 3284126 Change-Id: I7f8c6259f2932d2b1a10a2f9612866786d425da9
This commit is contained in:
committed by
Ben Murdoch
parent
96100195f0
commit
84cc2dbb1d
@@ -42,6 +42,7 @@ def main(path, options):
|
||||
cmd += "-w com.android.dumprendertree2/com.android.dumprendertree2.scriptsupport.ScriptTestRunner"
|
||||
|
||||
logging.info("Running the tests...")
|
||||
logging.debug("Command = %s" % cmd)
|
||||
(stdoutdata, stderrdata) = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
|
||||
if re.search("^INSTRUMENTATION_STATUS_CODE: -1", stdoutdata, re.MULTILINE) != None:
|
||||
logging.info("Failed to run the tests. Is DumpRenderTree2 installed on the device?")
|
||||
|
||||
@@ -68,8 +68,8 @@ public class FileFilter {
|
||||
public void loadTestExpectations() {
|
||||
URL url = null;
|
||||
try {
|
||||
url = new URL(ForwarderManager.getHostSchemePort(false) + "LayoutTests/" +
|
||||
TEST_EXPECTATIONS_TXT_PATH);
|
||||
url = new URL(ForwarderManager.getHostSchemePort(false) +
|
||||
"LayoutTests/" + TEST_EXPECTATIONS_TXT_PATH);
|
||||
} catch (MalformedURLException e) {
|
||||
assert false;
|
||||
}
|
||||
@@ -78,9 +78,14 @@ public class FileFilter {
|
||||
InputStream inputStream = null;
|
||||
BufferedReader bufferedReader = null;
|
||||
try {
|
||||
bufferedReader = new BufferedReader(new StringReader(new String(
|
||||
FsUtils.readDataFromUrl(url))));
|
||||
|
||||
byte[] httpAnswer = FsUtils.readDataFromUrl(url);
|
||||
if (httpAnswer == null) {
|
||||
Log.w(LOG_TAG, "loadTestExpectations(): File not found: " +
|
||||
TEST_EXPECTATIONS_TXT_PATH);
|
||||
return;
|
||||
}
|
||||
bufferedReader = new BufferedReader(new StringReader(
|
||||
new String(httpAnswer)));
|
||||
String line;
|
||||
String entry;
|
||||
String[] parts;
|
||||
@@ -113,7 +118,8 @@ public class FileFilter {
|
||||
path = trimTrailingSlashIfPresent(parts[0]);
|
||||
|
||||
/** Split on whitespace */
|
||||
tokens = new HashSet<String>(Arrays.asList(parts[1].split("\\s", 0)));
|
||||
tokens = new HashSet<String>(Arrays.asList(
|
||||
parts[1].split("\\s", 0)));
|
||||
|
||||
/** Chose the right collections to add to */
|
||||
if (tokens.contains(TOKEN_CRASH)) {
|
||||
@@ -138,8 +144,6 @@ public class FileFilter {
|
||||
bufferedReader.close();
|
||||
}
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
Log.w(LOG_TAG, "reloadConfiguration(): File not found: " + e.getMessage());
|
||||
} catch (IOException e) {
|
||||
Log.e(LOG_TAG, "url=" + url, e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user